}
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final ZonedDateTime now = ZonedDateTime.now(executionContext.getValuationClock());
final FXBarrierOptionSecurity barrierSec = (FXBarrierOptionSecurity) target.getSecurity();
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 DEFINITIONS
final Set<ForexOptionVanilla> vanillas = vanillaDecomposition(barrierSec, smoothing, overhedge, now, desiredValues);
// 3. Build up the market data bundle
final ForexOptionDataBundle<?> market = FXOptionFunctionUtils.buildMarketBundle(now, inputs, target, desiredValues);
// TODO Confirm whether we need to support both types of dataBundles: SmileDeltaTermStructureParametersStrikeInterpolation AND BlackForexTermStructureParameters
// 4. Compute Values - in base class
final Object results = computeValues(vanillas, market);
// 5. Properties of what's required of this function
final Object baseQuotePairsObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
if (baseQuotePairsObject == null) {
throw new OpenGammaRuntimeException("Could not get base/quote pair data");
}
final Currency putCurrency = barrierSec.getPutCurrency();
final Currency callCurrency = barrierSec.getCallCurrency();
final CurrencyPairs baseQuotePairs = (CurrencyPairs) baseQuotePairsObject;
final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
if (baseQuotePair == null) {
throw new OpenGammaRuntimeException("Could not get base/quote pair for currency pair (" + putCurrency + ", " + callCurrency + ")");
}