@Test
 /** Test the price computed from the curves */
 public void price() {
   final YieldCurveBundle curves = TestsDataSets.createCurves1();
   final double price = METHOD.price(ERU2, curves);
   final YieldAndDiscountCurve forwardCurve = curves.getCurve(FORWARD_CURVE_NAME);
   final double forward =
       (forwardCurve.getDiscountFactor(FIXING_START_TIME)
                   / forwardCurve.getDiscountFactor(FIXING_END_TIME)
               - 1)
           / FIXING_ACCRUAL;
   final double factor = MODEL.futureConvexityFactor(ERU2, MODEL_PARAMETERS);
   final double expectedPrice = 1.0 - factor * forward + (1 - factor) / FIXING_ACCRUAL;
   assertEquals("Future price from curves in Hull-White one factor model", expectedPrice, price);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }