Class ShortRateModels

java.lang.Object
com.quantfinlib.rates.ShortRateModels

public final class ShortRateModels extends Object
The three classic short-rate models, each answering "what is a zero-coupon bond worth if the short rate follows this SDE?" in closed form — the workhorse trio of rates risk factor modeling:
  • Vasicek dr = a(b − r)dt + σ dW — Gaussian, tractable everywhere, and honest about its flaw: rates can go negative (which, post-2015, is a feature as much as a bug);
  • CIR dr = a(b − r)dt + σ√r dW — the square-root diffusion keeps rates non-negative (strictly positive when the Feller condition 2ab ≥ σ² holds), at the cost of fatter formulas;
  • Hull-White — Vasicek with a time-dependent drift fitted so the model reprices TODAY'S curve exactly: the standard production choice, because a rates model that disagrees with the discount curve it hedges against is wrong by construction. Bond prices come from the curve plus a Gaussian convexity adjustment; no explicit θ(t) is needed for pricing.

All prices are for unit face. Simulation steps (exact Gaussian for Vasicek, full-truncation Euler for CIR) are provided for Monte Carlo scenario generation — the rates leg of a risk-factor simulation. Static, allocation-free per call, research lane. Calibration of (a, σ) to market instruments is the caller's optimization exercise; these classes price and simulate given parameters.

  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    cirBond(double shortRate, double a, double b, double sigma, double maturityYears)
    CIR zero-coupon bond price P(t, t+T).
    static double
    cirFeller(double a, double b, double sigma)
    The Feller ratio 2ab/σ²; ≥ 1 keeps the CIR rate strictly positive.
    static double
    cirStep(double shortRate, double a, double b, double sigma, double dtYears, double gaussian)
    One full-truncation Euler CIR step (never sources vol from a negative rate).
    static double
    hullWhiteBond(YieldCurve curve, double tYears, double maturityYears, double shortRate, double a, double sigma)
    Hull-White zero-coupon bond price P(t, t+T) given the market curve and the short rate now.
    static double
    instantaneousForward(YieldCurve curve, double tYears)
    The instantaneous forward rate f(0, t) off the curve, by symmetric finite difference of ln P (the curve carries no analytic derivative).
    static double
    vasicekBond(double shortRate, double a, double b, double sigma, double maturityYears)
    Vasicek zero-coupon bond price P(t, t+T) given the short rate now.
    static double
    vasicekStep(double shortRate, double a, double b, double sigma, double dtYears, double gaussian)
    One EXACT Vasicek simulation step (the transition is Gaussian, so no discretization error): r ← b + (r−b)e^{−aΔt} + stdev·z.
    static double
    vasicekYield(double shortRate, double a, double b, double sigma, double maturityYears)
    The continuously-compounded zero yield implied by vasicekBond(double, double, double, double, double).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • vasicekBond

      public static double vasicekBond(double shortRate, double a, double b, double sigma, double maturityYears)
      Vasicek zero-coupon bond price P(t, t+T) given the short rate now.
    • vasicekYield

      public static double vasicekYield(double shortRate, double a, double b, double sigma, double maturityYears)
      The continuously-compounded zero yield implied by vasicekBond(double, double, double, double, double).
    • vasicekStep

      public static double vasicekStep(double shortRate, double a, double b, double sigma, double dtYears, double gaussian)
      One EXACT Vasicek simulation step (the transition is Gaussian, so no discretization error): r ← b + (r−b)e^{−aΔt} + stdev·z.
    • cirBond

      public static double cirBond(double shortRate, double a, double b, double sigma, double maturityYears)
      CIR zero-coupon bond price P(t, t+T).
    • cirFeller

      public static double cirFeller(double a, double b, double sigma)
      The Feller ratio 2ab/σ²; ≥ 1 keeps the CIR rate strictly positive.
    • cirStep

      public static double cirStep(double shortRate, double a, double b, double sigma, double dtYears, double gaussian)
      One full-truncation Euler CIR step (never sources vol from a negative rate).
    • hullWhiteBond

      public static double hullWhiteBond(YieldCurve curve, double tYears, double maturityYears, double shortRate, double a, double sigma)
      Hull-White zero-coupon bond price P(t, t+T) given the market curve and the short rate now. By construction, at t = 0 with shortRate = f(0, 0) this reprices the curve exactly; away from it, the Gaussian convexity adjustment applies:
        P(t,T) = [P(0,T)/P(0,t)] · exp(B(f(0,t) − r) − σ²B²(1−e^{−2at})/(4a))
      Parameters:
      curve - today's discount curve
      tYears - valuation time (0 = today)
      maturityYears - time FROM t to the bond's maturity
      shortRate - the simulated short rate at t
      a - mean-reversion speed
      sigma - short-rate vol
    • instantaneousForward

      public static double instantaneousForward(YieldCurve curve, double tYears)
      The instantaneous forward rate f(0, t) off the curve, by symmetric finite difference of ln P (the curve carries no analytic derivative).