if (quoteType != FXForwardCurveSpecification.QuoteType.Points) {
s_logger.error("Cannot handle quote type " + quoteType);
return null;
}
final Set<ValueRequirement> requirements = new HashSet<>();
final FXForwardCurveInstrumentProvider provider = specification.getCurveInstrumentProvider();
for (final Tenor tenor : definition.getTenors()) {
final ExternalId identifier = provider.getInstrument(atZDT.toLocalDate(), tenor);
requirements.add(new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, identifier));
}
return requirements;
}
@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 ValueRequirement desiredValue = desiredValues.iterator().next();
final String curveName = desiredValue.getConstraint(ValuePropertyNames.CURVE);
final UnorderedCurrencyPair currencyPair = UnorderedCurrencyPair.of(target.getUniqueId());
final FXForwardCurveDefinition definition = curveDefinitionSource.getDefinition(curveName, currencyPair.toString());
if (definition == null) {
throw new OpenGammaRuntimeException("Couldn't find FX forward curve definition called " + curveName + " for target " + target);
}
final FXForwardCurveSpecification specification = curveSpecificationSource.getSpecification(curveName, currencyPair.toString());
if (specification == null) {
throw new OpenGammaRuntimeException("Couldn't find FX forward curve specification called " + curveName + " for target " + target);
}
final FXForwardCurveInstrumentProvider provider = specification.getCurveInstrumentProvider();
final Map<ExternalId, Double> data = new HashMap<>();
final boolean isRegular = specification.isMarketQuoteConvention();
for (final Tenor tenor : definition.getTenors()) {
final ExternalId identifier = provider.getInstrument(now.toLocalDate(), tenor);
final ValueRequirement requirement = new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, identifier);
if (inputs.getValue(requirement) != null) {
final Double value = (Double) inputs.getValue(requirement);
data.put(identifier, isRegular ? value : 1 / value);
}
}