CouponIborFxResetDiscountingMethod { public MultipleCurrencyAmount currencyExposure(final CouponIborFxReset coupon, final MulticurveProviderInterface multicurves) { ArgumentChecker.notNull(coupon, "coupon"); ArgumentChecker.notNull(multicurves, "multicurves"); double forward = multicurves.getSimplyCompoundForwardRate(coupon.getIndex(), coupon.getIborIndexFixingPeriodStartTime(), coupon.getIborIndexFixingPeriodEndTime(), coupon.getIborIndexFixingAccrualFactor()); double tp = coupon.getPaymentTime(); double t0 = coupon.getFxDeliveryTime(); Currency ccyPayment = coupon.getCurrency(); Currency ccyReference = coupon.getReferenceCurrency(); double dfCcyPaymentAtPayment = multicurves.getDiscountFactor(ccyPayment, tp); double dfCcyReferenceAtDelivery = multicurves.getDiscountFactor(ccyReference, t0); double dfCcyPaymentAtDelivery = multicurves.getDiscountFactor(ccyPayment, t0); double notionalRef = coupon.getNotional(); double pvRef = (forward + coupon.getSpread()) * coupon.getPaymentYearFraction() * notionalRef * dfCcyPaymentAtPayment * dfCcyReferenceAtDelivery / dfCcyPaymentAtDelivery; return MultipleCurrencyAmount.of(ccyReference, pvRef); } private  CouponIborFxResetDiscountingMethod(); static CouponIborFxResetDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborFxReset coupon,
      final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborFxReset coupon,
      final MulticurveProviderInterface multicurves); MultipleCurrencyAmount currencyExposure(final CouponIborFxReset coupon,
      final MulticurveProviderInterface multicurves);  }
@Test public void currencyExposure() { MultipleCurrencyAmount pvComputed = METHOD_CPN_IBOR_FX.presentValue(CPN, MULTICURVE); MultipleCurrencyAmount ceComputed = METHOD_CPN_IBOR_FX.currencyExposure(CPN, MULTICURVE); assertEquals("CouponIborFxResetDiscountingMethod: present currencyExposure", MULTICURVE.getFxRates().convert(ceComputed, CUR_PAY).getAmount(), MULTICURVE.getFxRates().convert(pvComputed, CUR_PAY).getAmount(), TOLERANCE_PV); assertTrue("CouponIborFxResetDiscountingMethod: present currencyExposure", Math.abs(ceComputed.getAmount(CUR_REF)) > TOLERANCE_PV); double forward = MULTICURVE.getSimplyCompoundForwardRate(EURIBOR3M, CPN.getIborIndexFixingPeriodStartTime(), CPN.getIborIndexFixingPeriodEndTime(), CPN.getIborIndexFixingAccrualFactor()); double amount = CPN.getNotional() * (forward + SPREAD) * CPN.getPaymentYearFraction(); double dfXTp = MULTICURVE.getDiscountFactor(CUR_PAY, CPN.getPaymentTime()); double dfYT0 = MULTICURVE.getDiscountFactor(CUR_REF, CPN.getFxDeliveryTime()); double dfXT0 = MULTICURVE.getDiscountFactor(CUR_PAY, CPN.getFxDeliveryTime()); double ceExpected = amount * dfXTp * dfYT0 / dfXT0; assertEquals("CouponIborFxResetDiscountingMethod: present currencyExposure", ceExpected, ceComputed.getAmount(CUR_REF), TOLERANCE_PV); }
@Test public void currencyExposureCalculatorVsMethod() { MultipleCurrencyAmount ceMethod = METHOD_CPN_IBOR_FX.currencyExposure(CPN, MULTICURVE); MultipleCurrencyAmount ceCalculator = CPN.accept(CEDC, MULTICURVE); assertEquals("CouponIborFxResetDiscountingMethod: present value", ceMethod.getAmount(CUR_REF), ceCalculator.getAmount(CUR_REF), TOLERANCE_PV); }