CouponInflationYearOnYearInterpolationWithMarginDiscountingMethod { public MultipleCurrencyAmount netAmount(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(inflation, "Inflation"); final double estimatedIndexStart = indexEstimationStart(coupon, inflation); final double estimatedIndexEnd = indexEstimationEnd(coupon, inflation); final double na = (estimatedIndexEnd / estimatedIndexStart - (coupon.payNotional() ? 0.0 : 1.0) + coupon.getFactor()) * coupon.getNotional(); return MultipleCurrencyAmount.of(coupon.getCurrency(), na); }  MultipleCurrencyAmount netAmount(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation); MultipleCurrencyAmount presentValue(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation); double indexEstimationStart(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation); double indexEstimationEnd(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation); MultipleCurrencyInflationSensitivity presentValueCurveSensitivity(final CouponInflationYearOnYearInterpolationWithMargin coupon, final InflationProviderInterface inflation);  }
@Test public void netAmount() { final MultipleCurrencyAmount na = METHOD.netAmount(YEAR_ON_YEAR_NO, MARKET.getInflationProvider()); final double finalIndexMonth0 = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceEndTime()[0]); final double finalIndexMonth1 = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceEndTime()[1]); final double initialIndexMonth0 = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceStartTime()[0]); final double initialIndexMonth1 = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(YEAR_ON_YEAR_NO.getReferenceStartTime()[1]); final double initialIndex = YEAR_ON_YEAR_NO.getWeightStart() * initialIndexMonth0 + (1 - YEAR_ON_YEAR_NO.getWeightStart()) * initialIndexMonth1; final double finalIndex = YEAR_ON_YEAR_NO.getWeightEnd() * finalIndexMonth0 + (1 - YEAR_ON_YEAR_NO.getWeightEnd()) * finalIndexMonth1; final double naExpected = (finalIndex / initialIndex - 1 + MARGIN) * NOTIONAL; assertEquals("Year on year coupon inflation DiscountingMethod: Net amount", naExpected, na.getAmount(YEAR_ON_YEAR_NO.getCurrency()), TOLERANCE_PV); }
@Test public void netAmountMethodVsCalculator() { final MultipleCurrencyAmount naMethod = METHOD.netAmount(YEAR_ON_YEAR_NO, MARKET.getInflationProvider()); final MultipleCurrencyAmount naCalculator = YEAR_ON_YEAR_NO.accept(NAIC, MARKET.getInflationProvider()); assertEquals("Year on year coupon inflation DiscountingMethod: Net amount", naMethod, naCalculator); }