// Switch on type
switch (bInOut) {
case KNOCK_OUT: // Long a linear at strike, short a linear at barrier, short a binary at barrier of size (barrier-strike)
final ForexOptionVanillaDefinition longLinearK = new ForexOptionVanillaDefinition(fxFwd, expiry, useCallSpread, isLong);
final ForexOptionVanillaDefinition shortLinearB = new ForexOptionVanillaDefinition(fxFwdForBarrier, expiry, useCallSpread, !isLong);
vanillas.add(longLinearK.toDerivative(valTime, baseQuoteCurveNames));
vanillas.add(shortLinearB.toDerivative(valTime, baseQuoteCurveNames));
// Short a binary of size, barrier - strike. Modelled as call spread struck around strike + oh, with spread of 2*eps
final ForexOptionVanillaDefinition shortNear = new ForexOptionVanillaDefinition(fxFwdForNearStrike, expiry, useCallSpread, !isLong);
final ForexOptionVanillaDefinition longFar = new ForexOptionVanillaDefinition(fxFwdForFarStrike, expiry, useCallSpread, isLong);
vanillas.add(shortNear.toDerivative(valTime, baseQuoteCurveNames));
vanillas.add(longFar.toDerivative(valTime, baseQuoteCurveNames));
break;
case KNOCK_IN: // Long a linear at barrier, long a binary at barrier of size (barrier - strike)
final ForexOptionVanillaDefinition longLinearB = new ForexOptionVanillaDefinition(fxFwdForBarrier, expiry, useCallSpread, isLong);
vanillas.add(longLinearB.toDerivative(valTime, baseQuoteCurveNames));
// Long a binary of size, barrier - strike. Modelled as call spread struck around strike + oh, with spread of 2*eps
final ForexOptionVanillaDefinition longNear = new ForexOptionVanillaDefinition(fxFwdForNearStrike, expiry, useCallSpread, isLong);
final ForexOptionVanillaDefinition shortFar = new ForexOptionVanillaDefinition(fxFwdForFarStrike, expiry, useCallSpread, !isLong);
vanillas.add(longNear.toDerivative(valTime, baseQuoteCurveNames));
vanillas.add(shortFar.toDerivative(valTime, baseQuoteCurveNames));
break;
default:
throw new OpenGammaRuntimeException("Encountered an EquityBarrierOption with unexpected BarrierDirection of: " + bUpDown);
}
return vanillas;