CouponIborFxResetDiscountingMethod { public MultipleCurrencyAmount presentValue(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 fxRate = multicurves.getFxRate(ccyReference, ccyPayment); double notional = fxRate * coupon.getNotional(); double value = (forward + coupon.getSpread()) * coupon.getPaymentYearFraction() * notional * dfCcyPaymentAtPayment * dfCcyReferenceAtDelivery / dfCcyPaymentAtDelivery; return MultipleCurrencyAmount.of(ccyPayment, value); } 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 presentValue() { double fxToday = MULTICURVE.getFxRate(CUR_REF, CUR_PAY); double forward = MULTICURVE.getSimplyCompoundForwardRate(EURIBOR3M, CPN.getIborIndexFixingPeriodStartTime(), CPN.getIborIndexFixingPeriodEndTime(), CPN.getIborIndexFixingAccrualFactor()); double amount = fxToday * 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 pvExpected = amount * dfXTp * dfYT0 / dfXT0; MultipleCurrencyAmount pvComputed = METHOD_CPN_IBOR_FX.presentValue(CPN, MULTICURVE); assertTrue("CouponIborFxResetDiscountingMethod: present value", pvComputed.size() == 1); assertEquals("CouponIborFxResetDiscountingMethod: present value", pvExpected, pvComputed.getAmount(CUR_PAY), TOLERANCE_PV); }
@Test public void presentValueCalculatorVsMethod() { MultipleCurrencyAmount pvMethod = METHOD_CPN_IBOR_FX.presentValue(CPN, MULTICURVE); MultipleCurrencyAmount pvCalculator = CPN.accept(PVDC, MULTICURVE); assertEquals("CouponIborFxResetDiscountingMethod: present value", pvMethod.getAmount(CUR_PAY), pvCalculator.getAmount(CUR_PAY), TOLERANCE_PV); }