Fitted Bond Curve
Fits the US Treasury zero-coupon curve to the prices of every Treasury note and bond on a day, from the Treasury’s FedInvest prices: the term structure the bonds themselves imply, with each bond’s residual showing whether it is rich (priced above the curve) or cheap (below it), the relative value view of a bond desk.
Where get_zero_coupon_curve bootstraps the dozen constant maturity par yields of the Treasury’s own curve, this takes the roughly 330 notes and bonds themselves, so the curve reflects what trades.
The curve minimizes the weighted squared differences between the bonds’ prices and their prices on the curve, with weights inversely proportional to duration, as Gürkaynak, Sack and Wright (2007) fit the Federal Reserve’s Treasury curve. A price error is about the duration times the price times the yield error, so the weights reduce the weight of the long bonds’ larger price errors, while still giving a basis point of a long bond more weight than one of a short bond (equal weight in yield would need \(1 / D^{2}\)).
The formula is as follows:
\[\min \Sigma_{i} w_{i} (P_{i}^{\text{model}} - P_{i})^{2},\;\; \text{with}\;\; P_{i}^{\text{model}} = \Sigma_{k} \text{CF}_{\text{ik}} d(t_{ik})\;\;\text{and}\;\; w_{i} = \frac{1}{D_{i}}\]where \(P_{i}\) is the clean price plus accrued interest of bond i, \(\text{CF}_{ik}\) its coupons and principal at times \(t_{ik}\) (actual days / 365 from the price date, on its actual coupon dates), \(D_{i}\) its modified duration and d(t) the discount function of the method:
- Svensson: \(d (t) = e^{- y (t) t}\), with y(t) the Svensson (1994) zero rate \(\beta_{0} + \beta_{1} (1 - e^{- t / \tau_{1}}) / (t / \tau_{1}) + \beta_{2} [(1 - e^{- t / \tau_{1}}) / (t / \tau_{1}) - e^{- t / \tau_{1}}] + \beta_{3} [(1 - e^{- t / \tau_{2}}) / (t / \tau_{2}) - e^{- t / \tau_{2}}]\), the model of the Federal Reserve’s curve (Gürkaynak, Sack and Wright, 2007)
- Nelson-Siegel: the same without \(\beta_{3}\) (Nelson and Siegel, 1987)
- Exponential spline: \(d (t) = \sum_{k = 1}^{9} a_{k} e^{- k \kappa t}\) with \(\sum a_{k} = 1\), the exponential basis of Vasicek and Fong (1982)
- Cubic spline: d(t) a cubic spline with \(d (0) = 1\) and about \(\sqrt{n}\) basis functions for n bonds, with knots at quantiles of the maturities so that as many bonds mature between every two knots (McCulloch, 1975)
The Nelson-Siegel and Svensson fits are a bounded nonlinear least squares from fixed starts (the model fitted to the bonds’ yields at their durations, and its betas with first decays of 0.5, 1, 2 and 5 years), with the bounds of get_nelson_siegel_svensson; a fit whose parameters are not identified (a flat ridge of equally good fits) raises an error rather than return an arbitrary point on it. The splines are linear in their coefficients and fitted exactly. As Gürkaynak, Sack and Wright do, bills, TIPS, floating rate notes and notes and bonds within three months of maturity are left out. Each day uses its own prices only. For prices of your own, use fitted_curve_model.fit_bond_curve.
The fitted zero rates are annually compounded, like those of get_zero_coupon_curve, while the models are fitted on continuously compounded rates, so the betas compare with the Federal Reserve’s; the instantaneous forward rate is continuously compounded. Yields of the bonds are bond-equivalent (compounded twice a year), as the Treasury quotes them.
Also known as: fitted yield curve, Treasury curve fitting, rich cheap analysis, bond relative value, Svensson curve on bond prices, spline curve.
Example
Install the Finance Toolkit with pip install financetoolkit -U, then call get_fitted_bond_curve:
from financetoolkit import FixedIncome
fixedincome = FixedIncome()
fixedincome.get_fitted_bond_curve(date="2026-11-05")
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
What zero rates, discount factors and forward rates does a curve fitted to the US Treasury bond prices of 5 November 2026 give from half a year to 30 years?
Which returns:
| Maturity | Zero Rate | Discount Factor | Instantaneous Forward Rate |
|---|---|---|---|
| 0.5 | 0.0428 | 0.9792 | 0.0435 |
| 1.0 | 0.0441 | 0.9577 | 0.0451 |
| 2.0 | 0.0455 | 0.9149 | 0.0460 |
| 3.0 | 0.0460 | 0.8738 | 0.0460 |
| 5.0 | 0.0466 | 0.7964 | 0.0472 |
| 7.0 | 0.0475 | 0.7225 | 0.0504 |
| 10.0 | 0.0496 | 0.6162 | 0.0555 |
| 20.0 | 0.0549 | 0.3432 | 0.0578 |
| 30.0 | 0.0546 | 0.2032 | 0.0461 |
9 rows
Parameters
get_fitted_bond_curve accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
method | str | The discount function. Options are: “svensson” (the Nelson-Siegel-Svensson zero rate), “nelson_siegel” (the Nelson-Siegel zero rate), “exponential_spline” (the exponential spline of Vasicek and Fong), “cubic_spline” (McCulloch’s cubic spline). Defaults to “svensson”. | "svensson" |
maturities | float | str | list | None | The maturities to return the curve at, in years or as labels such as ‘6M’ (a list or a comma-separated string). Defaults to None, 6 months and 1, 2, 3, 5, 7, 10, 20 and 30 years. | ["3M", "6M"] |
date | str | None | The day of the prices (YYYY-MM-DD); a weekend or holiday uses the business day before it. Defaults to None, the latest day with prices. | "2025-03-31" |
residuals | bool | Whether to return every bond with its price and yield on the curve and its residuals instead of the curve. Defaults to False. | False |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the class. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper McCulloch, J.H. (1975). “The Tax-Adjusted Yield Curve.” The Journal of Finance, 30(3), 811-830.
- Paper Vasicek, O.A. and Fong, H.G. (1982). “Term Structure Modeling Using Exponential Splines.” The Journal of Finance, 37(2), 339-348.
- Paper Nelson, C.R. and Siegel, A.F. (1987). “Parsimonious Modeling of Yield Curves.” The Journal of Business, 60(4), 473-489.
- Paper Svensson, L.E.O. (1994). “Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994.” NBER Working Paper 4871.
- Paper Gürkaynak, R.S., Sack, B. and Wright, J.H. (2007). “The U.S. Treasury Yield Curve: 1961 to the Present.” Journal of Monetary Economics, 54(8), 2291-2304.
- Library Shares similar logic as QuantLib’s FittedBondDiscountCurve
- Library Shares similar logic as QuantLib’s SvenssonFitting (svensson)
- Library Shares similar logic as QuantLib’s NelsonSiegelFitting (nelson_siegel)
- Library Shares similar logic as QuantLib’s ExponentialSplinesFitting (exponential_spline)
- Library Shares similar logic as QuantLib’s CubicBSplinesFitting (cubic_spline)