/**
  * Computes the price of a future from the curves using an estimation of the future rate without
  * convexity adjustment.
  *
  * @param future The future.
  * @param curves The Hull-White parameters and the curves.
  * @return The price.
  */
 public double price(
     final InterestRateFuture future, final HullWhiteOneFactorPiecewiseConstantDataBundle curves) {
   Validate.notNull(future, "Future");
   Validate.notNull(curves, "Curves");
   final YieldAndDiscountCurve forwardCurve = curves.getCurve(future.getForwardCurveName());
   double dfForwardStart = forwardCurve.getDiscountFactor(future.getFixingPeriodStartTime());
   double dfForwardEnd = forwardCurve.getDiscountFactor(future.getFixingPeriodEndTime());
   double forward = (dfForwardStart / dfForwardEnd - 1) / future.getFixingPeriodAccrualFactor();
   double futureConvexityFactor =
       MODEL.futureConvexityFactor(
           future.getLastTradingTime(),
           future.getFixingPeriodStartTime(),
           future.getFixingPeriodEndTime(),
           curves.getHullWhiteParameter());
   double price =
       1.0
           - futureConvexityFactor * forward
           + (1 - futureConvexityFactor) / future.getFixingPeriodAccrualFactor();
   return price;
 }
 /**
  * Compute the price sensitivity to rates of a interest rate future by discounting.
  *
  * @param future The future.
  * @param curves The Hull-White parameters and the curves.
  * @return The price rate sensitivity.
  */
 public InterestRateCurveSensitivity priceCurveSensitivity(
     final InterestRateFuture future, final HullWhiteOneFactorPiecewiseConstantDataBundle curves) {
   Validate.notNull(future, "Future");
   Validate.notNull(curves, "Curves");
   final YieldAndDiscountCurve forwardCurve = curves.getCurve(future.getForwardCurveName());
   double dfForwardStart = forwardCurve.getDiscountFactor(future.getFixingPeriodStartTime());
   double dfForwardEnd = forwardCurve.getDiscountFactor(future.getFixingPeriodEndTime());
   double futureConvexityFactor =
       MODEL.futureConvexityFactor(
           future.getLastTradingTime(),
           future.getFixingPeriodStartTime(),
           future.getFixingPeriodEndTime(),
           curves.getHullWhiteParameter());
   // Backward sweep
   double priceBar = 1.0;
   double forwardBar = -futureConvexityFactor * priceBar;
   double dfForwardEndBar =
       -dfForwardStart
           / (dfForwardEnd * dfForwardEnd)
           / future.getFixingPeriodAccrualFactor()
           * forwardBar;
   double dfForwardStartBar =
       1.0 / (future.getFixingPeriodAccrualFactor() * dfForwardEnd) * forwardBar;
   Map<String, List<DoublesPair>> resultMap = new HashMap<String, List<DoublesPair>>();
   List<DoublesPair> listForward = new ArrayList<DoublesPair>();
   listForward.add(
       new DoublesPair(
           future.getFixingPeriodStartTime(),
           -future.getFixingPeriodStartTime() * dfForwardStart * dfForwardStartBar));
   listForward.add(
       new DoublesPair(
           future.getFixingPeriodEndTime(),
           -future.getFixingPeriodEndTime() * dfForwardEnd * dfForwardEndBar));
   resultMap.put(future.getForwardCurveName(), listForward);
   InterestRateCurveSensitivity result = new InterestRateCurveSensitivity(resultMap);
   return result;
 }