Filling the gaps between quotes
The Treasury quotes ten maturities and everything else is interpolated. scipy.interpolate offers the standard tools. np.interp joins the quotes with straight lines: it is simple and never overshoots, but its slope jumps at every quote. CubicSpline(x, y, bc_type='natural') joins them with a smooth curve whose first and second derivatives are continuous; the price of smoothness is that it can overshoot between quotes and, outside the quoted range, it runs away, so it should not be extrapolated. PchipInterpolator(x, y) is smooth too but preserves the shape: where the data rise, it rises, so it cannot invent a hump. All three pass through every quote; they differ in between, and in what they do to everything derived from the curve.
The differences matter because derived quantities amplify them. A discount factor is D(t)=e^(-y(t) t/100), and the forward rate between two dates is the slope of its logarithm, f=-Δln D/Δt×100. A small kink in the yield becomes a visible jump in the forward. On 9 October 2026 the 15-year yield is 5.445% by linear interpolation, 5.464% by a natural cubic spline and 5.493% by PCHIP, and the largest jump between neighbouring forwards on a 120-point grid is 0.91 points for the linear curve and about 0.21 for the splines. On the inverted curve of 3 January 2000 the splines' forwards dip to 4.76% and 4.63% while the linear ones stay at 5.63%. There is no best method, only a choice to make on purpose: smooth forwards for pricing, shape preservation for risk, plain lines when you must not invent anything.
- All three pass through the quotes: they differ between them and in the forwards they imply.
- Forwards are the slope of log discount factors: any kink in the yield shows up as a jump.
- Do not extrapolate a cubic spline: use it between the quotes and nowhere else.
Lab · what's graded
- Three interpolations20 pts
- Discount factors10 pts
- The forward curve20 pts
- Roughness10 pts
- Comparing the methods15 pts
- One real day25 pts