return requirements;
}
@Override
public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target, final Map<ValueSpecification, ValueRequirement> inputs) {
final Builder builder = createValueProperties();
final FXForwardSecurity security = (FXForwardSecurity) target.getPosition().getSecurity();
final CurrencyPair currencyPair = _currencyPairs.getCurrencyPair(security.getPayCurrency(), security.getReceiveCurrency());
if (currencyPair == null) {
return null;
}
final Currency currencyBase = currencyPair.getBase();
String resultCurrency = null;
for (final Map.Entry<ValueSpecification, ValueRequirement> entry : inputs.entrySet()) {
final ValueSpecification inputSpec = entry.getKey();
final ValueRequirement inputReq = entry.getValue();
if (inputReq.getValueName().equals(YIELD_CURVE_RETURN_SERIES) || inputReq.getValueName().equals(FX_FORWARD_CURVE_RETURN_SERIES)) {
final Set<String> resultCurrencies = inputReq.getConstraints().getValues(RESULT_CURRENCY);
if (resultCurrencies != null && resultCurrencies.size() == 1) {
resultCurrency = inputReq.getConstraint(RESULT_CURRENCY);
} else {
// should never reach here, but just in case
resultCurrency = currencyBase.getCode();
}
}
for (final String propertyName : inputSpec.getProperties().getProperties()) {
if (ValuePropertyNames.FUNCTION.equals(propertyName)) {
continue;
}
final Set<String> values = inputSpec.getProperties().getValues(propertyName);
if (values == null || values.isEmpty()) {
builder.withAny(propertyName);
} else {
builder.with(propertyName, values);
}
}
}
if (resultCurrency == null) {
return null;
}
builder.with(ValuePropertyNames.CURRENCY, resultCurrency)
.with(ValuePropertyNames.PROPERTY_PNL_CONTRIBUTIONS, ValueRequirementNames.YIELD_CURVE_NODE_SENSITIVITIES);
final ValueProperties properties = builder.get();
final ComputationTargetSpecification targetSpec = target.toSpecification();
return ImmutableSet.of(new ValueSpecification(ValueRequirementNames.YIELD_CURVE_PNL_SERIES, targetSpec, properties));
}