@Test
/**
* Tests present value volatility node sensitivity.
*/
public void volatilityNodeSensitivity() {
final PresentValueForexBlackVolatilityNodeSensitivityDataBundle sensi = METHOD_OPTION
.presentValueBlackVolatilityNodeSensitivity(FOREX_CALL_OPTION, SMILE_MULTICURVES);
assertEquals("Forex vanilla option: vega node size", NB_EXP + 1, sensi.getVega().getData().length);
assertEquals("Forex vanilla option: vega node size", NB_STRIKE, sensi.getVega().getData()[0].length);
final Pair<Currency, Currency> currencyPair = ObjectsPair.of(EUR, USD);
assertEquals("Forex vanilla option: vega", currencyPair, sensi.getCurrencyPair());
final PresentValueForexBlackVolatilitySensitivity pointSensitivity = METHOD_OPTION.presentValueBlackVolatilitySensitivity(FOREX_CALL_OPTION, SMILE_MULTICURVES);
final double df = MULTICURVES.getDiscountFactor(USD, TimeCalculator.getTimeBetween(REFERENCE_DATE, OPTION_PAY_DATE));
final double forward = SPOT * MULTICURVES.getDiscountFactor(EUR, TimeCalculator.getTimeBetween(REFERENCE_DATE, OPTION_PAY_DATE)) / df;
final VolatilityAndBucketedSensitivities volAndSensitivities = SMILE_TERM.getVolatilityAndSensitivities(FOREX_CALL_OPTION.getTimeToExpiry(), STRIKE, forward);
final double[][] nodeWeight = volAndSensitivities.getBucketedSensitivities();
final DoublesPair point = DoublesPair.of(FOREX_CALL_OPTION.getTimeToExpiry(), STRIKE);
for (int loopexp = 0; loopexp < NB_EXP; loopexp++) {
for (int loopstrike = 0; loopstrike < NB_STRIKE; loopstrike++) {
assertEquals("Forex vanilla option: vega node", nodeWeight[loopexp][loopstrike] * pointSensitivity.getVega().getMap().get(point),
sensi.getVega().getData()[loopexp][loopstrike]);
}
}
}