/**
  * Computes the option security price curve sensitivity. The future price is computed without
  * convexity adjustment.
  *
  * @param security The future option security.
  * @param sabrData The SABR data bundle.
  * @return The security price curve sensitivity.
  */
 public InterestRateCurveSensitivity priceCurveSensitivity(
     final InterestRateFutureOptionMarginSecurity security,
     final SABRInterestRateDataBundle sabrData) {
   // Forward sweep
   final double priceFuture = METHOD_FUTURE.price(security.getUnderlyingFuture(), sabrData);
   final double rateStrike = 1.0 - security.getStrike();
   final EuropeanVanillaOption option =
       new EuropeanVanillaOption(rateStrike, security.getExpirationTime(), !security.isCall());
   final double forward = 1 - priceFuture;
   final double delay =
       security.getUnderlyingFuture().getLastTradingTime() - security.getExpirationTime();
   final double[] volatilityAdjoint =
       sabrData
           .getSABRParameter()
           .getVolatilityAdjoint(security.getExpirationTime(), delay, rateStrike, forward);
   final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatilityAdjoint[0]);
   final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
   // Backward sweep
   final double priceBar = 1.0;
   final double volatilityBar = priceAdjoint[2] * priceBar;
   final double forwardBar = priceAdjoint[1] * priceBar + volatilityAdjoint[1] * volatilityBar;
   final double priceFutureBar = -forwardBar;
   final InterestRateCurveSensitivity priceFutureDerivative =
       METHOD_FUTURE.priceCurveSensitivity(security.getUnderlyingFuture(), sabrData);
   return priceFutureDerivative.multipliedBy(priceFutureBar);
 }
 /**
  * Computes the option security price curve sensitivity. The future price is computed without
  * convexity adjustment.
  *
  * @param security The future option security.
  * @param sabrData The SABR data bundle.
  * @return The security price curve sensitivity.
  */
 public PresentValueSABRSensitivityDataBundle priceSABRSensitivity(
     final InterestRateFutureOptionMarginSecurity security,
     final SABRInterestRateDataBundle sabrData) {
   final PresentValueSABRSensitivityDataBundle sensi = new PresentValueSABRSensitivityDataBundle();
   // Forward sweep
   final double priceFuture = METHOD_FUTURE.price(security.getUnderlyingFuture(), sabrData);
   final double rateStrike = 1.0 - security.getStrike();
   final EuropeanVanillaOption option =
       new EuropeanVanillaOption(rateStrike, security.getExpirationTime(), !security.isCall());
   final double forward = 1 - priceFuture;
   final double delay =
       security.getUnderlyingFuture().getLastTradingTime() - security.getExpirationTime();
   final double[] volatilityAdjoint =
       sabrData
           .getSABRParameter()
           .getVolatilityAdjoint(security.getExpirationTime(), delay, rateStrike, forward);
   final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatilityAdjoint[0]);
   final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
   // Backward sweep
   final double priceBar = 1.0;
   final double volatilityBar = priceAdjoint[2] * priceBar;
   final DoublesPair expiryDelay = new DoublesPair(security.getExpirationTime(), delay);
   sensi.addAlpha(expiryDelay, volatilityAdjoint[3] * volatilityBar);
   sensi.addBeta(expiryDelay, volatilityAdjoint[4] * volatilityBar);
   sensi.addRho(expiryDelay, volatilityAdjoint[5] * volatilityBar);
   sensi.addNu(expiryDelay, volatilityAdjoint[6] * volatilityBar);
   return sensi;
 }
 public void delta() {
   final double priceFutures =
       METHOD_FUTURE.price(CALL_JB_147.getUnderlyingFuture(), ISSUER_SPECIFIC_MULTICURVES);
   final EuropeanVanillaOption option =
       new EuropeanVanillaOption(
           STRIKE_147, CALL_JB_147.getExpirationTime(), CALL_JB_147.isCall());
   final double expiry = CALL_JB_147.getExpirationTime();
   final double volatility = BLACK_SURFACE_EXP_STRIKE.getZValue(expiry, STRIKE_147);
   double df =
       ISSUER_SPECIFIC_MULTICURVES
           .getMulticurveProvider()
           .getDiscountFactor(JBM5_DEFINITION.getCurrency(), CALL_JB_147.getExpirationTime());
   final BlackFunctionData dataBlack = new BlackFunctionData(priceFutures, df, volatility);
   final double[] priceAD = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
   final double deltaCallExpected = priceAD[1];
   final double deltaCallComputed = METHOD_OPT.delta(CALL_JB_147, BLACK_EXP_STRIKE_BNDFUT);
   assertEquals(
       "BondFuturesOptionPremiumSecurityBlackBondFuturesMethod: delta",
       deltaCallExpected,
       deltaCallComputed,
       TOLERANCE_DELTA);
   final double deltaPutComputed = METHOD_OPT.delta(PUT_JB_147, BLACK_EXP_STRIKE_BNDFUT);
   assertEquals(
       "BondFuturesOptionPremiumSecurityBlackBondFuturesMethod: delta",
       deltaCallExpected - deltaPutComputed,
       df,
       TOLERANCE_DELTA);
 }