ForexForwardPointsMethod { public MultipleCurrencyAmount currencyExposure(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 ccy1; final Currency ccy2; final double amount1; final double amount2; if (checkCurrency(fx, ccyPair)) { ccy1 = fx.getCurrency1(); ccy2 = fx.getCurrency2(); amount1 = fx.getPaymentCurrency1().getAmount(); amount2 = fx.getPaymentCurrency2().getAmount(); } else { ccy1 = fx.getCurrency2(); ccy2 = fx.getCurrency1(); amount1 = fx.getPaymentCurrency2().getAmount(); amount2 = fx.getPaymentCurrency1().getAmount(); } final double df2 = multicurves.getDiscountFactor(ccy2, payTime); final double ce2 = amount2 * df2; final double todayRate = multicurves.getFxRate(ccy1, ccy2); final double ce1 = amount1 * df2 * (fwdRate / todayRate); MultipleCurrencyAmount ce = MultipleCurrencyAmount.of(ccy1, ce1); ce = ce.plus(ccy2, ce2); return ce; } 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 currencyExposure() { final double fxRate = MULTICURVES.getFxRate(CUR_1, CUR_2); 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 ce1 = amount1 * df2 * (fwdRate / fxRate); final double ce2 = amount2 * df2; MultipleCurrencyAmount ceExpected = MultipleCurrencyAmount.of(CUR_1, ce1); ceExpected = ceExpected.plus(CUR_2, ce2); final MultipleCurrencyAmount ceComputed = METHOD_FX_PTS.currencyExposure(FX, MULTICURVES, FWD_RATES, PAIR); assertEquals("ForexForwardPointsMethod: currencyExposure", 2, ceComputed.size()); assertEquals("ForexForwardPointsMethod: currencyExposure", ceExpected.getAmount(CUR_1), ceComputed.getAmount(CUR_1), TOLERANCE_PV); assertEquals("ForexForwardPointsMethod: currencyExposure", ceExpected.getAmount(CUR_2), ceComputed.getAmount(CUR_2), TOLERANCE_PV); final MultipleCurrencyAmount pvComputed = METHOD_FX_PTS.presentValue(FX, MULTICURVES, FWD_RATES, PAIR); assertEquals("ForexForwardPointsMethod: currencyExposure", MULTICURVES.getFxRates().convert(ceComputed, CUR_2).getAmount(), pvComputed.getAmount(CUR_2), TOLERANCE_PV); }