CouponFixedAccruedCompoundingDiscountingMethod { public MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponFixedAccruedCompounding cpn, final MulticurveProviderInterface multicurve) { final double time = cpn.getPaymentTime(); final Map<String, List<DoublesPair>> mapDsc = new HashMap<>(); final DoublesPair s = DoublesPair.of(time, -time * cpn.getAmount() * multicurve.getDiscountFactor(cpn.getCurrency(), time)); final List<DoublesPair> list = new ArrayList<>(); list.add(s); mapDsc.put(multicurve.getName(cpn.getCurrency()), list); MultipleCurrencyMulticurveSensitivity result = new MultipleCurrencyMulticurveSensitivity(); result = result.plus(cpn.getCurrency(), MulticurveSensitivity.ofYieldDiscounting(mapDsc)); return result; } private  CouponFixedAccruedCompoundingDiscountingMethod(); static CouponFixedAccruedCompoundingDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponFixedAccruedCompounding coupon, final MulticurveProviderInterface multicurves); CurrencyAmount presentValuePositiveNotional(final CouponFixedAccruedCompounding coupon, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponFixedAccruedCompounding cpn, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueParallelCurveSensitivity() { final MultipleCurrencyMulticurveSensitivity pvpcsComputed = METHOD.presentValueCurveSensitivity(CPN_PAY, MULTICURVES); final double pvpcsExpectedDouble = -CPN_PAY.getPaymentTime() * CPN_PAY.getAmount() * MULTICURVES.getDiscountFactor(CPN_PAY.getCurrency(), CPN_PAY.getPaymentTime()); final Map<String, List<DoublesPair>> mapDsc = new HashMap<>(); final DoublesPair s = DoublesPair.of(CPN_PAY.getPaymentTime(), pvpcsExpectedDouble); final List<DoublesPair> list = new ArrayList<>(); list.add(s); mapDsc.put(MULTICURVES.getName(CPN_PAY.getCurrency()), list); MultipleCurrencyMulticurveSensitivity pvpcsExpected = new MultipleCurrencyMulticurveSensitivity(); pvpcsExpected = pvpcsExpected.plus(CPN_PAY.getCurrency(), MulticurveSensitivity.ofYieldDiscounting(mapDsc)); AssertSensitivityObjects.assertEquals("CouponFixedAccruedCompounding: Present value parallel curve sensitivity by discounting", pvpcsExpected, pvpcsComputed, 1.0E-2); }
@Test public void presentValueParallelCurveSensitivityMethodVsCalculator() { final MultipleCurrencyMulticurveSensitivity pvpcsMethod = METHOD.presentValueCurveSensitivity(CPN_PAY, MULTICURVES); final MultipleCurrencyMulticurveSensitivity pvpcsCalculator = CPN_PAY.accept(PVCSDC, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponFixed: Present value parallel curve sensitivity by discounting", pvpcsMethod, pvpcsCalculator, 1.0E-5); }
@Test public void presentValueCurveSensitivity() { final MultipleCurrencyParameterSensitivity pvpsAnnuityExact = PSC.calculateSensitivity(CPN_PAY, MULTICURVES, MULTICURVES.getAllNames()); final MultipleCurrencyParameterSensitivity pvpsAnnuityFD = PSC_DSC_FD.calculateSensitivity(CPN_PAY, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponFixedCompoundingDiscountingMethod: presentValueCurveSensitivity ", pvpsAnnuityExact, pvpsAnnuityFD, TOLERANCE_PV_DELTA); }
@Test public void presentValueParallelCurveSensitivityWithAccrualDates() { final MultipleCurrencyMulticurveSensitivity pvpcsComputed = METHOD.presentValueCurveSensitivity(CPN_PAY_WITH_ACCRUAL_DATES, MULTICURVES); final double pvpcsExpectedDouble = -CPN_PAY_WITH_ACCRUAL_DATES.getPaymentTime() * CPN_PAY_WITH_ACCRUAL_DATES.getAmount() * MULTICURVES.getDiscountFactor(CPN_PAY_WITH_ACCRUAL_DATES.getCurrency(), CPN_PAY_WITH_ACCRUAL_DATES.getPaymentTime()); final Map<String, List<DoublesPair>> mapDsc = new HashMap<>(); final DoublesPair s = DoublesPair.of(CPN_PAY_WITH_ACCRUAL_DATES.getPaymentTime(), pvpcsExpectedDouble); final List<DoublesPair> list = new ArrayList<>(); list.add(s); mapDsc.put(MULTICURVES.getName(CPN_PAY_WITH_ACCRUAL_DATES.getCurrency()), list); MultipleCurrencyMulticurveSensitivity pvpcsExpected = new MultipleCurrencyMulticurveSensitivity(); pvpcsExpected = pvpcsExpected.plus(CPN_PAY_WITH_ACCRUAL_DATES.getCurrency(), MulticurveSensitivity.ofYieldDiscounting(mapDsc)); AssertSensitivityObjects.assertEquals("CouponFixedAccruedCompounding: Present value parallel curve sensitivity by discounting", pvpcsExpected, pvpcsComputed, 1.0E-2); }
@Test public void presentValueParallelCurveSensitivityMethodVsCalculatorWithAccrualDates() { final MultipleCurrencyMulticurveSensitivity pvpcsMethod = METHOD.presentValueCurveSensitivity(CPN_PAY_WITH_ACCRUAL_DATES, MULTICURVES); final MultipleCurrencyMulticurveSensitivity pvpcsCalculator = CPN_PAY_WITH_ACCRUAL_DATES.accept(PVCSDC, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponFixed: Present value parallel curve sensitivity by discounting", pvpcsMethod, pvpcsCalculator, 1.0E-5); }