CouponONSpreadDiscountingMethod { public MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponONSpread coupon, final MulticurveProviderInterface multicurve) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(multicurve, "Multi-curves"); final double df = multicurve.getDiscountFactor(coupon.getCurrency(), coupon.getPaymentTime()); final double forward = multicurve.getSimplyCompoundForwardRate(coupon.getIndex(), coupon.getFixingPeriodStartTime(), coupon.getFixingPeriodEndTime(), coupon.getFixingPeriodAccrualFactor()); final double ratio = 1.0 + coupon.getFixingPeriodAccrualFactor() * forward; final double pvBar = 1.0; final double ratioBar = coupon.getNotionalAccrued() * df * pvBar; final double forwardBar = coupon.getFixingPeriodAccrualFactor() * ratioBar; final double dfBar = (coupon.getNotionalAccrued() * ratio + coupon.getSpreadAmount() - coupon.getNotional()) * pvBar; final Map<String, List<DoublesPair>> mapDsc = new HashMap<>(); final List<DoublesPair> listDiscounting = new ArrayList<>(); listDiscounting.add(DoublesPair.of(coupon.getPaymentTime(), -coupon.getPaymentTime() * df * dfBar)); mapDsc.put(multicurve.getName(coupon.getCurrency()), listDiscounting); final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>(); final List<ForwardSensitivity> listForward = new ArrayList<>(); listForward.add(new SimplyCompoundedForwardSensitivity(coupon.getFixingPeriodStartTime(), coupon.getFixingPeriodEndTime(), coupon.getFixingPeriodAccrualFactor(), forwardBar)); mapFwd.put(multicurve.getName(coupon.getIndex()), listForward); final MultipleCurrencyMulticurveSensitivity result = MultipleCurrencyMulticurveSensitivity.of(coupon.getCurrency(), MulticurveSensitivity.of(mapDsc, mapFwd)); return result; } private  CouponONSpreadDiscountingMethod(); static CouponONSpreadDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponONSpread coupon, final MulticurveProviderInterface multicurve); MultipleCurrencyAmount presentValue(
      final CouponONSpread coupon,
      final MulticurveProviderInterface multicurve,
      final ForwardRateProvider<IndexON> forwardRateProvider); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponONSpread coupon, final MulticurveProviderInterface multicurve); double parRate(final CouponONSpread coupon, final MulticurveProviderInterface multicurve); MultipleCurrencyMulticurveSensitivity parRateCurveSensitivity(final CouponONSpread coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueCurveSensitivity() { final MultipleCurrencyParameterSensitivity pvpsDepositExact = PSC.calculateSensitivity(CPN_OIS, MULTICURVES, MULTICURVES.getAllNames()); final MultipleCurrencyParameterSensitivity pvpsDepositFD = PSC_DSC_FD.calculateSensitivity(CPN_OIS, MULTICURVES); AssertSensitivityObjects.assertEquals("CashDiscountingProviderMethod: presentValueCurveSensitivity ", pvpsDepositExact, pvpsDepositFD, TOLERANCE_PV_DELTA); }
@Test public void presentValueMarketSensitivityMethodVsCalculator() { final MultipleCurrencyMulticurveSensitivity pvcsMethod = METHOD_CPN_ON.presentValueCurveSensitivity(CPN_OIS, MULTICURVES); final MultipleCurrencyMulticurveSensitivity pvcsCalculator = CPN_OIS.accept(PVCSDC, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponFixedDiscountingMarketMethod: presentValueMarketSensitivity", pvcsMethod, pvcsCalculator, TOLERANCE_PV_DELTA); }