Class DoubleBarrierOption
- All Implemented Interfaces:
FiniteDifferenceEquityEventProduct, FiniteDifferenceEquityProduct, FiniteDifferenceInternalStateConstraint, FiniteDifferenceProduct<FiniteDifferenceEquityModel>, Product
The product is defined by a strike K, lower and upper barriers L < U, maturity T, and a call/put sign. Let S(t) denote the underlying. The alive region is the open band
L < S(t) < U.
For a knock-out contract, the option survives only as long as the path remains inside the band. For a knock-in contract, the option becomes active once the path hits either barrier. Writing
τ = inf { t in [0,T] : S(t) ≤ L or S(t) ≥ U },
the corresponding payoffs are
V(T) = 1_{τ > T} max(ω(S(T)-K),0) for knock-out,
V(T) = 1_{τ ≤ T} max(ω(S(T)-K),0) for knock-in,
where ω = 1 for a call and ω = -1 for a put.
This implementation supports:
- vanilla call / put payoffs,
DoubleBarrierType.KNOCK_OUTandDoubleBarrierType.KNOCK_IN,- European, Bermudan, and American exercise,
- one-dimensional models,
- two-dimensional Heston and SABR models.
The knock-out case is priced directly by imposing an internal-state constraint outside the alive band. The knock-in case is priced directly without parity decomposition:
- outside the alive band, the option is already activated and equals the corresponding vanilla value,
- inside the alive band, a pre-hit PDE is solved on the band (L,U) with time-dependent Dirichlet boundary data taken from the activated vanilla branch at the two barriers,
- for Bermudan and American exercise, the obstacle is applied only in the activated vanilla branch, while the pre-hit branch remains a pure continuation problem up to barrier activation.
In the one-dimensional case this leads to a PDE on the truncated spatial interval (L,U). In the two-dimensional case the same idea is applied while preserving the second state-variable grid and imposing barrier traces that depend on time and on the second state variable.
For discrete monitoring, barrier activation / knock-out is applied only at the supplied monitoring dates via event conditions. In the discretely monitored knock-in case, the activated branch is the true vanilla branch with the product exercise style, while the pre-hit branch is solved as a European continuation problem between monitoring dates.
- Author:
- Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option using a numeric call/put sign.DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option using a numeric call/put sign.DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option with anonymous underlying.DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option with anonymous underlying.DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option with anonymous underlying.DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option with anonymous underlying.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option using a numeric call/put sign.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option using a numeric call/put sign.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option.DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]applyEventCondition(double time, double[] valuesAfterEvent, FiniteDifferenceEquityModel model) Performs the operation.Returns the call/put sign.doublegetConstrainedValue(double time, double... stateVariables) Returns the constrained value in the knocked-out region.Returns the double-barrier type.double[]Returns the value.Returns the exercise specification.doubleReturns the lower barrier.doubleReturns the maturity.double[]Returns the monitoring times.Returns the monitoring type.doubleReturns the strike.Returns the underlying name.doubleReturns the upper barrier.double[]getValue(double evaluationTime, FiniteDifferenceEquityModel model) Returns the values at the specified evaluation time on the model space grid.double[][]Returns the full value surface.booleanisConstraintActive(double time, double... stateVariables) Returns whether the internal knock-out constraint is active.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FiniteDifferenceEquityProduct
getModelClassMethods inherited from interface FiniteDifferenceProduct
getValue
-
Constructor Details
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.exercise- Exercise specification.
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.exercise- Exercise specification.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option with anonymous underlying.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option with anonymous underlying.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType) Creates a European double-barrier option using a numeric call/put sign.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Numeric sign,1.0for call and-1.0for put.doubleBarrierType- Double-barrier type.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, MonitoringType monitoringType, double[] monitoringTimes) Creates a European double-barrier option using a numeric call/put sign.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Numeric sign,1.0for call and-1.0for put.doubleBarrierType- Double-barrier type.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option using a numeric call/put sign.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Numeric sign,1.0for call and-1.0for put.doubleBarrierType- Double-barrier type.exercise- Exercise specification.
-
DoubleBarrierOption
public DoubleBarrierOption(String underlyingName, double maturity, double strike, double lowerBarrier, double upperBarrier, double callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option using a numeric call/put sign.- Parameters:
underlyingName- Name of the underlying. May benull.maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Numeric sign,1.0for call and-1.0for put.doubleBarrierType- Double-barrier type.exercise- Exercise specification.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise) Creates a double-barrier option with anonymous underlying.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.exercise- Exercise specification.
-
DoubleBarrierOption
public DoubleBarrierOption(double maturity, double strike, double lowerBarrier, double upperBarrier, CallOrPut callOrPutSign, DoubleBarrierType doubleBarrierType, Exercise exercise, MonitoringType monitoringType, double[] monitoringTimes) Creates a double-barrier option with anonymous underlying.- Parameters:
maturity- Option maturity.strike- Option strike.lowerBarrier- Lower barrier.upperBarrier- Upper barrier.callOrPutSign- Call/put sign.doubleBarrierType- Double-barrier type.exercise- Exercise specification.monitoringType- Monitoring type.monitoringTimes- Monitoring times for discrete monitoring.
-
-
Method Details
-
getValue
Returns the values at the specified evaluation time on the model space grid.- Specified by:
getValuein interfaceFiniteDifferenceProduct<FiniteDifferenceEquityModel>- Parameters:
evaluationTime- Evaluation time.model- The finite-difference model.- Returns:
- The value vector at the requested evaluation time.
-
getValues
Returns the full value surface.- Specified by:
getValuesin interfaceFiniteDifferenceProduct<FiniteDifferenceEquityModel>- Parameters:
model- The finite-difference model.- Returns:
- The value surface indexed by space point and time index.
-
getEventTimes
public double[] getEventTimes()Description copied from interface:FiniteDifferenceEquityEventProductReturns the value.- Specified by:
getEventTimesin interfaceFiniteDifferenceEquityEventProduct- Returns:
- The value.
-
applyEventCondition
public double[] applyEventCondition(double time, double[] valuesAfterEvent, FiniteDifferenceEquityModel model) Description copied from interface:FiniteDifferenceEquityEventProductPerforms the operation.- Specified by:
applyEventConditionin interfaceFiniteDifferenceEquityEventProduct- Parameters:
time- The value.valuesAfterEvent- The value.model- The value.- Returns:
- The value.
-
isConstraintActive
public boolean isConstraintActive(double time, double... stateVariables) Returns whether the internal knock-out constraint is active.- Specified by:
isConstraintActivein interfaceFiniteDifferenceInternalStateConstraint- Parameters:
time- Evaluation time.stateVariables- State variables.- Returns:
trueif the state is outside the alive band.
-
getConstrainedValue
public double getConstrainedValue(double time, double... stateVariables) Returns the constrained value in the knocked-out region.- Specified by:
getConstrainedValuein interfaceFiniteDifferenceInternalStateConstraint- Parameters:
time- Evaluation time.stateVariables- State variables.- Returns:
- The constrained value.
-
getUnderlyingName
Returns the underlying name.- Returns:
- The underlying name, possibly
null.
-
getMaturity
public double getMaturity()Returns the maturity.- Returns:
- The maturity.
-
getStrike
public double getStrike()Returns the strike.- Returns:
- The strike.
-
getLowerBarrier
public double getLowerBarrier()Returns the lower barrier.- Returns:
- The lower barrier.
-
getUpperBarrier
public double getUpperBarrier()Returns the upper barrier.- Returns:
- The upper barrier.
-
getCallOrPut
-
getDoubleBarrierType
Returns the double-barrier type.- Returns:
- The double-barrier type.
-
getExercise
Returns the exercise specification.- Returns:
- The exercise specification.
-
getMonitoringType
Returns the monitoring type.- Returns:
- The monitoring type.
-
getMonitoringTimes
public double[] getMonitoringTimes()Returns the monitoring times.- Returns:
- The monitoring times, or
nullfor continuous monitoring.
-