Class BarrierOption

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

public final class BarrierOption extends Object
Continuously monitored single-barrier options: all eight in/out, up/down, call/put combinations, regular and reverse, with a cash rebate.

Closed forms of Reiner and Rubinstein (1991), "Breaking down the barriers", Risk 4(8), in the notation of Haug (2007), The Complete Guide to Option Pricing Formulas, 2nd ed., section 4.17.1. With cost of carry b = r − q, μ = (b − σ²/2)/σ², λ = √(μ² + 2r/σ²) and

  x1 = ln(S/X)/(σ√T) + (1+μ)σ√T     x2 = ln(S/H)/(σ√T) + (1+μ)σ√T
  y1 = ln(H²/(SX))/(σ√T) + (1+μ)σ√T y2 = ln(H/S)/(σ√T) + (1+μ)σ√T
  z  = ln(H/S)/(σ√T) + λσ√T

the building blocks A-F (φ = ±1 call/put, η = +1 down, −1 up) combine as in Haug's table: for instance an up-and-out call with X < H is A − B + C − D + F. A knock-in rebate is paid at expiry if the barrier was never touched; a knock-out rebate is paid at the moment of the hit.

Conventions match BlackScholes: carry is the continuous yield q (foreign rate for FX), so b = rate − carry. If the barrier is already breached at spot, a knock-in is the vanilla and a knock-out pays its rebate now. Discrete monitoring is not modelled; the Broadie-Glasserman-Kou (1997) shift H·e^{±0.5826σ√Δt} is the usual correction and can be applied to barrier by the caller.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Barrier direction relative to spot.
    static enum 
    Whether the barrier activates or extinguishes the option.
  • 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, no rebate.
    static double
    downAndOutCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Down-and-out call, no rebate.
    static double
    price(BlackScholes.OptionType type, BarrierOption.Direction direction, BarrierOption.Knock knock, double spot, double strike, double barrier, double rebate, double rate, double carry, double vol, double timeYears)
    Price of a single-barrier option with a cash rebate.
    static double
    upAndInPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Up-and-in put, no rebate.
    static double
    upAndOutPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
    Up-and-out put, no rebate.

    Methods inherited from class Object

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

    • price

      public static double price(BlackScholes.OptionType type, BarrierOption.Direction direction, BarrierOption.Knock knock, double spot, double strike, double barrier, double rebate, double rate, double carry, double vol, double timeYears)
      Price of a single-barrier option with a cash rebate.
      Parameters:
      rebate - cash amount: paid at expiry for an untouched knock-in, at the hit for a knock-out; 0 for none
    • downAndInCall

      public static double downAndInCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Down-and-in call, no rebate. Throws if the barrier is at or above spot.
    • downAndOutCall

      public static double downAndOutCall(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Down-and-out call, no rebate. Throws if the barrier is at or above spot.
    • upAndInPut

      public static double upAndInPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Up-and-in put, no rebate. Throws if the barrier is at or below spot.
    • upAndOutPut

      public static double upAndOutPut(double spot, double strike, double barrier, double rate, double carry, double vol, double timeYears)
      Up-and-out put, no rebate. Throws if the barrier is at or below spot.