CouponIborAverageDiscountingMethod { public MultipleCurrencyAmount presentValue(final CouponIborAverage coupon, final MulticurveProviderInterface multicurves) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(multicurves, "Multi-curves provider"); final double forward1 = multicurves.getSimplyCompoundForwardRate(coupon.getIndex1(), coupon.getFixingPeriodStartTime1(), coupon.getFixingPeriodEndTime1(), coupon.getFixingAccrualFactor1()); final double forward2 = multicurves.getSimplyCompoundForwardRate(coupon.getIndex2(), coupon.getFixingPeriodStartTime2(), coupon.getFixingPeriodEndTime2(), coupon.getFixingAccrualFactor2()); final double forward = coupon.getWeight1() * forward1 + coupon.getWeight2() * forward2; final double df = multicurves.getDiscountFactor(coupon.getCurrency(), coupon.getPaymentTime()); final double pv = coupon.getNotional() * coupon.getPaymentYearFraction() * forward * df; return MultipleCurrencyAmount.of(coupon.getCurrency(), pv); } private  CouponIborAverageDiscountingMethod(); static CouponIborAverageDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborAverage coupon, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborAverage coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueMarketDiscount() { final MultipleCurrencyAmount pvComputed = METHOD_CPN_IBOR__AVERAGE.presentValue(CPN_IBOR__AVERAGE, MULTICURVES); final double forward1 = MULTICURVES.getSimplyCompoundForwardRate(CPN_IBOR__AVERAGE.getIndex1(), CPN_IBOR__AVERAGE.getFixingPeriodStartTime1(), CPN_IBOR__AVERAGE.getFixingPeriodEndTime1(), CPN_IBOR__AVERAGE.getFixingAccrualFactor1()); final double forward2 = MULTICURVES.getSimplyCompoundForwardRate(CPN_IBOR__AVERAGE.getIndex2(), CPN_IBOR__AVERAGE.getFixingPeriodStartTime2(), CPN_IBOR__AVERAGE.getFixingPeriodEndTime2(), CPN_IBOR__AVERAGE.getFixingAccrualFactor2()); final double df = MULTICURVES.getDiscountFactor(CPN_IBOR__AVERAGE.getCurrency(), CPN_IBOR_1.getPaymentTime()); final double pvExpected = CPN_IBOR__AVERAGE.getNotional() * CPN_IBOR__AVERAGE.getPaymentYearFraction() * (WEIGHT_1 * forward1 + WEIGHT_2 * forward2) * df; assertEquals("CouponIborDiscountingMarketMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }
@Test public void presentValue() { final MultipleCurrencyAmount pvComputed = METHOD_CPN_IBOR__AVERAGE.presentValue(CPN_IBOR__AVERAGE, MULTICURVES); final MultipleCurrencyAmount pvComputed1 = METHOD_CPN_IBOR.presentValue(CPN_IBOR_1, MULTICURVES); final MultipleCurrencyAmount pvComputed2 = METHOD_CPN_IBOR.presentValue(CPN_IBOR_2, MULTICURVES); final double pvExpected = CPN_IBOR__AVERAGE.getPaymentYearFraction() * (WEIGHT_1 * pvComputed1.getAmount(EUR) / ACCRUAL_FACTOR_1 + WEIGHT_2 * pvComputed2.getAmount(EUR) / ACCRUAL_FACTOR_2); assertEquals("CouponIborDiscountingMarketMethod: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV); }