Class BarrierOptions
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumBarrier-event style for strike-free binary barriers.static enumSettlement timing for the binary barrier payoff.static enumBinary payoff style used by single-barrier binary formulas.static enumDouble-barrier monitoring styles supported by the closed-form routines. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleblackScholesBarrierOptionValue(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.static doubleblackScholesBarrierStatusBinaryValue(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.static doubleblackScholesBinaryBarrierAtHitValue(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.static doubleblackScholesBinaryBarrierOptionValue(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.static doubleblackScholesBinaryBarrierStatusAtExpiryValue(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.static doubleblackScholesDoubleBarrierCashBinaryValue(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.static doubleblackScholesDoubleBarrierOptionValue(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.static doubleblackScholesOneTouchValue(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.static doubleblackScholesSoftBarrierOptionValue(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.
-
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 priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.optionStrike- StrikeK.isCall-truefor a call,falsefor a put.rebate- Cash rebate associated with the barrier event.barrierValue- Barrier levelH.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 priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.optionStrike- StrikeK.isCall-truefor a call,falsefor a put.barrierValue- Barrier levelH.barrierType- Barrier orientation and knock style.binaryPayoffType- Cash-or-nothing or asset-or-nothing payoff.cashPayoff- Cash amount used whenbinaryPayoffTypeis 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 priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.optionStrike- StrikeK.isCall-truefor a call,falsefor a put.lowerBarrier- Lower barrierL.upperBarrier- Upper barrierU.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 priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.cashPayoff- Cash amount paid when the contract condition is satisfied.lowerBarrier- Lower barrierL.upperBarrier- Upper barrierU.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
lowerBarrierandupperBarrier. When the two levels coincide, the method falls back to the standard single-barrier formula.- Parameters:
initialStockValue- Spot priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.optionStrike- StrikeK.isCall-truefor a call,falsefor 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 atS=H.- Parameters:
initialStockValue- Spot priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.barrierValue- Barrier levelH.barrierType- Must beDOWN_INorUP_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 priceS0.riskFreeRate- Continuously compounded risk-free rater.dividendYield- Continuously compounded dividend yieldq.volatility- Black-Scholes volatilitysigma.optionMaturity- Time to maturityT.barrierValue- Barrier levelH.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 whenbinaryPayoffTypeis 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
cashPayoffat 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.
-