CouponIborCompoundingDiscountingMethod { public MultipleCurrencyAmount presentValue(final CouponIborCompounding coupon, final MulticurveProviderInterface multicurve) { return presentValue(coupon, multicurve, IborForwardRateProvider.getInstance()); } private  CouponIborCompoundingDiscountingMethod(); static CouponIborCompoundingDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborCompounding coupon, final MulticurveProviderInterface multicurve); MultipleCurrencyAmount presentValue(
      final CouponIborCompounding coupon,
      final MulticurveProviderInterface multicurve,
      final ForwardRateProvider<IborIndex> forwardRateProvider); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborCompounding coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueBeforeFirstFixing() { final MultipleCurrencyAmount pvComputed = METHOD_COMPOUNDED.presentValue(CPN_BEFORE, MULTICURVES); double notionalAccrued = CPN_BEFORE.getNotional(); final int nbSub = CPN_BEFORE.getFixingTimes().length; for (int loopsub = 0; loopsub < nbSub; loopsub++) { notionalAccrued *= (1.0 + CPN_BEFORE.getPaymentAccrualFactors()[loopsub] * MULTICURVES.getSimplyCompoundForwardRate(CPN_BEFORE.getIndex(), CPN_BEFORE.getFixingPeriodStartTimes()[loopsub], CPN_BEFORE.getFixingPeriodEndTimes()[loopsub], CPN_BEFORE.getFixingPeriodAccrualFactors()[loopsub])); } final double dfPayment = MULTICURVES.getDiscountFactor(CAD, CPN_BEFORE.getPaymentTime()); final double pvExpected = (notionalAccrued - NOTIONAL) * dfPayment; assertEquals("CouponIborCompoundedDiscounting: Present value", pvExpected, pvComputed.getAmount(CAD), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD_COMPOUNDED.presentValue(CPN_BEFORE, MULTICURVES); final MultipleCurrencyAmount pvCalculator = CPN_BEFORE.accept(PVDC, MULTICURVES); assertEquals("CouponIborCompoundedDiscounting: Present value", pvMethod.getAmount(CAD), pvCalculator.getAmount(CADCDOR3M.getCurrency()), TOLERANCE_PV); }
@Test public void presentValueAfter1Fixing() { final MultipleCurrencyAmount pvComputed = METHOD_COMPOUNDED.presentValue(CPN_1, MULTICURVES); double accruedNotional = (1.0 + CPN_DEFINITION.getPaymentAccrualFactors()[0] * FIXING_RATES[1]) * NOTIONAL; accruedNotional *= (1.0 + CPN_1.getPaymentAccrualFactors()[0] * MULTICURVES.getSimplyCompoundForwardRate(CPN_1.getIndex(), CPN_1.getFixingPeriodStartTimes()[0], CPN_1.getFixingPeriodEndTimes()[0], CPN_1.getFixingPeriodAccrualFactors()[0])); final double dfPayment = MULTICURVES.getDiscountFactor(CAD, CPN_1.getPaymentTime()); final double pvExpected = (accruedNotional - NOTIONAL) * dfPayment; assertEquals("CouponIborCompoundedDiscounting: Present value", pvExpected, pvComputed.getAmount(CAD), TOLERANCE_PV); }