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