@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final Clock snapshotClock = executionContext.getValuationClock();
final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
final Trade trade = target.getTrade();
final ValueRequirement desiredValue = desiredValues.iterator().next();
final String curveCalculationConfigName = desiredValue.getConstraint(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
final MultiCurveCalculationConfig curveCalculationConfig = _curveConfigSource.getConfig(curveCalculationConfigName);
if (curveCalculationConfig == null) {
throw new OpenGammaRuntimeException("Could not find curve calculation configuration named " + curveCalculationConfigName);
}
final String currency = FinancialSecurityUtils.getCurrency(trade.getSecurity()).getCode();
final String[] curveNames = curveCalculationConfig.getYieldCurveNames();
final String[] yieldCurveNames = curveNames.length == 1 ? new String[] {curveNames[0], curveNames[0] } : curveNames;
final String[] fullYieldCurveNames = new String[yieldCurveNames.length];
for (int i = 0; i < yieldCurveNames.length; i++) {
fullYieldCurveNames[i] = yieldCurveNames[i] + "_" + currency;
}
final YieldCurveBundle data = YieldCurveFunctionUtils.getAllYieldCurves(inputs, curveCalculationConfig, _curveConfigSource);
final InstrumentDefinition<InstrumentDerivative> irFutureDefinition = _converter.convert(trade);
final InstrumentDerivative irFuture = _dataConverter.convert(trade.getSecurity(), irFutureDefinition, now, fullYieldCurveNames, timeSeries);
final ValueSpecification spec = getSpecification(target, curveCalculationConfigName);
return getResults(irFuture, data, spec);
}