Class BarrierOption

java.lang.Object
com.quantfinlib.pricing.BarrierOption

public final class BarrierOption extends Object
Single-barrier vanilla options — continuously monitored knock-in / knock-out — for the regular barrier configurations, priced in closed form by the reflection principle (Reiner–Rubinstein, as in Hull):
  • Down barriers on calls with H ≤ K (barrier in the OTM region): down-and-in from the reflection formula, down-and-out from in–out parity KO = vanilla − KI;
  • Up barriers on puts with H ≥ K, the mirror case.

Reverse barriers (a barrier in the ITM region, e.g. an up-and-out call) knock out exactly where the payoff is largest, need the full eight-case decomposition, and their risk is dominated by the barrier gamma — this class rejects them explicitly rather than pricing them subtly wrong. Price those with simulation.MonteCarloSimulator path pricing or a barrier-aware tree.

No rebates. Conventions match BlackScholes: carry is the continuous yield (foreign rate for FX, dividend yield for equities). With λ = (r − q + σ²/2)/σ² and y = ln(H²/(S·K))/(σ√T) + λσ√T, the down-and-in call is

  c_di = S·e^{−qT}(H/S)^{2λ}·N(y) − K·e^{−rT}(H/S)^{2λ−2}·N(y − σ√T)
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    downAndInCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Down-and-in call, H ≤ min(S, K): alive only after the barrier trades.
    static double
    downAndOutCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Down-and-out call, H ≤ min(S, K): dies if the barrier trades.
    static double
    upAndInPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Up-and-in put, H ≥ max(S, K): the mirror of the down-and-in call.
    static double
    upAndOutPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Up-and-out put, H ≥ max(S, K).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • downAndInCall

      public static double downAndInCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Down-and-in call, H ≤ min(S, K): alive only after the barrier trades.
    • downAndOutCall

      public static double downAndOutCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Down-and-out call, H ≤ min(S, K): dies if the barrier trades.
    • upAndInPut

      public static double upAndInPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Up-and-in put, H ≥ max(S, K): the mirror of the down-and-in call.
    • upAndOutPut

      public static double upAndOutPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Up-and-out put, H ≥ max(S, K).