@Test
 /**
  * Test the present value rate sensitivity for a CMS cap with pricing by replication in the SABR
  * with extrapolation framework.
  */
 public void presentValueCurveSensitivity() {
   final MultipleCurrencyParameterSensitivity pvpsCapLongExact =
       PS_SS_C.calculateSensitivity(
           CMS_CAP_LONG, SABR_MULTICURVES, SABR_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsCapLongFD =
       PS_SS_FDC.calculateSensitivity(CMS_CAP_LONG, SABR_MULTICURVES);
   AssertSensivityObjects.assertEquals(
       "SwaptionPhysicalFixedIborSABRMethod: presentValueCurveSensitivity ",
       pvpsCapLongExact,
       pvpsCapLongFD,
       TOLERANCE_PV_DELTA);
   final MultipleCurrencyParameterSensitivity pvpsCapShortExact =
       PS_SS_C.calculateSensitivity(
           CMS_CAP_SHORT,
           SABR_MULTICURVES,
           SABR_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsCapShortFD =
       PS_SS_FDC.calculateSensitivity(CMS_CAP_SHORT, SABR_MULTICURVES);
   AssertSensivityObjects.assertEquals(
       "SwaptionPhysicalFixedIborSABRMethod: presentValueCurveSensitivity ",
       pvpsCapShortExact,
       pvpsCapShortFD,
       TOLERANCE_PV_DELTA);
 }
 /**
  * Test the present value rate sensitivity for a CMS cap with pricing by replication in the SABR
  * with extrapolation framework.
  */
 public void presentValueCurveSensitivity() {
   final MultipleCurrencyParameterSensitivity pvpsCapLongExact =
       PS_SS_C.calculateSensitivity(
           CMS_CAP_LONG, SABR_MULTICURVES, SABR_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsCapLongFD =
       PS_SS_FDC.calculateSensitivity(CMS_CAP_LONG, SABR_MULTICURVES);
   AssertSensitivityObjects.assertEquals(
       "SwaptionPhysicalFixedIborSABRMethod: presentValueCurveSensitivity ",
       pvpsCapLongExact,
       pvpsCapLongFD,
       TOLERANCE_PV_DELTA);
   final MultipleCurrencyParameterSensitivity pvpsCapShortExact =
       PS_SS_C.calculateSensitivity(
           CMS_CAP_SHORT,
           SABR_MULTICURVES,
           SABR_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsCapShortFD =
       PS_SS_FDC.calculateSensitivity(CMS_CAP_SHORT, SABR_MULTICURVES);
   AssertSensitivityObjects.assertEquals(
       "SwaptionPhysicalFixedIborSABRMethod: presentValueCurveSensitivity ",
       pvpsCapShortExact,
       pvpsCapShortFD,
       TOLERANCE_PV_DELTA);
 }
 @Test
 /** Tests present value curve sensitivity when the valuation date is on trade date. */
 public void presentValueCurveSensitivity() {
   final MultipleCurrencyParameterSensitivity pvpsExact =
       PS_HW_C.calculateSensitivity(
           SWAPTION_SHORT_RECEIVER,
           HW_MULTICURVES,
           HW_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsFD =
       PS_HW_FDC.calculateSensitivity(SWAPTION_SHORT_RECEIVER, HW_MULTICURVES);
   AssertSensivityObjects.assertEquals(
       "SwaptionPhysicalFixedIborSABRMethod: presentValueCurveSensitivity ",
       pvpsExact,
       pvpsFD,
       TOLERANCE_PV_DELTA);
 }
 @Test
 /** Tests the curve sensitivity for the explicit formula. */
 public void presentValueCurveSensitivity() {
   final MultipleCurrencyParameterSensitivity pvpsExact =
       PS_BS_C.calculateSensitivity(
           SWAPTION_LONG_REC,
           BLACK_MULTICURVES,
           BLACK_MULTICURVES.getMulticurveProvider().getAllNames());
   final MultipleCurrencyParameterSensitivity pvpsFD =
       PS_BS_FDC.calculateSensitivity(SWAPTION_LONG_REC, BLACK_MULTICURVES);
   AssertSensivityObjects.assertEquals(
       "Swaption Black method: presentValueCurveSensitivity ",
       pvpsExact,
       pvpsFD,
       TOLERANCE_PV_DELTA);
 }
 @Test(enabled = false)
 /** Tests present value curve sensitivity when the valuation date is on trade date. */
 public void presentValueCurveSensitivityStability() {
   // 5Yx5Y
   final MultipleCurrencyParameterSensitivity pvpsExact =
       PS_HW_C.calculateSensitivity(
           SWAPTION_SHORT_RECEIVER,
           HW_MULTICURVES,
           HW_MULTICURVES.getMulticurveProvider().getAllNames());
   final double derivativeExact = pvpsExact.totalSensitivity(MULTICURVES.getFxRates(), EUR);
   final double startingShift = 1.0E-4;
   final double ratio = Math.sqrt(2.0);
   final int nbShift = 55;
   final double[] eps = new double[nbShift + 1];
   final double[] derivative_FD = new double[nbShift];
   final double[] diff = new double[nbShift];
   eps[0] = startingShift;
   for (int loopshift = 0; loopshift < nbShift; loopshift++) {
     final ParameterSensitivityHullWhiteDiscountInterpolatedFDCalculator fdShift =
         new ParameterSensitivityHullWhiteDiscountInterpolatedFDCalculator(PVHWC, eps[loopshift]);
     final MultipleCurrencyParameterSensitivity pvpsFD =
         fdShift.calculateSensitivity(SWAPTION_SHORT_RECEIVER, HW_MULTICURVES);
     derivative_FD[loopshift] = pvpsFD.totalSensitivity(MULTICURVES.getFxRates(), EUR);
     diff[loopshift] = derivative_FD[loopshift] - derivativeExact;
     eps[loopshift + 1] = eps[loopshift] / ratio;
   }
   // 1Mx5Y
   final Period expirationPeriod =
       Period.ofDays(
           1); // Period.ofDays(1); Period.ofDays(7); Period.ofMonths(1); Period.ofYears(1);
   // Period.ofYears(10);
   final ZonedDateTime expiryDateExp =
       ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, expirationPeriod, EURIBOR6M, CALENDAR);
   final ZonedDateTime settlementDateExp =
       ScheduleCalculator.getAdjustedDate(expiryDateExp, SPOT_LAG, CALENDAR);
   final double ATM = 0.0151; //  1W: 1.52% - 1M: 1.52% - 1Y: 1.51% - 10Y: 1.51%
   final SwapFixedIborDefinition swapExpx5YDefinition =
       SwapFixedIborDefinition.from(
           settlementDateExp, SWAP_TENOR, EUR1YEURIBOR6M, NOTIONAL, ATM, !FIXED_IS_PAYER);
   final SwaptionPhysicalFixedIborDefinition swaptionExpx5YDefinition =
       SwaptionPhysicalFixedIborDefinition.from(EXPIRY_DATE, swapExpx5YDefinition, !IS_LONG);
   final SwaptionPhysicalFixedIbor swaptionExpx5Y =
       swaptionExpx5YDefinition.toDerivative(REFERENCE_DATE);
   //    final double forward = swaptionExpx5Y.getUnderlyingSwap().accept(PRDC, MULTICURVES);
   final MultipleCurrencyParameterSensitivity pvpsExactExp =
       PS_HW_C.calculateSensitivity(
           swaptionExpx5Y, HW_MULTICURVES, HW_MULTICURVES.getMulticurveProvider().getAllNames());
   final double derivativeExactExp = pvpsExactExp.totalSensitivity(MULTICURVES.getFxRates(), EUR);
   final double[] derivative_FDExp = new double[nbShift];
   final double[] diffExp = new double[nbShift];
   for (int loopshift = 0; loopshift < nbShift; loopshift++) {
     final ParameterSensitivityHullWhiteDiscountInterpolatedFDCalculator fdShift =
         new ParameterSensitivityHullWhiteDiscountInterpolatedFDCalculator(PVHWC, eps[loopshift]);
     final MultipleCurrencyParameterSensitivity pvpsFD =
         fdShift.calculateSensitivity(swaptionExpx5Y, HW_MULTICURVES);
     derivative_FDExp[loopshift] = pvpsFD.totalSensitivity(MULTICURVES.getFxRates(), EUR);
     diffExp[loopshift] = derivative_FDExp[loopshift] - derivativeExactExp;
   }
   //    int t = 0;
   //    t++;
 }