viewDefinition.setMinFullCalculationPeriod(500L);
final ViewCalculationConfiguration defaultCalculationConfig = new ViewCalculationConfiguration(viewDefinition, DEFAULT_CALC_CONFIG);
final Set<Currency> ccysAdded = new HashSet<>();
for (final UnorderedCurrencyPair pair : ExampleVanillaFxOptionPortfolioLoader.CCYS) {
final ComputationTargetSpecification target = ComputationTargetSpecification.of(pair.getUniqueId());
final ValueProperties properties = ValueProperties.builder()
.with(SURFACE, "DEFAULT")
.with(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE, InstrumentTypeProperties.FOREX)
.get();
defaultCalculationConfig.addSpecificRequirement(new ValueRequirement(VOLATILITY_SURFACE_DATA, target, properties));
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, VEGA_QUOTE_MATRIX, properties);
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, VEGA_MATRIX, properties);
if (!ccysAdded.contains(pair.getFirstCurrency())) {
final String ccy = pair.getFirstCurrency().getCode();
final String discountingCurve = CURVES_FOR_CURRENCY.get(pair.getFirstCurrency()).getFirst();
final ValueProperties curveProperties = ValueProperties.builder()
.with(CURVE, discountingCurve)
.with(CURVE_CURRENCY, ccy)
.get();
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, YIELD_CURVE_NODE_SENSITIVITIES, curveProperties);
ccysAdded.add(pair.getFirstCurrency());
}
if (!ccysAdded.contains(pair.getSecondCurrency())) {
final String ccy = pair.getSecondCurrency().getCode();
final String discountingCurve = CURVES_FOR_CURRENCY.get(pair.getSecondCurrency()).getFirst();
final ValueProperties curveProperties = ValueProperties.builder()
.with(CURVE, discountingCurve)
.with(CURVE_CURRENCY, ccy)
.get();
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, YIELD_CURVE_NODE_SENSITIVITIES, curveProperties);
ccysAdded.add(pair.getSecondCurrency());
}
}
final ValueProperties currencyProperty = ValueProperties.builder()
.with(ValuePropertyNames.CURRENCY, "USD")
.get();
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, PRESENT_VALUE, currencyProperty);
defaultCalculationConfig.addPortfolioRequirement(FXOptionSecurity.SECURITY_TYPE, FX_CURRENCY_EXPOSURE, ValueProperties.builder().get());
viewDefinition.addViewCalculationConfiguration(defaultCalculationConfig);