@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues)
throws AsynchronousExecution {
final ZonedDateTime now = ZonedDateTime.now(executionContext.getValuationClock());
final EquityBarrierOptionSecurity barrierSec = (EquityBarrierOptionSecurity) target.getSecurity();
final ExternalId underlyingId = barrierSec.getUnderlyingId();
final ValueRequirement desiredValue = desiredValues.iterator().next();
// 1. Get parameters for the smoothing of binary payoffs into put spreads
final String strOH = desiredValue.getConstraint(ValuePropertyNames.BINARY_OVERHEDGE);
if (strOH == null) {
throw new OpenGammaRuntimeException("Could not find: " + ValuePropertyNames.BINARY_OVERHEDGE);
}
final Double overhedge = Double.parseDouble(strOH);
final String strSmooth = desiredValue.getConstraint(ValuePropertyNames.BINARY_SMOOTHING_FULLWIDTH);
if (strSmooth == null) {
throw new OpenGammaRuntimeException("Could not find: " + ValuePropertyNames.BINARY_SMOOTHING_FULLWIDTH);
}
final Double smoothing = Double.parseDouble(strSmooth);
// 2. Break the barrier security into it's vanilla analytic derivatives
final Set<EquityIndexOption> vanillas = vanillaDecomposition(now, barrierSec, smoothing, overhedge);
if (vanillas.iterator().next().getTimeToSettlement() < 0.0) {
throw new OpenGammaRuntimeException("EquityBarrierOptionSecurity with expiry, " + barrierSec.getExpiry().getExpiry().toString() + ", has already settled.");
}
// 3. Build up the market data bundle
final StaticReplicationDataBundle market = buildMarketBundle(underlyingId, executionContext, inputs, target, desiredValues);
// 4. Properties of what's required of this function