Yield Curve¶
quantflow.rates.yield_curve.YieldCurve
pydantic-model
¶
Bases: BaseModel, ABC
Abstract base class for yield curves
instanteous_forward_rate
abstractmethod
¶
Calculate the instantaneous forward rate for a given time to maturity
The instantaneous forward rate is related to discount factor by the following formula:
where \(D(\tau)\) is the discount factor for a given time to maturity \(\tau\).
Source code in quantflow/rates/yield_curve.py
discount_factor
abstractmethod
¶
Calculate the discount factor for a given time to maturity
The discount factor is related to the instantaneous forward rate by the following formula:
where \(f(\tau)\) is the instantaneous forward rate for a given time to maturity \(\tau\).
Source code in quantflow/rates/yield_curve.py
quantflow.rates.nelson_siegel.NelsonSiegel
pydantic-model
¶
Bases: YieldCurve
Class representing a Nelson-Siegel yield curve
The Nelson-Siegel model is a popular parametric model for fitting the term structure of interest rates. It is defined by the following formula for the instantaneous forward rate:
where \(\tau\) is the time to maturity, \(\beta_1\) is the level parameter, \(\beta_2\) is the slope parameter, \(\beta_3\) is the curvature parameter and \(\lambda\) is the decay factor.
Fields:
instanteous_forward_rate
¶
Source code in quantflow/rates/nelson_siegel.py
discount_factor
¶
Calculate the discount factor for a given time to maturity.
The discount factor is calculated using the formula:
Source code in quantflow/rates/nelson_siegel.py
fit
classmethod
¶
Fit a Nelson-Siegel curve to observed zero-coupon rates.
Uses a profile OLS approach: for each candidate \(\lambda\) the betas are solved exactly via least squares, so only a 1-D scalar minimisation over \(\lambda\) is needed.
| PARAMETER | DESCRIPTION |
|---|---|
ttm
|
times to maturity in years (1-D, length >= 3)
TYPE:
|
rates
|
observed zero-coupon rates, same length as ttm
TYPE:
|
lambda_bounds
|
search bounds for the decay parameter \(\lambda\)
TYPE:
|