CouponInflationYearOnYearMonthlyWithMarginDiscountingMethod { public MultipleCurrencyAmount presentValue(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(inflation, "Inflation"); final double discountFactor = inflation.getDiscountFactor(coupon.getCurrency(), coupon.getPaymentTime()); return netAmount(coupon, inflation).multipliedBy(discountFactor); }  MultipleCurrencyAmount netAmount(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation); MultipleCurrencyAmount presentValue(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation); double indexEstimationStart(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation); double indexEstimationEnd(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation); MultipleCurrencyInflationSensitivity presentValueCurveSensitivity(final CouponInflationYearOnYearMonthlyWithMargin coupon, final InflationProviderInterface inflation);  }
@Test public void presentValueNoNotional() { final MultipleCurrencyAmount pv = METHOD.presentValue(YEAR_ON_YEAR_NO, MARKET.getInflationProvider()); final double df = MARKET.getCurve(YEAR_ON_YEAR_NO.getCurrency()).getDiscountFactor(YEAR_ON_YEAR_NO.getPaymentTime()); final double finalIndex = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceEndTime()); final double initialIndex = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceStartTime()); final double pvExpected = (finalIndex / initialIndex - 1 + MARGIN) * df * NOTIONAL; assertEquals("Year on year coupon inflation DiscountingMethod: Present value", pvExpected, pv.getAmount(YEAR_ON_YEAR_NO.getCurrency()), TOLERANCE_PV); }
@Test public void presentValueMethodVsCalculator() { final MultipleCurrencyAmount pvMethod = METHOD.presentValue(YEAR_ON_YEAR_NO, MARKET.getInflationProvider()); final MultipleCurrencyAmount pvCalculator = YEAR_ON_YEAR_NO.accept(PVIC, MARKET.getInflationProvider()); assertEquals("Year on year coupon inflation DiscountingMethod: Present value", pvMethod, pvCalculator); }
@Test public void presentValueWithNotional() { final MultipleCurrencyAmount pv = METHOD.presentValue(YEAR_ON_YEAR_WITH, MARKET.getInflationProvider()); final double df = MARKET.getCurve(YEAR_ON_YEAR_WITH.getCurrency()).getDiscountFactor(YEAR_ON_YEAR_WITH.getPaymentTime()); final double finalIndex = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_WITH.getReferenceEndTime()); final double initialIndex = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_WITH.getReferenceStartTime()); final double pvExpected = (finalIndex / initialIndex + MARGIN) * df * NOTIONAL; assertEquals("Year on year coupon inflation DiscountingMethod: Present value", pvExpected, pv.getAmount(YEAR_ON_YEAR_WITH.getCurrency()), TOLERANCE_PV); }