CouponIborAverageFixingDatesDiscountingMethod { public MultipleCurrencyAmount presentValue(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurves) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(multicurves, "Multi-curves provider"); final int nDates = coupon.getFixingPeriodEndTime().length; double forward = 0.; for (int i = 0; i < nDates; ++i) { final double forward1 = multicurves.getSimplyCompoundForwardRate(coupon.getIndex(), coupon.getFixingPeriodStartTime()[i], coupon.getFixingPeriodEndTime()[i], coupon.getFixingPeriodAccrualFactor()[i]); forward += coupon.getWeight()[i] * forward1; } forward += coupon.getAmountAccrued(); 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  CouponIborAverageFixingDatesDiscountingMethod(); static CouponIborAverageFixingDatesDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueTest() { final MultipleCurrencyAmount pvComputed = METHOD.presentValue(DER1, MULTICURVES); double forward = AMOUNT_ACC; for (int i = 0; i < NUM_OBS; ++i) { forward += WEIGHTS[i] * MULTICURVES.getSimplyCompoundForwardRate(INDEX, FIXING_PERIOD_START_TIMES[i], FIXING_PERIOD_END_TIMES[i], FIX_ACC_FACTORS[i]); } final double pvExpected = DER1.getNotional() * MULTICURVES.getDiscountFactor(DER1.getCurrency(), DER1.getPaymentTime()) * DER1.getPaymentYearFraction() * forward; assertEquals(pvExpected, pvComputed.getAmount(DER1.getCurrency()), EPS * pvExpected); final MultipleCurrencyAmount pvWithCalc = PVDC.visitCouponIborAverageFixingDates(DER1, MULTICURVES); assertEquals(pvWithCalc.getAmount(DER1.getCurrency()), pvComputed.getAmount(DER1.getCurrency()), EPS * pvExpected); }
@Test public void presentValueNoFixTest() { final MultipleCurrencyAmount pvComputed = METHOD.presentValue(DER2, MULTICURVES); double forward = 0.0; for (int i = 0; i < NUM_OBS; ++i) { forward += WEIGHTS[i] * MULTICURVES.getSimplyCompoundForwardRate(INDEX, FIXING_PERIOD_START_TIMES[i], FIXING_PERIOD_END_TIMES[i], FIX_ACC_FACTORS[i]); } final double pvExpected = DER2.getNotional() * MULTICURVES.getDiscountFactor(DER2.getCurrency(), DER2.getPaymentTime()) * DER2.getPaymentYearFraction() * forward; assertEquals(pvExpected, pvComputed.getAmount(DER2.getCurrency()), EPS * pvExpected); final MultipleCurrencyAmount pvWithCalc = PVDC.visitCouponIborAverageFixingDates(DER2, MULTICURVES); assertEquals(pvWithCalc.getAmount(DER2.getCurrency()), pvComputed.getAmount(DER2.getCurrency()), EPS * pvExpected); }