ForexForwardPointsMethod { public MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates, final Pair<Currency, Currency> ccyPair) { final double payTime = fx.getPaymentTime(); final double fwdRate = forwardRates.getYValue(payTime); final Currency ccy2; final double amount1; final double amount2; if (checkCurrency(fx, ccyPair)) { ccy2 = fx.getCurrency2(); amount1 = fx.getPaymentCurrency1().getAmount(); amount2 = fx.getPaymentCurrency2().getAmount(); } else { ccy2 = fx.getCurrency1(); amount1 = fx.getPaymentCurrency2().getAmount(); amount2 = fx.getPaymentCurrency1().getAmount(); } final double df2 = multicurves.getDiscountFactor(ccy2, payTime); final double pv = df2 * (amount2 + amount1 * fwdRate); return MultipleCurrencyAmount.of(ccy2, pv); } private  ForexForwardPointsMethod(); static ForexForwardPointsMethod getInstance(); MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates, final Pair<Currency, Currency> ccyPair); MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveForwardPointsProviderInterface multicurvesForward); MultipleCurrencyAmount currencyExposure(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates, final Pair<Currency, Currency> ccyPair); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates,
      final Pair<Currency, Currency> ccyPair); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Forex fx, final MulticurveForwardPointsProviderInterface multicurvesForward); double[] presentValueForwardPointsSensitivity(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates, final Pair<Currency, Currency> ccyPair);  }
@Test public void presentValueDirectOrder() { final double payTime = FX.getPaymentTime(); final double fwdRate = FWD_RATES.getYValue(payTime); final double amount1 = NOMINAL_1; final double amount2 = -NOMINAL_1 * FX_RATE; final double df2 = MULTICURVES.getDiscountFactor(CUR_2, payTime); final double pvExpected = df2 * (amount2 + amount1 * fwdRate); final MultipleCurrencyAmount pvComputed = METHOD_FX_PTS.presentValue(FX, MULTICURVES, FWD_RATES, PAIR); assertEquals("ForexForwardPointsMethod: presentValue", 1, pvComputed.size()); assertEquals("ForexForwardPointsMethod: presentValue", pvExpected, pvComputed.getAmount(CUR_2), TOLERANCE_PV); final MultipleCurrencyAmount pvComputed2 = METHOD_FX_PTS.presentValue(FX, MULTICURVES_FWD); assertEquals("ForexForwardPointsMethod: presentValue", pvComputed.getAmount(CUR_2), pvComputed2.getAmount(CUR_2), TOLERANCE_PV); }
@Test public void presentValueOppositeOrder() { final MultipleCurrencyAmount pvComputedIndirect = METHOD_FX_PTS.presentValue(FX_INDIRECT, MULTICURVES, FWD_RATES, PAIR); final MultipleCurrencyAmount pvComputedDirect = METHOD_FX_PTS.presentValue(FX, MULTICURVES, FWD_RATES, PAIR); assertEquals("ForexForwardPointsMethod: presentValue", 1, pvComputedIndirect.size()); assertEquals("ForexForwardPointsMethod: presentValue", pvComputedIndirect.getAmount(CUR_2), pvComputedDirect.getAmount(CUR_2), TOLERANCE_PV); final MultipleCurrencyAmount pvComputed2 = METHOD_FX_PTS.presentValue(FX_INDIRECT, MULTICURVES_FWD); assertEquals("ForexForwardPointsMethod: presentValue", pvComputedIndirect.getAmount(CUR_2), pvComputed2.getAmount(CUR_2), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD_FX_PTS.presentValue(FX, MULTICURVES, FWD_RATES, PAIR); final MultipleCurrencyAmount pvCalculator = FX.accept(PVFFPC, MULTICURVES_FWD); assertEquals("ForexForwardPointsMethod: presentValue", pvMethod.getAmount(CUR_2), pvCalculator.getAmount(CUR_2), TOLERANCE_PV); }