//------------------------------------------------------------------------- public virtual void test_forecastValue() { SimpleRatesProvider prov = createProvider(FX_RESET_NOTIONAL_EXCHANGE_REC_USD); DiscountingFxResetNotionalExchangePricer test = new DiscountingFxResetNotionalExchangePricer(); double calculated = test.forecastValue(FX_RESET_NOTIONAL_EXCHANGE_REC_USD, prov); assertEquals(calculated, FX_RESET_NOTIONAL_EXCHANGE_REC_USD.Notional * FX_RATE, 0d); }
//------------------------------------------------------------------------- public virtual void test_forecastValueSensitivity() { ImmutableRatesProvider prov = ImmutableRatesProvider.builder(VAL_DATE).fxRateProvider(FX_MATRIX).discountCurve(GBP, DISCOUNT_CURVE_GBP).discountCurve(USD, DISCOUNT_CURVE_USD).build(); FxResetNotionalExchange[] expanded = new FxResetNotionalExchange[] { FX_RESET_NOTIONAL_EXCHANGE_REC_USD, FX_RESET_NOTIONAL_EXCHANGE_PAY_GBP }; for (int i = 0; i < 2; ++i) { FxResetNotionalExchange fxReset = expanded[i]; DiscountingFxResetNotionalExchangePricer test = new DiscountingFxResetNotionalExchangePricer(); PointSensitivityBuilder pointSensitivityComputed = test.forecastValueSensitivity(expanded[i], prov); CurrencyParameterSensitivities parameterSensitivityComputed = prov.parameterSensitivity(pointSensitivityComputed.build()); CurrencyParameterSensitivities parameterSensitivityExpected = FD_CALCULATOR.sensitivity(prov, (p) => CurrencyAmount.of(fxReset.Currency, test.forecastValue(fxReset, (p)))); assertTrue(parameterSensitivityComputed.equalWithTolerance(parameterSensitivityExpected, Math.Abs(expanded[i].Notional) * EPS_FD * 10.0)); } }