Class BarrierOptions

java.lang.Object
net.finmath.functions.BarrierOptions

public final class BarrierOptions extends Object
Analytic helper formulas for barrier-style products under Black-Scholes.

This class is intentionally kept in it.univr.fima.correction and serves as the analytic regression backbone for the finite-difference barrier product layer in this project.

Covered formulas include:

  • standard single-barrier vanilla options,
  • single-barrier binary options,
  • single-barrier one-touch / no-touch style binaries,
  • double-barrier vanilla options,
  • double-barrier cash binaries, including KIKO / KOKI,
  • soft barriers.

The class remains in this package on purpose, to avoid name clashes with the upstream dependency class net.finmath.functions.BarrierOptions.

Version:
1.0
Author:
Alessandro Gnoatto
Date:
23.03.2026
  • Method Details

    • blackScholesBarrierOptionValue

      public static double blackScholesBarrierOptionValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double optionStrike, boolean isCall, double rebate, double barrierValue, BarrierOptions.BarrierType barrierType)
      Prices a standard continuously monitored single-barrier European option with possible rebate under Black-Scholes.

      This is the Haug-style single-barrier formula already present in the original helper class.

      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      optionStrike - Strike K.
      isCall - true for a call, false for a put.
      rebate - Cash rebate associated with the barrier event.
      barrierValue - Barrier level H.
      barrierType - Barrier orientation and knock style.
      Returns:
      The single-barrier option value.
    • blackScholesBinaryBarrierOptionValue

      public static double blackScholesBinaryBarrierOptionValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double optionStrike, boolean isCall, double barrierValue, BarrierOptions.BarrierType barrierType, BarrierOptions.BinaryPayoffType binaryPayoffType, double cashPayoff)
      Prices a continuously monitored single-barrier binary option under Black-Scholes.
      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      optionStrike - Strike K.
      isCall - true for a call, false for a put.
      barrierValue - Barrier level H.
      barrierType - Barrier orientation and knock style.
      binaryPayoffType - Cash-or-nothing or asset-or-nothing payoff.
      cashPayoff - Cash amount used when binaryPayoffType is cash-or-nothing.
      Returns:
      The single-barrier binary option value.
    • blackScholesDoubleBarrierOptionValue

      public static double blackScholesDoubleBarrierOptionValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double optionStrike, boolean isCall, double lowerBarrier, double upperBarrier, BarrierOptions.DoubleBarrierType barrierType, int series)
      Prices a continuously monitored double-barrier vanilla option under Black-Scholes using the truncated series also used by QuantLib.
      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      optionStrike - Strike K.
      isCall - true for a call, false for a put.
      lowerBarrier - Lower barrier L.
      upperBarrier - Upper barrier U.
      barrierType - Double-barrier knock style.
      series - Number of image terms retained on each side of zero.
      Returns:
      The double-barrier vanilla option value.
    • blackScholesDoubleBarrierCashBinaryValue

      public static double blackScholesDoubleBarrierCashBinaryValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double cashPayoff, double lowerBarrier, double upperBarrier, BarrierOptions.DoubleBarrierType barrierType, int maxIteration, double requiredConvergence)
      Prices a continuously monitored double-barrier cash binary option under Black-Scholes.
      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      cashPayoff - Cash amount paid when the contract condition is satisfied.
      lowerBarrier - Lower barrier L.
      upperBarrier - Upper barrier U.
      barrierType - Double-barrier binary style.
      maxIteration - Maximum number of series terms.
      requiredConvergence - Absolute convergence tolerance for the last term.
      Returns:
      The double-barrier cash binary value.
    • blackScholesSoftBarrierOptionValue

      public static double blackScholesSoftBarrierOptionValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double optionStrike, boolean isCall, double lowerBarrier, double upperBarrier, BarrierOptions.BarrierType barrierType)
      Prices a soft-barrier option under Black-Scholes.

      The barrier is smoothed over the interval between lowerBarrier and upperBarrier. When the two levels coincide, the method falls back to the standard single-barrier formula.

      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      optionStrike - Strike K.
      isCall - true for a call, false for a put.
      lowerBarrier - Lower end of the soft barrier band.
      upperBarrier - Upper end of the soft barrier band.
      barrierType - Soft knock-in or knock-out direction.
      Returns:
      The soft-barrier option value.
    • blackScholesBinaryBarrierAtHitValue

      public static double blackScholesBinaryBarrierAtHitValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double barrierValue, BarrierOptions.BarrierType barrierType, BarrierOptions.BinaryPayoffType binaryPayoffType, double cashPayoff)
      Prices a continuously monitored single-barrier binary paying at the first hit time.

      This covers the Reiner-Rubinstein / Haug formulas:

      • down-and-in cash-(at-hit)-or-nothing,
      • up-and-in cash-(at-hit)-or-nothing,
      • down-and-in asset-(at-hit)-or-nothing,
      • up-and-in asset-(at-hit)-or-nothing.

      For asset-at-hit, the payoff at hit is the barrier level H, since the hit occurs exactly at S=H.

      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      barrierValue - Barrier level H.
      barrierType - Must be DOWN_IN or UP_IN.
      binaryPayoffType - Cash-or-nothing or asset-or-nothing payoff.
      cashPayoff - Cash amount used for cash-or-nothing.
      Returns:
      The at-hit binary barrier value.
    • blackScholesBinaryBarrierStatusAtExpiryValue

      public static double blackScholesBinaryBarrierStatusAtExpiryValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double barrierValue, BarrierOptions.BarrierType barrierType, BarrierOptions.BinaryBarrierEventType eventType, BarrierOptions.BinaryPayoffType binaryPayoffType, double cashPayoff)
      Prices a continuously monitored single-barrier binary paying at expiry, depending only on whether the barrier has been hit or not.

      This covers the Reiner-Rubinstein / Haug formulas:

      • down/up-and-in cash-(at-expiration)-or-nothing,
      • down/up-and-in asset-(at-expiration)-or-nothing,
      • down/up-and-out cash-or-nothing,
      • down/up-and-out asset-or-nothing.
      Parameters:
      initialStockValue - Spot price S0.
      riskFreeRate - Continuously compounded risk-free rate r.
      dividendYield - Continuously compounded dividend yield q.
      volatility - Black-Scholes volatility sigma.
      optionMaturity - Time to maturity T.
      barrierValue - Barrier level H.
      barrierType - Barrier orientation and knock style.
      eventType - HIT for knock-in style payoff, NO_HIT for knock-out style payoff.
      binaryPayoffType - Cash-or-nothing or asset-or-nothing.
      cashPayoff - Cash amount used when binaryPayoffType is cash-or-nothing.
      Returns:
      The expiry binary barrier value.
    • blackScholesOneTouchValue

      public static double blackScholesOneTouchValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double barrierValue, BarrierOptions.BarrierType barrierType, BarrierOptions.BinaryPayoffType binaryPayoffType, double cashPayoff)
      One-touch / asset-touch convenience wrapper.

      For cash-or-nothing this is a standard one-touch paying cashPayoff at hit. For asset-or-nothing this is an asset-touch paying the barrier level at hit.

      Parameters:
      initialStockValue - The value.
      riskFreeRate - The value.
      dividendYield - The value.
      volatility - The value.
      optionMaturity - The value.
      barrierValue - The value.
      barrierType - The value.
      binaryPayoffType - The value.
      cashPayoff - The value.
      Returns:
      The value.
    • blackScholesBarrierStatusBinaryValue

      public static double blackScholesBarrierStatusBinaryValue(double initialStockValue, double riskFreeRate, double dividendYield, double volatility, double optionMaturity, double barrierValue, BarrierOptions.BarrierType barrierType, BarrierOptions.BinaryBarrierEventType eventType, BarrierOptions.BinaryPayoffType binaryPayoffType, double cashPayoff)
      No-touch / hit-at-expiry convenience wrapper.

      Use DOWN_OUT or UP_OUT with eventType NO_HIT for no-touch, and DOWN_IN or UP_IN with eventType HIT for hit-by-expiry.

      Parameters:
      initialStockValue - The value.
      riskFreeRate - The value.
      dividendYield - The value.
      volatility - The value.
      optionMaturity - The value.
      barrierValue - The value.
      barrierType - The value.
      eventType - The value.
      binaryPayoffType - The value.
      cashPayoff - The value.
      Returns:
      The value.