Drawing a smooth line through a few points
Markets quote a yield curve at a few maturities, such as 2, 3 and 5 years, but you need the value at any maturity, such as 2.5 years. Interpolation fills the gaps between known points. The simplest way is linear: draw a straight line between two neighbours with np.interp or interpolate.interp1d. A cubic spline, interpolate.CubicSpline, joins the points with pieces of cubic curve so that the slope and the curvature also match at every point, and the result looks smooth. A spline can overshoot between points. PchipInterpolator avoids that by never going above or below its neighbours. Inside the known range any of these is fine, but outside it you are extrapolating, which is a guess, and a cubic can then run away.
Which quantity you interpolate matters. Linear interpolation of yields is easy, but finance often interpolates the logarithm of the discount factor instead. With continuous compounding the discount factor is , so . Interpolating this linearly keeps forward rates constant between knots. The forward rate between times and is the rate you can lock in today for that future period: . A smooth, sensible forward curve is the real test of an interpolation.
- Interpolate inside, be careful outside: linear, cubic spline and PCHIP agree inside the data and part ways outside it.
- Choose what to interpolate: the log of the discount factor keeps forward rates steady between knots.
- Check the forward curve: a good interpolation gives sensible forward rates, not just a pretty line through the points.
Lab · what's graded
- A linear interpolation10 pts
- Interpolating the discount factor15 pts
- A forward rate15 pts
- A spline value10 pts
- The right tool15 pts
- Building a curve10 pts
- Why not extrapolate a cubic spline25 pts