Nelson-Siegel and Svensson yield curves
Zero yields, forward rates and par yields of Nelson-Siegel and Svensson curves, and least-squares fits of either curve to observed yields.
- Model id
fixed_income.curve_fitting, version 1- Domain
- Fixed income
- Evidence
- standard
- Cost class
- heavy: Estimation or simulation; a hosted run may take up to 30 seconds.
Formula
Where
- Zero-coupon yield at maturity n
zero_yields - Maturity, in years
maturities - Level: the yield at very long maturities
beta0 - Slope: the short end less the long end
beta1 - Curvature: the size of the first hump
beta2 - The size of the second hump (Svensson)
beta3 - Where the first hump sits, in years
tau1 - Where the second hump sits, in years (Svensson)
tau2 - The loading of the slope term at decay k
- Instantaneous forward rate at maturity n
forward_rates - Discount factor at maturity n
discount_factors - Par yield at maturity n
par_yields - Accrual fraction of coupon period i
- Time of coupon i, in years
- The fitted yield at the k-th maturity
fitted_yields - The observed yield at the k-th maturity
yields
Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.
Variables
Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.
Inputs
Yields, forwards and par yields of given parameters (evaluate): 9 inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Yields, forwards and par yields of given parameters | |
Beta0beta0ratio · [-10000, 10000] | ratio | [-10000, 10000] | The long-run level: the yield as maturity grows |
Beta1beta1ratio · [-10000, 10000] | ratio | [-10000, 10000] | The slope: beta0 + beta1 is the instantaneous short rate |
Beta2beta2ratio · [-10000, 10000] | ratio | [-10000, 10000] | The first hump's size |
Beta3beta3ratio · [-10000, 10000] | ratio | [-10000, 10000] | The second hump's size (Svensson); 0 for Nelson-Siegel |
Tau1tau1years · [0.001, 200] | years | [0.001, 200] | The first decay, in years (GSW's TAU1) |
Tau2tau2years · [0.001, 200] | years | [0.001, 200] | The second decay, in years (Svensson); omitted for Nelson-Siegel |
Maturitiesmaturitiesyears (array) · length min 1, max 360; each (0, 100] | years (array) | length min 1, max 360; each (0, 100] | Maturities to evaluate, in years |
Coupon frequencycoupon_frequencytext | text | Coupons a year of the par bonds a par yield describes |
Fit a curve to observed yields by least squares (fit): 6 inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Fit a curve to observed yields by least squares | |
Maturitiesmaturitiesyears (array) · length min 4, max 60; each (0, 100] | years (array) | length min 4, max 60; each (0, 100] | Maturity of each observed yield, in years, increasing |
Yieldsyieldsrate (array) · length min 4, max 60; each [-0.1, 1] | rate (array) | length min 4, max 60; each [-0.1, 1] | The observed yield at each maturity |
Yield typeyield_typetext | text | What the observed yields are: 'par' (coupon rates of bonds priced at par, as Treasury's par curve gives them) or 'zero' (continuously compounded zero-coupon yields) | |
Coupon frequencycoupon_frequencytext | text | Coupons a year of the par bonds a par yield describes | |
Formformtext | text | The curve to fit: 'nelson_siegel' (4 parameters) or 'svensson' (6) |
Outputs
Yields, forwards and par yields of given parameters (evaluate): 6 outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Yields, forwards and par yields of given parameters | |
Maturitiesmaturitiesyears (array) · length max 360; each (0, 100] | years (array) | length max 360; each (0, 100] | The maturities evaluated, in years |
Zero yieldszero_yieldsrate (array) · length max 360; each [-0.99, 10] | rate (array) | length max 360; each [-0.99, 10] | The zero-coupon yield at each maturity, continuously compounded |
Forward ratesforward_ratesrate (array) · length max 360; each [-0.99, 10] | rate (array) | length max 360; each [-0.99, 10] | The instantaneous forward rate at each maturity, continuously compounded |
Par yieldspar_yieldsrate (array) · length max 360; each [-0.99, 10] | rate (array) | length max 360; each [-0.99, 10] | The par yield at each maturity, with coupon_frequency coupons a year |
Discount factorsdiscount_factorsratio (array) · length max 360; each (0, 1e+44] | ratio (array) | length max 360; each (0, 1e+44] | The discount factor to each maturity |
Fit a curve to observed yields by least squares (fit): 10 outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Fit a curve to observed yields by least squares | |
Beta0beta0ratio · [-1, 1] | ratio | [-1, 1] | The fitted long-run level |
Beta1beta1ratio · [-1, 1] | ratio | [-1, 1] | The fitted slope |
Beta2beta2ratio · [-1, 1] | ratio | [-1, 1] | The fitted first hump |
Beta3beta3ratio · [-1, 1] | ratio | [-1, 1] | The fitted second hump; 0 for a Nelson-Siegel fit |
Tau1tau1years · [0.05, 30] | years | [0.05, 30] | The fitted first decay, in years |
Tau2tau2years · [0.05, 30] | years | [0.05, 30] | The fitted second decay, in years; a Nelson-Siegel fit repeats tau1, so the parameters evaluate as a Svensson curve with beta3 = 0 |
Fitted yieldsfitted_yieldsrate (array) · length max 60; each [-0.99, 10] | rate (array) | length max 60; each [-0.99, 10] | The fitted curve's yield at each observed maturity, of the observed type |
RMSErmserate · [0, 10] | rate | [0, 10] | Root mean squared difference of the fitted and observed yields |
Evaluationsevaluationscount · [0, 8528] | count | [0, 8528] | Evaluations of the residuals across every start |
Calculator
Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.
Loading the calculator…
Worked example
A Svensson curve evaluated at ten maturities.
Example svensson_curve. Inputs:
{
"beta0": 0.045,
"beta1": -0.01,
"beta2": -0.02,
"beta3": 0.015,
"calculation": "evaluate",
"coupon_frequency": "semiannual",
"maturities": [0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30],
"tau1": 1.5,
"tau2": 9
}Outputs:
{
"calculation": "evaluate",
"discount_factors": [
0.9914118754083311,
0.983035546977096,
0.966430187508788,
0.9321289781871325,
0.8956240251692664,
0.8189890946359901,
0.7434323830721982,
0.6398690110848921,
0.3895119901834118,
0.24192422656551854
],
"forward_rates": [
0.03411882886692362,
0.03384611104785915,
0.03451166608393013,
0.03800389627881271,
0.041815892391038306,
0.047046272349522585,
0.04938826648343131,
0.05030413895193972,
0.048611819352283994,
0.04678369882228964
],
"maturities": [0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30],
"par_yields": [
0.0346500775497841,
0.03451442437675999,
0.034440012868515675,
0.035431223456410116,
0.03700686640224473,
0.040080078703741785,
0.042343574132422825,
0.044433643837881044,
0.046677879218381804,
0.04698011533925773
],
"zero_yields": [
0.03450086017854946,
0.034219995524688664,
0.03414621521496301,
0.03514204262928172,
0.036744856278854085,
0.03993690213609814,
0.042353923043343455,
0.044649179375607514,
0.04714303153095239,
0.047304357174043375
]
}Assumptions
- Zero yields and forward rates are continuously compounded; the betas are decimals, so the Board's and the ECB's percent parameters are divided by 100.
- Par yields pay coupon_frequency coupons a year, counted back from maturity, with a short first period when the maturity is not a whole number of periods; Treasury's par curve is semiannual.
- A fit weighs every observed yield equally. Its decays are searched in [0.05, 30] years and its betas in [-1, 1]; it scores a fixed grid of 48 decays (Svensson pairs at least 1.5 apart as a ratio) by linear least squares against the zero curve the observed yields imply, refines the eight best jointly and keeps the lowest sum of squares.
- Profile: default binds the evaluate calculation to the Board's GSW parameters on the date and the fit calculation to Treasury's par curve on the date (its last curve on or before it, the tenors it publishes).
Limitations
- The parameters of a fit are not unique: different betas and decays can give nearly the same yields, so compare fitted yields, not parameters. A fit is local; the grid of starts makes it reproducible, not certainly global. A second hump the maturities cannot identify (beta3 near zero, or tau2 near the longest maturity, where the hump is nearly a straight line) can leave a Svensson fit a few tenths of a basis point from the best.
- A curve whose yields, forwards or par yields fall outside [-0.99, 10] at a maturity or a coupon date raises DomainError, as does one that discounts past the smallest float (a yield times its maturity above 700) and a fit no start of which reaches finite yields.
- A fit stops after 200 evaluations a start; one that stopped before its tolerances were met warns fit_not_converged.
- The GSW file gives Nelson-Siegel parameters only before 1980 (no BETA3 or TAU2), so a bind of the evaluate calculation at such a date raises: supply beta0 to tau1 instead.
Evidence
Status: standard. Textbook consensus, such as bond duration or the CAPM formula.
Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).
Syllabus
The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.
Data
This model can read its data for you: each bound field names a data series, and the sources listed can fill it, in the order they are tried. This website reads only the sources whose terms let it serve their data (marked "hosted"); every source is available when you run pyeconomics on your own computer.
| Field | Concept | Read as | Sources (licence class; hosted) |
|---|---|---|---|
beta0 | Gürkaynak-Sack-Wright curve: level (beta0)us.treasury.gsw_beta0 | last observation on or before the date; real time: as published by the date |
|
beta1 | Gürkaynak-Sack-Wright curve: slope (beta1)us.treasury.gsw_beta1 | last observation on or before the date; real time: as published by the date |
|
beta2 | Gürkaynak-Sack-Wright curve: first hump (beta2)us.treasury.gsw_beta2 | last observation on or before the date; real time: as published by the date |
|
beta3 | Gürkaynak-Sack-Wright curve: second hump (beta3)us.treasury.gsw_beta3 | last observation on or before the date; real time: as published by the date |
|
tau1 | Gürkaynak-Sack-Wright curve: first decay (tau1)us.treasury.gsw_tau1 | last observation on or before the date; real time: as published by the date |
|
tau2 | Gürkaynak-Sack-Wright curve: second decay (tau2)us.treasury.gsw_tau2 | last observation on or before the date; real time: as published by the date |
|
yieldstenors in maturities | Treasury par yield curveus.treasury.par_curve | the curve on or before the date: its last row, a value per tenor; real time: as published by the date |
|
Citations
- Nelson, C. R. and Siegel, A. F. (1987). Parsimonious Modeling of Yield Curves. Journal of Business, 60(4), 473-489. doi:10.1086/296409 (The three-component forward-rate curve and its yield curve)
- Svensson, L. E. O. (1994). Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994. NBER Working Paper 4871. doi:10.3386/w4871 (The extended Nelson-Siegel forward curve with a second hump)
- 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. doi:10.1016/j.jmoneco.2007.06.029 (The Svensson zero, forward and par yields of the Board's daily file)
- European Central Bank. Euro area yield curves: technical notes and the published Svensson parameters. https://www.ecb.europa.eu/stats/financial_markets_and_interest_rates/euro_area_yield_curves/html/index.en.html (The Svensson model of the AAA and all-government curves)
Changelog
- Version 1: First version.
Use it elsewhere
- Documentation
- The model's reference page
- REST API
GET or POST /v1/models/fixed_income.curve_fitting/run- MCP tool
run_modelwith the model's id,fixed_income.curve_fitting. Connect an assistant- Command line
pyeconomics models run fixed_income.curve_fitting --help
The worked example, from Python and from the command line:
import pyeconomics
inputs = {
"beta0": 0.045,
"beta1": -0.01,
"beta2": -0.02,
"beta3": 0.015,
"calculation": "evaluate",
"coupon_frequency": "semiannual",
"maturities": [0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30],
"tau1": 1.5,
"tau2": 9,
}
result = pyeconomics.run("fixed_income.curve_fitting", inputs)
print(result.to_json())
pyeconomics models run fixed_income.curve_fitting --inputs - <<'JSON'
{
"beta0": 0.045,
"beta1": -0.01,
"beta2": -0.02,
"beta3": 0.015,
"calculation": "evaluate",
"coupon_frequency": "semiannual",
"maturities": [0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30],
"tau1": 1.5,
"tau2": 9
}
JSON