CouponIborAverageFixingDatesDiscountingMethod { public MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurve) { ArgumentChecker.notNull(coupon, "Coupon"); ArgumentChecker.notNull(multicurve, "Curves"); final int nDates = coupon.getFixingPeriodEndTime().length; double forward = 0.; for (int i = 0; i < nDates; ++i) { final double forward1 = multicurve.getSimplyCompoundForwardRate(coupon.getIndex(), coupon.getFixingPeriodStartTime()[i], coupon.getFixingPeriodEndTime()[i], coupon.getFixingPeriodAccrualFactor()[i]); forward += coupon.getWeight()[i] * forward1; } forward += coupon.getAmountAccrued(); final double df = multicurve.getDiscountFactor(coupon.getCurrency(), coupon.getPaymentTime()); final double forwardBar = coupon.getNotional() * coupon.getPaymentYearFraction() * df; final double dfBar = coupon.getNotional() * coupon.getPaymentYearFraction() * forward; final double[] forwardBars = new double[nDates]; for (int i = 0; i < nDates; ++i) { forwardBars[i] = coupon.getWeight()[i] * forwardBar; } 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<>(); for (int i = 0; i < nDates; ++i) { listForward.add(new SimplyCompoundedForwardSensitivity(coupon.getFixingPeriodStartTime()[i], coupon.getFixingPeriodEndTime()[i], coupon.getFixingPeriodAccrualFactor()[i], forwardBars[i])); } mapFwd.put(multicurve.getName(coupon.getIndex()), listForward); return MultipleCurrencyMulticurveSensitivity.of(coupon.getCurrency(), MulticurveSensitivity.of(mapDsc, mapFwd)); } private  CouponIborAverageFixingDatesDiscountingMethod(); static CouponIborAverageFixingDatesDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurve);  }
@Test public void presentValueMarketSensitivityMethodVsCalculator() { final MultipleCurrencyMulticurveSensitivity pvcsMethod1 = METHOD.presentValueCurveSensitivity(DER1, MULTICURVES); final MultipleCurrencyMulticurveSensitivity pvcsCalculator1 = DER1.accept(PVCSDC, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponIborAverageFixingDatesDiscountingMethod", pvcsMethod1, pvcsCalculator1, TOLERANCE_PV_DELTA); final MultipleCurrencyMulticurveSensitivity pvcsMethod2 = METHOD.presentValueCurveSensitivity(DER2, MULTICURVES); final MultipleCurrencyMulticurveSensitivity pvcsCalculator2 = DER2.accept(PVCSDC, MULTICURVES); AssertSensitivityObjects.assertEquals("CouponIborAverageFixingDatesDiscountingMethod", pvcsMethod2, pvcsCalculator2, TOLERANCE_PV_DELTA); }