_curveName = curveName;
}
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final FutureSecurity security = (FutureSecurity) target.getSecurity();
final Clock snapshotClock = executionContext.getValuationClock();
final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
final Currency currency = security.getCurrency();
final Object curveObject = inputs.getValue(YieldCurveFunction.getCurveRequirement(currency, _curveName, null, null));
if (curveObject == null) {
throw new OpenGammaRuntimeException("Could not get " + _curveName + " curve");
}
final ExternalId underlyingIdentifier = getUnderlyingIdentifier(security);
final Object spotObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, underlyingIdentifier));
if (spotObject == null) {
throw new OpenGammaRuntimeException("Could not get market data for " + underlyingIdentifier);
}
final YieldAndDiscountCurve curve = (YieldAndDiscountCurve) curveObject;
final double spot = (Double) spotObject;
final SimpleFutureDataBundleDeprecated data = new SimpleFutureDataBundleDeprecated(curve, null, spot, 0., 0.);
final SimpleInstrument instrument = security.accept(CONVERTER).toDerivative(now);
final CurrencyAmount pv = instrument.accept(CALCULATOR, data);
final ValueProperties properties = createValueProperties()
.with(ValuePropertyNames.CURVE, _curveName)
.with(ValuePropertyNames.CURRENCY, pv.getCurrency().getCode()).get();
final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.PRESENT_VALUE, target.toSpecification(), properties);