Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceProbability & MeasureStochastic ModelsMarket MicrostructureGuide
Fixed Income
Bond Lab
Yield Curve
LabRates desk
Duration & Convexity
Treasury Futures Lab
Interest Rate Swap Lab
Callable Bond Lab
Immunization Lab
LabALM desk
Connected Guides
  • Immunization and duration matching
  • Duration and convexity

© 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.

Immunization Lab

Fund a liability: match present value and duration, then keep the portfolio matched as rates move.

Fund a liability of 1,000,000 due in 8 years. Every year a rate shock hits and time passes; rebalance to stay funded, but every trade costs money.

Portfolio

Drag a bar to set its share; the others rescale so the total stays 100%.

The mix is unchanged: no trade, no cost.

Assets vs liability

Present valueMatched
Assets676,839
Liability676,839
Duration (years)Matched
Assets7.62
Liability7.62
Convexity
Assets79.11
Liability65.31
Round 0 of 8No shock yet: the first round brings the first one.
Random seed: 1
Surplus over the years
Never rebalancedAuto-immunisedYou

A twist moves long yields one way and short yields the other, which a parallel-shock hedge does not cover.

About this tool

Immunization funds a known future liability with bonds so that interest-rate moves do not open a funding gap. Match the present value and the duration of the assets to the liability, and the surplus barely reacts to a parallel shift in yields. Over the years the match drifts as time passes and the curve moves, so you rebalance, at a cost. This lab plays that as a game: each round brings a seeded rate shock, and you see why the surplus moved.

Frequently asked questions

What is immunization?

A strategy that holds assets whose present value and duration equal those of a liability. A small parallel move in yields then changes assets and liability by about the same amount, so the surplus stays near zero.

Why does the portfolio need rebalancing?

Duration changes with time and with yields, and the liability's duration shrinks by a year every year while a bond's duration shrinks more slowly. The match therefore drifts, and the portfolio has to be reset to stay immunized.

What does convexity add?

Duration matching covers small moves. For larger moves the second-order term matters: assets with more convexity than the liability gain more when yields fall than they lose when yields rise, so the surplus tends to be positive after large shifts.

What is a twist, and why does it hurt?

A twist moves long and short yields in opposite directions. Duration matching assumes a parallel shift, so a twist can leave a gap even in a perfectly matched portfolio.

Learn the theory

  • Immunization and duration matching — Protecting a liability against rate moves by matching present value and duration, and why convexity and rebalancing matter.
  • Duration and convexity — Macaulay and modified duration, first- and second-order approximations of interest-rate risk.