Skip to content

Fixed income

Spot, par and forward curves

Bootstrap spot rates and discount factors from par yields, par yields from spot rates, and forward rates between maturities.

Model id
fixed_income.curve_bootstrap, version 1
Domain
Fixed income
Evidence
standard
Cost class
instant: A closed-form calculation; a hosted run may take up to 2 seconds.

Formula

dk=1−ckf∑j<kdj1+ckfd_k = \frac{1 - \frac{c_k}{f}\sum_{j<k} d_j}{1 + \frac{c_k}{f}}sk=f(dk−1/k−1),skcont=−fkln⁡dks_k = f\left(d_k^{-1/k} - 1\right), \quad s_k^{\mathrm{cont}} = -\frac{f}{k}\ln d_kck=f 1−dk∑j≤kdjc_k = f\,\frac{1 - d_k}{\sum_{j \le k} d_j}(1+F1,2f)f(T2−T1)=(1+s2/f)fT2(1+s1/f)fT1\left(1 + \frac{F_{1,2}}{f}\right)^{f (T_2 - T_1)} = \frac{(1 + s_2/f)^{f T_2}}{(1 + s_1/f)^{f T_1}}

Where

dkd_k
Discount factor for a payment k periods from now discount_factors
ckc_k
Par yield of the bond maturing in k periods par_yields
ff
Periods in a year frequency
sks_k
Spot rate for k periods, compounded f times a year spot_rates
skconts_k^{\mathrm{cont}}
The same spot rate, continuously compounded
F1,2F_{1,2}
Forward rate between the near and the far date forward_rate
T1T_1
Years to the near date near_years
T2T_2
Years to the far date far_years
s1s_1
Spot rate to the near date near_rate
s2s_2
Spot rate to the far date far_rate

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

Bootstrap spot rates from par yields (from_par): 4 inputs
Inputs of the calculation from_par
NameDescription
CalculationcalculationtextBootstrap spot rates from par yields
Par yieldspar_yieldsrate (array) · length min 1, max 200; each [-0.1, 1]Par yield at each tenor 1/f, 2/f, ... years
FrequencyfrequencytextCoupons per year of the par bonds, and the tenor spacing
CompoundingcompoundingtextHow spot and forward rates compound: at the frequency (periodic) or continuously
Par yields and forwards from spot rates (from_spot): 4 inputs
Inputs of the calculation from_spot
NameDescription
CalculationcalculationtextPar yields and forwards from spot rates
Spot ratesspot_ratesrate (array) · length min 1, max 200; each [-0.1, 1]Spot (zero) rate at each tenor 1/f, 2/f, ... years
FrequencyfrequencytextCoupons per year of the par bonds, and the tenor spacing
CompoundingcompoundingtextHow spot and forward rates compound: at the frequency (periodic) or continuously
Forward rate between two maturities (forward_rate): 7 inputs
Inputs of the calculation forward_rate
NameDescription
CalculationcalculationtextForward rate between two maturities
Near ratenear_raterate · [-0.1, 1]Spot rate to the near maturity
Near yearsnear_yearsyears · [0, 100]Near maturity, in years (0 for now)
Far ratefar_raterate · [-0.1, 1]Spot rate to the far maturity
Far yearsfar_yearsyears · (0, 100]Far maturity, in years
FrequencyfrequencytextCompounding frequency of periodic rates
CompoundingcompoundingtextHow spot and forward rates compound: at the frequency (periodic) or continuously

Outputs

Bootstrap spot rates from par yields (from_par): 5 outputs
Outputs of the calculation from_par
NameDescription
CalculationcalculationtextBootstrap spot rates from par yields
Tenorstenorsyears (array) · length max 200; each (0, 200]Tenor of each point, in years
Discount factorsdiscount_factorsratio (array) · length max 200; each (0, 1e+12]Discount factor at each tenor
Spot ratesspot_ratesrate (array) · length max 200; each [-0.99, 10]Spot (zero) rate at each tenor
Forward ratesforward_ratesrate (array) · length max 200; each [-0.99, 10]Forward rate over each period, ending at its tenor
Par yields and forwards from spot rates (from_spot): 5 outputs
Outputs of the calculation from_spot
NameDescription
CalculationcalculationtextPar yields and forwards from spot rates
Tenorstenorsyears (array) · length max 200; each (0, 200]Tenor of each point, in years
Discount factorsdiscount_factorsratio (array) · length max 200; each (0, 1e+12]Discount factor at each tenor
Par yieldspar_yieldsrate (array) · length max 200; each [-0.99, 10]Par yield at each tenor
Forward ratesforward_ratesrate (array) · length max 200; each [-0.99, 10]Forward rate over each period, ending at its tenor
Forward rate between two maturities (forward_rate): 2 outputs
Outputs of the calculation forward_rate
NameDescription
CalculationcalculationtextForward rate between two maturities
Forward rateforward_raterate · [-0.99, 10]Rate from the near to the far maturity

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

Three years of semiannual par yields.

Example treasury_par_curve. Inputs:

{
  "calculation": "from_par",
  "compounding": "periodic",
  "frequency": "semiannual",
  "par_yields": [0.04, 0.041, 0.042, 0.0425, 0.043, 0.0435]
}

Outputs:

{
  "calculation": "from_par",
  "discount_factors": [
    0.9803921568627451,
    0.960217501993448,
    0.9395173331675025,
    0.9192629634462635,
    0.8989849397527125,
    0.878698650383075
  ],
  "forward_rates": [
    0.040000000000000084,
    0.042021010505252636,
    0.04406553896383517,
    0.04406654140683878,
    0.04511315550876494,
    0.04617348475679015
  ],
  "spot_rates": [
    0.040000000000000084,
    0.041010255101800175,
    0.04202817530050558,
    0.04253757618396721,
    0.04305243242699409,
    0.04357227702336333
  ],
  "tenors": [0.5, 1, 1.5, 2, 2.5, 3]
}

Assumptions

  • The par yields are coupon rates of bonds paying f coupons a year, priced at par on a coupon date, one maturing at each tenor 1/f, 2/f, ... years.
  • Spot and forward rates compound at the frequency, or continuously; a forward rate shares the compounding of the spot rates it comes from.

Limitations

  • Par yields whose bootstrapped discount factor is not positive, and any rate outside [-0.99, 10], raise DomainError.
  • Tenors are regular; interpolating between irregular instruments is out of scope (pyeconomics.core.curves interpolates zero rates).

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.

Citations

  1. Hull, J. C. (2018). Options, Futures, and Other Derivatives, 10th ed. Pearson. https://openlibrary.org/isbn/9780134472089 (Chapter 4 (zero rates, par yields, bootstrapping and forward rates)). ISBN 9780134472089
  2. Fabozzi, F. J. (2005). Fixed Income Mathematics: Analytical and Statistical Techniques, 4th ed. McGraw-Hill. https://openlibrary.org/isbn/9780071460736 (Chapter 7 (the yield curve, spot rate curve and forward rates)). ISBN 9780071460736

Changelog

  • Version 1: First version.

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/fixed_income.curve_bootstrap/run
MCP tool
fixed_income_curve_bootstrap, or run_model with the model's id; both give the same result. Connect an assistant
Command line
pyeconomics models run fixed_income.curve_bootstrap --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "calculation": "from_par",
    "compounding": "periodic",
    "frequency": "semiannual",
    "par_yields": [0.04, 0.041, 0.042, 0.0425, 0.043, 0.0435],
}
result = pyeconomics.run("fixed_income.curve_bootstrap", inputs)
print(result.to_json())
Command line
pyeconomics models run fixed_income.curve_bootstrap --inputs - <<'JSON'
{
  "calculation": "from_par",
  "compounding": "periodic",
  "frequency": "semiannual",
  "par_yields": [0.04, 0.041, 0.042, 0.0425, 0.043, 0.0435]
}
JSON