CouponIborCompoundingFlatSpreadDiscountingMethod { public MultipleCurrencyAmount presentValue(final CouponIborCompoundingFlatSpread coupon, final MulticurveProviderInterface multicurve) { return presentValue(coupon, multicurve, IborForwardRateProvider.getInstance()); } private  CouponIborCompoundingFlatSpreadDiscountingMethod(); static CouponIborCompoundingFlatSpreadDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborCompoundingFlatSpread coupon, final MulticurveProviderInterface multicurve); MultipleCurrencyAmount presentValue(
      final CouponIborCompoundingFlatSpread coupon,
      final MulticurveProviderInterface multicurve,
      final ForwardRateProvider<IborIndex> forwardRateProvider); double presentValueSpreadSensitivity(final CouponIborCompoundingFlatSpread coupon, final MulticurveProviderInterface multicurve); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborCompoundingFlatSpread coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueBeforeFirstFixing() { final MultipleCurrencyAmount pvComputed = METHOD_COMPOUNDED.presentValue(CPN_BEFORE, MULTICURVES); final int nbSub = CPN_BEFORE.getFixingTimes().length; double[] forward = new double[nbSub]; for (int loopsub = 0; loopsub < nbSub; loopsub++) { forward[loopsub] = MULTICURVES.getSimplyCompoundForwardRate(CADCDOR3M, CPN_BEFORE.getFixingPeriodStartTimes()[loopsub], CPN_BEFORE.getFixingPeriodEndTimes()[loopsub], CPN_BEFORE.getFixingPeriodAccrualFactors()[loopsub]); } final double cpa = cpa(CPN_BEFORE.getCompoundingPeriodAmountAccumulated(), forward, CPN_BEFORE.getSubperiodsAccrualFactors(), SPREAD); final double dfPayment = MULTICURVES.getDiscountFactor(CAD, CPN_BEFORE.getPaymentTime()); final double pvExpected = NOTIONAL * cpa * dfPayment; assertEquals("CouponIborCompoundingFlatSpreadDiscountingMethod: 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("CouponIborCompoundingFlatSpreadDiscountingMethod: Present value", pvMethod.getAmount(CAD), pvCalculator.getAmount(CADCDOR3M.getCurrency()), TOLERANCE_PV); }
@Test public void presentValueAfter1Fixing() { final MultipleCurrencyAmount pvComputed = METHOD_COMPOUNDED.presentValue(CPN_1, MULTICURVES); final int nbSub = CPN_1.getFixingTimes().length; double[] forward = new double[nbSub]; for (int loopsub = 0; loopsub < nbSub; loopsub++) { forward[loopsub] = MULTICURVES.getSimplyCompoundForwardRate(CADCDOR3M, CPN_1.getFixingPeriodStartTimes()[loopsub], CPN_1.getFixingPeriodEndTimes()[loopsub], CPN_1.getFixingPeriodAccrualFactors()[loopsub]); } final double cpa = cpa(CPN_1.getCompoundingPeriodAmountAccumulated() / NOTIONAL, forward, CPN_1.getSubperiodsAccrualFactors(), SPREAD); final double dfPayment = MULTICURVES.getDiscountFactor(CAD, CPN_1.getPaymentTime()); final double pvExpected = NOTIONAL * cpa * dfPayment; assertEquals("CouponIborCompoundingFlatSpreadDiscountingMethod: Present value", pvExpected, pvComputed.getAmount(CAD), TOLERANCE_PV); }