CouponFixedFxResetDiscountingMethod { public MultipleCurrencyAmount currencyExposure(final CouponFixedFxReset coupon, final MulticurveProviderInterface multicurves) { Validate.notNull(coupon, "Coupon"); Validate.notNull(multicurves, "multicurve"); Currency ccyPayment = coupon.getCurrency(); Currency ccyReference = coupon.getReferenceCurrency(); double dfCcyPaymentAtPayment = multicurves.getDiscountFactor(ccyPayment, coupon.getPaymentTime()); double dfCcyReferenceAtDelivery = multicurves.getDiscountFactor(ccyReference, coupon.getFxDeliveryTime()); double dfCcyPaymentAtDelivery = multicurves.getDiscountFactor(ccyPayment, coupon.getFxDeliveryTime()); double pv = coupon.getNotional() * coupon.getPaymentYearFraction() * coupon.getRate() * dfCcyPaymentAtPayment * dfCcyReferenceAtDelivery / dfCcyPaymentAtDelivery; return MultipleCurrencyAmount.of(ccyReference, pv); } private  CouponFixedFxResetDiscountingMethod(); static CouponFixedFxResetDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponFixedFxReset coupon, 
      final MulticurveProviderInterface multicurve); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponFixedFxReset coupon, 
      final MulticurveProviderInterface multicurve); MultipleCurrencyAmount currencyExposure(final CouponFixedFxReset coupon, 
      final MulticurveProviderInterface multicurves);  }
@Test public void currencyExposure() { MultipleCurrencyAmount pvComputed = METHOD_CPN_FIXED_FX.presentValue(CPN, MULTICURVE); MultipleCurrencyAmount ceComputed = METHOD_CPN_FIXED_FX.currencyExposure(CPN, MULTICURVE); assertEquals("CouponFixedFxResetDiscountingMethod: present currencyExposure", MULTICURVE.getFxRates().convert(ceComputed, CUR_PAY).getAmount(), MULTICURVE.getFxRates().convert(pvComputed, CUR_PAY).getAmount(), TOLERANCE_PV); assertTrue("CouponFixedFxResetDiscountingMethod: present currencyExposure", Math.abs(ceComputed.getAmount(CUR_REF)) > TOLERANCE_PV); double amount = NOTIONAL * ACCRUAL_FACTOR * RATE; 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("CouponFixedFxResetDiscountingMethod: present currencyExposure", ceExpected, ceComputed.getAmount(CUR_REF), TOLERANCE_PV); }
@Test public void currencyExposureCalculatorVsMethod() { MultipleCurrencyAmount ceMethod = METHOD_CPN_FIXED_FX.currencyExposure(CPN, MULTICURVE); MultipleCurrencyAmount ceCalculator = CPN.accept(CEDC, MULTICURVE); assertEquals("CouponFixedFxResetDiscountingMethod: present value", ceMethod.getAmount(CUR_REF), ceCalculator.getAmount(CUR_REF), TOLERANCE_PV); }