ForexDiscountingMethod { public MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveProviderInterface multicurves) { final MultipleCurrencyAmount pv1 = METHOD_PAY.presentValue(fx.getPaymentCurrency1(), multicurves); final MultipleCurrencyAmount pv2 = METHOD_PAY.presentValue(fx.getPaymentCurrency2(), multicurves); return pv1.plus(pv2); } private  ForexDiscountingMethod(); static ForexDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveProviderInterface multicurves); MultipleCurrencyAmount currencyExposure(final Forex fx, final MulticurveProviderInterface multicurves); double parSpread(final Forex fx, final MulticurveProviderInterface multicurves); double forwardForexRate(final Forex fx, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves); MulticurveSensitivity parSpreadCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves);  }
@Test public void presentValue() { final MultipleCurrencyAmount pv = METHOD_FX.presentValue(FX, MULTICURVES); final MultipleCurrencyAmount ca1 = METHOD_PAY.presentValue(PAY_1, MULTICURVES); final MultipleCurrencyAmount ca2 = METHOD_PAY.presentValue(PAY_2, MULTICURVES); assertEquals("ForexDiscountingMethod: presentValue", ca1.plus(ca2), pv); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD_FX.presentValue(FX, MULTICURVES); final MultipleCurrencyAmount pvCalculator = FX.accept(PVDC, MULTICURVES); assertEquals("ForexDiscountingMethod: presentValue: Method vs Calculator", pvMethod, pvCalculator); }
@Test public void presentValueReverse() { final ForexDefinition fxReverseDefinition = new ForexDefinition(CUR_2, CUR_1, PAYMENT_DATE, -NOMINAL_1 * FX_RATE, 1.0 / FX_RATE); final Forex fxReverse = fxReverseDefinition.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount pv = METHOD_FX.presentValue(FX, MULTICURVES); final MultipleCurrencyAmount pvReverse = METHOD_FX.presentValue(fxReverse, MULTICURVES); assertEquals("Forex present value: Reverse description", pv.getAmount(CUR_1), pvReverse.getAmount(CUR_1), TOLERANCE_PV); assertEquals("Forex present value: Reverse description", pv.getAmount(CUR_2), pvReverse.getAmount(CUR_2), TOLERANCE_PV); }