viewDefinition.setDefaultCurrency(Currency.USD);
viewDefinition.setMaxDeltaCalculationPeriod(500L);
viewDefinition.setMaxFullCalculationPeriod(500L);
viewDefinition.setMinDeltaCalculationPeriod(500L);
viewDefinition.setMinFullCalculationPeriod(500L);
final ViewCalculationConfiguration defaultCalConfig = new ViewCalculationConfiguration(viewDefinition, DEFAULT_CALC_CONFIG);
defaultCalConfig.addPortfolioRequirementName(SwapSecurity.SECURITY_TYPE, PAR_RATE);
// The name "Default" has no special meaning, but means that the currency conversion function can never be used and so we get the instrument's natural currency
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, PRESENT_VALUE,
ValueProperties.with(CurrencyConversionFunction.ORIGINAL_CURRENCY, "Default").withOptional(CurrencyConversionFunction.ORIGINAL_CURRENCY).get());
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, PRESENT_VALUE,
ValueProperties.with(CURRENCY, "USD").get());
for (final Map.Entry<Currency, String> entry : CONFIGS_FOR_CURRENCY.entrySet()) {
final String ccyName = entry.getKey().getCode();
final ComputationTargetSpecification ccyTarget = ComputationTargetSpecification.of(entry.getKey());
final Pair<String, String> curveNames = CURVES_FOR_CURRENCY.get(entry.getKey());
final String discountingCurve = curveNames.getFirst();
final String forwardCurve = curveNames.getSecond();
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, PV01,
ValueProperties.with(CURVE, discountingCurve).with(CURVE_CURRENCY, ccyName)
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get());
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, YIELD_CURVE_NODE_SENSITIVITIES,
ValueProperties.with(CURVE, discountingCurve).with(CURVE_CURRENCY, ccyName)
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get());
defaultCalConfig.addSpecificRequirement(new ValueRequirement(YIELD_CURVE, ccyTarget,
ValueProperties.with(CURVE, discountingCurve).with(CURVE_CALCULATION_CONFIG, entry.getValue())
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get()));
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, YIELD_CURVE_NODE_SENSITIVITIES,
ValueProperties.with(CURVE, forwardCurve).with(CURVE_CURRENCY, ccyName)
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get());
defaultCalConfig.addPortfolioRequirement(SwapSecurity.SECURITY_TYPE, PV01,
ValueProperties.with(CURVE, forwardCurve).with(CURVE_CURRENCY, ccyName)
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get());
defaultCalConfig.addSpecificRequirement(new ValueRequirement(YIELD_CURVE, ccyTarget,
ValueProperties.with(CURVE, forwardCurve).with(CURVE_CALCULATION_CONFIG, entry.getValue())
.with(ValuePropertyNames.AGGREGATION, MISSING_INPUTS).withOptional(ValuePropertyNames.AGGREGATION).get()));
}
viewDefinition.addViewCalculationConfiguration(defaultCalConfig);
return viewDefinition;