σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
QuantLib skill›Module 4 · Surfaces and calibration›Topic 4.2·~1 hr 10 minAdvanced

Short-rate models: calibrating Hull–White

Skill positionModule 4 of 5 · Topic 2 of 3
4.2 Short-rate models: calibrating Hull–White
—Lab score— / 100Total XP—Streak—
Lecture0% read

9 min readCode examples: 4

  1. 01A model for the short rate
  2. 02Options on bonds and caplets
  3. 03Calibrating to the market
  4. 04Hull–White on the real curve
  5. 05What you will build

On 9 October 2026 four six-month caplets, expiring in 1, 2, 3 and 4 years, are quoted by Black volatilities of 40%, 36%, 33% and 31% (stand-in quotes: the course has no caplet data). On the real Treasury curve they cost 36.4, 44.4, 48.2 and 50.9 per 10,000 of notional. A Hull–White model with a mean reversion of 0.20 and a volatility of 2.2% matches the first exactly and the others within 4.3%, and it reproduces today's curve to machine precision. It then prices what no quote gives: a 2-year put on a 5-year bond costs 0.0182 per unit of face value. This topic writes the model, its closed forms, and the calibration.

01

A model for the short rate

Where we are. Up to now the interest rate was a number, or a curve known today. An option on a rate, such as a cap, depends on how rates move. A short-rate model describes the instantaneous rate r(t) as a random process. In the Hull–White model the rate is pulled back towards a level with a speed a (the mean reversion) and is shaken by a random term of size σ: dr = (θ(t) − a r) dt + σ dW. The function θ(t) is chosen so that the model gives *exactly* today's discount factors. Because of this, the model is called arbitrage-free with respect to the curve, and the curve of topic 6 is its input.

The model has closed forms. The price at time t of a zero-coupon bond that matures at T is P(t, T) = A(t, T) × exp(−B(t, T) × r(t)). The factor B says how much the bond reacts to the short rate: it is a duration that is capped by the mean reversion, since a rate shock fades away. The factor A carries today's curve (through P(0, T) ÷ P(0, t) and f(0, t), the instantaneous forward rate) and a convexity correction that lowers the price of a long bond when σ grows.

B(t, T) = ( 1 − e^(−a (T − t)) ) ÷ a, A(t, T) = P(0, T) ÷ P(0, t) × exp( B f(0, t) − σ² ÷ (4a) × ( 1 − e^(−2 a t) ) × B² )(1)a is the mean reversion, σ the volatility, P(0, t) today's discount factor for t, f(0, t) today's instantaneous forward rate for t, and r(t) the short rate at t; the bond price is A × exp(−B r)

Worked example 1. *Problem:* find B for a bond of 1, 5 and 10 years with a mean reversion of 0.1 and of 0.5. Then, on a flat 5% curve with a = 0.1 and σ = 1%, price a 5-year bond today with the short rate at 5%, and in one year with the short rate at 3%, 5% and 7%. Finally set σ = 0 and compare with the forward price. *Plan:* use hw_B and hw_bond_price. *Steps:* below.

main.pyPython
print([round(hw_B(0.1, 0.0, T), 4) for T in (1, 5, 10)], [round(hw_B(0.5, 0.0, T), 4) for T in (1, 5, 10)])1p = lambda t: math.exp(-0.05 * t)print(round(hw_bond_price(0.1, 0.01, 1.0, p(5), 0.05, 0.0, 5.0, 0.05), 5), round(p(5), 5))2for r in (0.03, 0.05, 0.07):    print(r, round(hw_bond_price(0.1, 0.01, p(1), p(5), 0.05, 1.0, 5.0, r), 5))3print(round(hw_bond_price(0.1, 0.0, p(1), p(5), 0.05, 1.0, 5.0, 0.05), 5), round(p(4), 5))4
[0.9516, 3.9347, 6.3212] [0.7869, 1.8358, 1.9865]
0.7788 0.7788
0.03 0.8741
0.05 0.81833
0.07 0.76611
0.81873 0.81873
  1. 1B grows with the maturity, more slowly the larger the mean reversion.
  2. 2At time 0 the model gives today's price.
  3. 3A lower short rate, a dearer bond.
  4. 4No volatility: the forward price.

*Check:* B is 0.9516, 3.9347 and 6.3212 for a mean reversion of 0.1, and 0.7869, 1.8358 and 1.9865 for 0.5: with strong mean reversion a 10-year bond reacts to the short rate about as much as a 2-year bond would without mean reversion. The bond today is 0.7788 from the model and 0.7788 from the curve. In one year, with the short rate at 3%, 5% and 7%, the 5-year bond costs 0.8741, 0.81833 and 0.76611. With no volatility and a 5% short rate it costs 0.81873, the forward price e^(−0.05 × 4); with σ = 1% it costs 0.81833, a little less, because of the convexity term. *What to notice:* the formula is exact for any short rate; only the short rate, one number, is needed to price every bond.

02

Options on bonds and caplets

The model gives a closed form for a European option on a zero-coupon bond. At the expiry s of the option, the bond price is log-normal under the right probability measure, with a volatility σ_p that combines the model volatility, the mean reversion, the time to expiry and the sensitivity B(s, T). The result has the shape of Black's formula: call = P(0, T) N(h) − K P(0, s) N(h − σ_p), put = K P(0, s) N(σ_p − h) − P(0, T) N(−h), with h = ln( P(0, T) ÷ (K P(0, s)) ) ÷ σ_p + σ_p ÷ 2. This is the Jamshidian formula.

A caplet pays at time T the amount δ × max(L − K, 0), where L is the simple rate for the period from s to T, of length δ, and K the strike. Buying it is the same as buying a put on the bond that matures at T, with a strike 1 ÷ (1 + δK), scaled by 1 + δK. So the caplet price is (1 + δK) × put. A cap is a sum of caplets, so the closed form prices caps, and a calibration to caps is a calibration of the model.

Worked example 2. *Problem:* on a flat 5% curve with a = 0.1, price a put and a call that expire in 1 year on the 5-year bond, struck at the forward price, for σ of 0.5%, 1% and 2%. Then price the 1-year caplet on the rate from year 1 to year 1.5, struck at the forward rate, and find the Black volatility that gives the same price. *Plan:* use hw_bond_option and hw_caplet. *Steps:* below.

main.pyPython
p = lambda t: math.exp(-0.05 * t)x = p(5) / p(1)for sigma in (0.005, 0.01, 0.02):    print(sigma, round(hw_bond_option(0.1, sigma, p(1), p(5), 1.0, 5.0, x, "put"), 5), round(hw_bond_option(0.1, sigma, p(1), p(5), 1.0, 5.0, x, "call"), 5))1forward = (p(1) / p(1.5) - 1) / 0.5for sigma in (0.005, 0.01, 0.02):    price = hw_caplet(0.1, sigma, p(1), p(1.5), 1.0, 1.5, forward)2    low, high = 0.01, 3.0    for _ in range(100):        mid = 0.5 * (low + high)        low, high = (low, mid) if black_caplet(p(1.5), forward, forward, mid, 1.0, 0.5) > price else (mid, high)    print(sigma, round(price * 1e4, 3), round(0.5 * (low + high), 4))3
0.005 0.00488 0.00488
0.01 0.00975 0.00975
0.02 0.0195 0.0195
0.005 8.81 0.0941
0.01 17.62 0.1883
0.02 35.239 0.3784
  1. 1At the forward price a put and a call have the same value.
  2. 2The caplet price, printed per 10,000 of notional.
  3. 3The Black volatility with the same price.

*Check:* the put and the call struck at the forward price are equal, 0.00488, 0.00975 and 0.0195 for the three volatilities: this is put-call parity, call − put = P(0, T) − K P(0, s) = 0. The caplet is worth 8.81, 17.62 and 35.239 per 10,000 of notional, and the equivalent Black volatilities are 0.0941, 0.1883 and 0.3784. *What to notice:* the Hull–White volatility is a *normal* (absolute) volatility of the rate: σ = 1% on a 5% rate is a lognormal volatility of about 1% ÷ 5% = 20%, here 18.8%. This is how market caplet volatilities are translated into model parameters.

03

Calibrating to the market

Calibration chooses the model parameters so that the model prices match market prices. The caplet price rises with σ, so for a given mean reversion a, the σ that matches a target price is found by bisection, exactly as the implied volatility of topic 5. But there are two parameters and many caplets. A simple method: for each a in a grid, fix σ so that the first caplet is exact, then measure the squared error over all the caplets; keep the best a. QuantLib does the same with an optimiser (Levenberg–Marquardt) over both parameters at once.

Worked example 3. *Problem:* on a flat 5% curve, build four caplets (expiries 1 to 4, six months, struck at the forward rate) and take their prices from a model with a = 0.05 and σ = 1.2%. Calibrate with the grid of mean reversions A_GRID. Then take prices from a model with a = 0.07, which is not in the grid, and calibrate again. *Plan:* use calibrate_hw. *Steps:* below.

main.pyPython
p = lambda t: math.exp(-0.05 * t)caplets = [(p(s), p(s + 0.5), s, s + 0.5, (p(s) / p(s + 0.5) - 1) / 0.5) for s in (1.0, 2.0, 3.0, 4.0)]targets = [hw_caplet(0.05, 0.012, *c) for c in caplets]a, sigma, error = calibrate_hw(A_GRID, caplets, targets)1print(a, round(sigma, 6), round(error, 12))2off = [hw_caplet(0.07, 0.012, *c) for c in caplets]3a, sigma, error = calibrate_hw(A_GRID, caplets, off)print(a, round(sigma, 6), error < 1e-7, [round(hw_caplet(a, sigma, *c) * 1e4, 3) for c in caplets], [round(t * 1e4, 3) for t in off])4
0.05 0.012 0.0
0.05 0.011824 True [21.614, 28.376, 32.276, 34.627] [21.614, 28.111, 31.688, 33.704]
  1. 1Calibrate to prices made by a model in the grid.
  2. 2The parameters come back.
  3. 3Prices from a mean reversion that is not in the grid.
  4. 4The best of the grid: the fit is close but not exact.

*Check:* the first calibration returns 0.05 0.012 0.0: the parameters that made the prices, with an error of zero. The second returns the nearest grid value, 0.05, with σ = 0.011824 and a small error (below 1e-7): the model prices are 21.614, 28.376, 32.276 and 34.627 against the market 21.614, 28.111, 31.688 and 33.704. *What to notice:* the first caplet is matched exactly because σ is fitted to it, and the others are close. Different pairs of a and σ give nearly the same caplets, so a is poorly determined by caplets alone; a calibration to a few prices is a summary, not the truth.

04

Hull–White on the real curve

Worked example 4. *Problem:* on the last day of the data, build the zero curve from the Treasury par yields of 1, 2, 3, 5, 7 and 10 years. Take four at-the-money caplets of six months, expiring in 1, 2, 3 and 4 years, with market Black volatilities of 40%, 36%, 33% and 31%, and calibrate the model with A_GRID. Find the largest relative error of the model prices. Check that the model reproduces the 5-year discount factor today, and price a put that expires in 2 years on the 5-year bond, struck at the forward price. *Plan:* study combines the functions. *Steps:* below.

main.pyPython
out = study(load_data())print(out["a"], round(out["sigma"], 5), round(out["fit_error"], 4), out["curve_error"])1print([round(v * 1e4, 2) for v in out["market_prices"]], [round(v * 1e4, 2) for v in out["model_prices"]])2print(round(out["put_on_bond"], 5))3
0.2 0.02207 0.043 0.0
[36.41, 44.41, 48.21, 50.94] [36.41, 44.75, 47.97, 48.75]
0.01823
  1. 1The calibrated parameters, the error, and the curve check.
  2. 2Market and model caplets per 10,000 of notional.
  3. 3The put on the 5-year bond.

*Check:* the calibration picks a = 0.2, the edge of the grid, with σ = 0.02207. The largest relative error is 0.043 (4.3%) and the curve error is 0.0. The market caplets are 36.41, 44.41, 48.21 and 50.94 per 10,000, and the model gives 36.41, 44.75, 47.97 and 48.75: the first is exact, and the model undervalues the 4-year caplet by 4%. The put on the 5-year bond costs 0.01823 per unit of face value. *What to notice:* the market volatilities fall with the expiry, a *humped* shape that a model with constant parameters can follow only roughly; the next step in practice is a time-dependent σ.

A calibrated model is a summary of the prices

The market volatilities here are stand-ins, and the parameters that fit a few quotes are not unique: another pair of a and σ can fit almost as well and price a different instrument differently. Calibrate to the instruments that resemble the one you want to price, and look at the errors before you trust the model. In QuantLib, HullWhite is the model, JamshidianSwaptionEngine and AnalyticCapFloorEngine price with it, and calibrate fits the parameters to a set of calibration helpers.

  • NameQuestion it answers
  • hw_B(a, t, T)How much does a bond react to the short rate?QuantLib: HullWhite.B
  • hw_bond_price(a, sigma, p_0t, p_0T, f_0t, t, T, r)What is a bond worth, given the short rate?uses hw_BQuantLib: HullWhite.discountBond
  • hw_bond_option(a, sigma, p_s, p_T, s, T, strike, kind)What is an option on a bond worth?uses hw_BQuantLib: HullWhite.discountBondOption
  • hw_caplet(a, sigma, p_s, p_T, s, T, strike)What is a caplet worth in the model?uses hw_bond_optionQuantLib: AnalyticCapFloorEngine
  • fit_sigma(a, p_s, p_T, s, T, strike, target)Which volatility gives this price?uses hw_capletlike the implied volatility of topic 5
  • calibrate_hw(a_grid, caplets, targets)Which parameters fit the market?uses fit_sigmaQuantLib: HullWhite.calibrate
What the real data saysHull–White calibrated to four six-month caplets on the Treasury curve of 9 October 2026, with Black volatilities of 40%, 36%, 33% and 31%
Mean reversion and volatility0.20, 2.2%the edge of the grid for a
Largest caplet error4.3%the 4-year caplet; the first is exact
Curve error0the model gives today's 5-year discount factor
Put on a 5-year bond, expiry 2 years0.0182per unit of face value

Key takeaways

  • A short-rate model has a closed form for bonds. P(t, T) = A × exp(−B r): the short rate is the only random input, and A carries today's curve exactly.
  • A caplet is a put on a bond. Scaled by 1 + δK, with the strike 1 ÷ (1 + δK); the Jamshidian formula prices it like Black's.
  • The model volatility is a normal volatility. σ divided by the rate is roughly the lognormal volatility the market quotes.
  • Calibration is a search for parameters. Fit σ to one price by bisection, search the mean reversion over a grid, and look at the errors: the parameters are not unique.
Quick check
Your turn. In the Hull–White model with a volatility σ of 1%, the forward rate is 5%. Which Black (lognormal) volatility is closest to the caplet's price?
Pick an answer.
05

What you will build

The lab follows the lecture. Task 1 is the factor B, and task 2 the price of a bond given the short rate. Task 3 prices an option on a bond, and task 4 a caplet as a put on the bond. Task 5 finds the volatility that matches one price by bisection, and task 6 calibrates the volatility and the mean reversion to a set of caplets. Task 7 calibrates the model to four caplets on the real Treasury curve.

Next topic: Calibrating the Heston model. The equity options of topic 10 had a smile that Black-Scholes-Merton cannot explain with one volatility. Heston is the equity counterpart of what you just did: a model in which the volatility itself is random, with a handful of parameters, calibrated to the implied volatility surface. It has no simple closed form in the variance, so it asks for numerical integration.

Lab · what's graded

7 tasks · 100 pts
  • The factor B6 pts
  • A bond price16 pts
  • An option on a bond20 pts
  • A caplet10 pts
  • The volatility for a price12 pts
  • Calibration16 pts
  • Hull–White on the real curve20 pts
Explorer · lab-sqt-11
▾ lab-sqt-11
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-sqt-11$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-sqt-11 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes