Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceStochastic ModelsGuide
Guide
Derivatives pricing
01Forwards, calls and puts02Combining positions03Arbitrage and the forward price04Put–call parity05The one-step binomial model06Risk-neutral probabilities07Multi-step trees and backward induction08American options and early exercise09Delta and hedging10Geometric Brownian motion11The Black–Scholes formula12The Greeks: gamma, vega, theta and rho13Implied volatility and the volatility smile14Stochastic volatility and the Heston model15Static replication: Breeden–Litzenberger and Carr–Madan16Exotic options: barriers, Asians and digitals
Portfolio & risk
01Returns and volatility02Diversification and correlation03The efficient frontier and the capital market line04Risk aversion and the optimal complete portfolio05CAPM, beta and the security market line06Performance measures: Sharpe, Treynor, Jensen and information ratio07Factor models and systematic risk08Value at Risk and expected shortfall
Fixed income
01Bond prices and yields02Duration and convexity03Immunization and duration matching04Spot rates, forward rates and the yield curve05Bond futures and the cheapest-to-deliver06Interest rate swaps07Callable bonds and negative convexity08Credit risk: default probabilities and credit spreads
Corporate finance
01Interest, compounding and discounting02Annuities, perpetuities and loan amortization03Net present value and internal rate of return04The weighted average cost of capital05Capital structure and the Modigliani–Miller theorems06Discounted cash flow valuation07Relative valuation with multiples08Real options: the value of flexibility
Stochastic models
01Random walks and Brownian motion02Probability spaces, σ-algebras and random variables03Filtrations, adapted processes and stopping times04Conditional expectation and martingales05Properties of Brownian motion06The reflection principle and first passage times07The Brownian bridge08The Itô integral09Itô's lemma10Kolmogorov equations and the Feynman–Kac formula11Change of measure and Girsanov's theorem12Monte Carlo option pricing13Simulating SDEs: the Euler–Maruyama scheme14Mean reversion: Ornstein–Uhlenbeck and Vasicek15Jumps and the Merton jump-diffusion model
Knowledge graph

© 2026 Quant Sandbox · A study aid for quantitative finance

Privacy & dataNo cookies

This site does not use cookies and asks for no personal data. It keeps a few small settings in your browser's local storage — your chosen theme and language, the sidebar layout, and your progress and answers in the Guides — so it remembers them on your next visit. This data never leaves your device; clearing your browser storage removes it. Inputs you change can also be captured in the page URL, so you can share or bookmark a specific setup. The site uses Vercel Web Analytics, a privacy-friendly, cookieless service that records only anonymous, aggregated usage (such as page views) without identifying you or tracking you across other sites.

Guide/Fixed income

Immunization and duration matching

Lesson 3 of 8 · 1 min read

"Duration and convexity" measured how much a single bond's price moves when its yield changes. This lesson turns that measurement into a hedge. An investor who owes a fixed amount at a fixed date can choose bonds whose value tracks the value of the debt, so that a change in interest rates hurts neither side more than the other. The notation is the one from "Bond prices and yields": face value F=100F = 100F=100, annual coupons, yields with annual compounding, Macaulay duration DDD and convexity CCC. Throughout, the yield curve is flat and moves in parallel.

A fixed liability

A pension fund must pay L=1 000 000L = 1\,000\,000L=1000000 in exactly 7 years. At a flat yield of y=5%y = 5\%y=5% the present value of this liability is

PVL=L(1+y)7=1 000 0001.057≈710 681.PV_L = \frac{L}{(1+y)^{7}} = \frac{1\,000\,000}{1.05^{7}} \approx 710\,681.PVL​=(1+y)7L​=1.0571000000​≈710681.

The liability is a zero-coupon payment, so its duration is its maturity, DL=7D_L = 7DL​=7, and its convexity is CL=7⋅8/1.052≈50.79C_L = 7 \cdot 8/1.05^2 \approx 50.79CL​=7⋅8/1.052≈50.79. The fund holds bonds worth exactly PVLPV_LPVL​ today. The difference between the value of its bonds and PVLPV_LPVL​ is its surplus; the aim is to keep it from turning negative when rates move.

Price risk and reinvestment risk

A rise in yields does two things to a bond portfolio held for HHH years. The bonds' market value falls at once (price risk), but every coupon received before HHH is reinvested at the higher rate (reinvestment risk works in the holder's favour). A fall in yields does the opposite. The value at the horizon of a portfolio worth P(y)P(y)P(y) today is VH=P(y) (1+y)HV_H = P(y)\,(1+y)^{H}VH​=P(y)(1+y)H, and its sensitivity to the yield is

dln⁡VHdy=P′(y)P(y)+H1+y=H−D1+y,\frac{d \ln V_H}{dy} = \frac{P'(y)}{P(y)} + \frac{H}{1+y} = \frac{H - D}{1+y},dydlnVH​​=P(y)P′(y)​+1+yH​=1+yH−D​,

using P′/P=−D/(1+y)P'/P = -D/(1+y)P′/P=−D/(1+y) from the previous lesson. When the holding period equals the duration, H=DH = DH=D, the two effects cancel to first order: a small parallel shift leaves the horizon value unchanged.

Matching present value and duration

This gives the recipe called immunization. Choose assets such that

PVA=PVLandDA=DL,PV_A = PV_L \qquad \text{and} \qquad D_A = D_L,PVA​=PVL​andDA​=DL​,

where DAD_ADA​ is the value-weighted average of the bonds' durations. With two bonds, a short one with duration DSD_SDS​ and a long one with duration DLgD_{Lg}DLg​, put the share www of the money into the short bond and 1−w1 - w1−w into the long one. The duration condition w DS+(1−w) DLg=DLw\,D_S + (1-w)\,D_{Lg} = D_LwDS​+(1−w)DLg​=DL​ gives

w=DLg−DLDLg−DS.w = \frac{D_{Lg} - D_L}{D_{Lg} - D_S}.w=DLg​−DS​DLg​−DL​​.

Immunization: hold assets with the same present value and the same duration as the liability. Then a small parallel shift in yields changes both values by the same amount.

A worked example

Use a 2-year and a 12-year bond, both with a 5% coupon, so both trade at par at y=5%y = 5\%y=5%. Their durations are DS≈1.952D_S \approx 1.952DS​≈1.952 and DLg≈9.306D_{Lg} \approx 9.306DLg​≈9.306, hence

w=9.306−79.306−1.952≈0.3136.w = \frac{9.306 - 7}{9.306 - 1.952} \approx 0.3136.w=9.306−1.9529.306−7​≈0.3136.

The fund buys 222 888 of the 2-year bond and 487 793 of the 12-year bond, together 710 681, and its asset duration is exactly 7. Now shift every yield by the same amount and reprice everything:

  • Δy=−1%\Delta y = -1\%Δy=−1%: assets and liability both rise by about 49 200; the surplus is +747+747+747.
  • Δy=+1%\Delta y = +1\%Δy=+1%: both fall by about 45 600; the surplus is +642+642+642.
  • Δy=±3%\Delta y = \pm 3\%Δy=±3%: the surplus is +7 861+7\,861+7861 and +4 985+4\,985+4985.

Compare the two unhedged choices. With everything in the 2-year bond, a 1% fall in yields leaves a deficit of 35 832, because the bond barely gains while the liability rises sharply. With everything in the 12-year bond, a 1% rise leaves a deficit of 13 958.

The same two bonds can immunize a different liability. Try 500 000 due in 5 years, still at a flat 5%.

Worked example

Immunizing a five-year liability with the 2-year and 12-year bonds

  1. Present value of the liability.

    PVL=500 0001.055\displaystyle PV_L = \frac{500\,000}{1.05^{5}}PVL​=1.055500000​=391,763
  2. Share of the money in the 2-year bond, using DS≈1.952D_S \approx 1.952DS​≈1.952 and DLg≈9.306D_{Lg} \approx 9.306DLg​≈9.306.

    w=DLg−DLDLg−DS\displaystyle w = \frac{D_{Lg} - D_L}{D_{Lg} - D_S}w=DLg​−DS​DLg​−DL​​=0.5856
  3. Amount invested in the 2-year bond.

    w⋅PVL\displaystyle w \cdot PV_Lw⋅PVL​=229,411
  4. Amount invested in the 12-year bond.

    (1−w)⋅PVL\displaystyle (1 - w) \cdot PV_L(1−w)⋅PVL​=162,352

A shorter liability needs more of the short bond: 59% of the money instead of 31%.

Why the surplus stays positive

Duration matching removes the first-order term of the surplus. The second-order term comes from the difference in convexity:

ΔS≈12 (CA−CL) PVL (Δy)2.\Delta S \approx \tfrac{1}{2}\,(C_A - C_L)\,PV_L\,(\Delta y)^2.ΔS≈21​(CA​−CL​)PVL​(Δy)2.

A barbell of a short and a long bond spreads its cash flows around the liability date, which gives it more convexity than a single payment at year 7: here CA≈70.27C_A \approx 70.27CA​≈70.27 against CL≈50.79C_L \approx 50.79CL​≈50.79. The formula predicts a surplus of about 692 for a 1% move in either direction, close to the exact 747 and 642. As long as CA≥CLC_A \ge C_LCA​≥CL​, any small parallel shift leaves a non-negative surplus. The protection is only as good as that assumption: if short and long yields move by different amounts, the barbell can lose.

Rebalancing

An immunized position does not stay immunized on its own. If yields stay where they are, every duration shortens by one year per year and the match survives. When yields move, the durations of the two bonds change by different amounts, while the liability's does not: after a 1% rise the asset duration is 6.796, after a 1% fall it is 7.205, against DL=7D_L = 7DL​=7 in both cases. The fund has to re-solve for www and trade back to the target, and in practice it does so periodically rather than continuously.

In the figure the portfolio holds the face amounts fixed at the start. Drag the shock marker along the track, or use the arrow keys, to shift all yields by up to 300 basis points either way. The two bars show the present values of the assets and of the liability, and the readouts give the surplus and both durations. The small chart below plots the surplus against the shock; the stretches you have dragged across are highlighted. With the duration-matched portfolio the curve is a shallow U that never drops below zero. Switch to "All in the short bond" or "All in the long bond" and the same drag opens a deficit on one side.

Immunization: a yield shock on assets and liabilityOpen in Duration & Convexity →
Drag the shock marker, or use the arrow keys.
Yield shock
0 bp
−300 bp0+300 bp
PV of assets
710 681
PV of liability
710 681
Surplus against the shock (the part you have visited is highlighted)
−300 bp0+300 bp
PV of assets
710 681
PV of liability
710 681
Surplus
+0
Duration: assets / liability
7.00 / 7.00

Summary

  • A fixed liability is a zero-coupon payment: its duration is its maturity.
  • Over a horizon equal to the duration, price risk and reinvestment risk cancel to first order.
  • Immunization matches present value and duration; with two bonds, the weight follows from w DS+(1−w) DLg=DLw\,D_S + (1-w)\,D_{Lg} = D_LwDS​+(1−w)DLg​=DL​.
  • With asset convexity at least that of the liability, small parallel shifts leave a non-negative surplus; non-parallel moves are not covered.
  • Durations drift as yields move, so the position must be rebalanced.

The next lesson, "Spot rates, forward rates and the yield curve", drops the flat curve and lets yields differ by maturity, which is what immunization against parallel shifts leaves exposed.

Try itCompare durations and convexities of bonds in the Duration & Convexity lab →
2 questions on this lesson at the end of the series →
← PreviousDuration and convexityNext →Spot rates, forward rates and the yield curve
Connections
Immunization and duration matching
Open the full graph →
Labs for this lesson
Duration & ConvexityBond Lab