Implementation:Avhz RustQuant NelsonSiegel
| Knowledge Sources | |
|---|---|
| Domains | Stochastic_Processes, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete implementation of the Nelson-Siegel (1987) yield curve model provided by the RustQuant library.
Description
The Nelson-Siegel model is a parsimonious, parametric model for fitting the yield curve. The spot rate at maturity tau is given by:
r(tau) = beta0 + beta1 * [(1 - e^(-tau/lambda)) / (tau/lambda)] + beta2 * [(1 - e^(-tau/lambda)) / (tau/lambda) - e^(-tau/lambda)]
where:
- beta0 controls the long-term level (asymptotic rate)
- beta1 controls the short-term component (slope)
- beta2 controls the medium-term component (curvature/hump)
- lambda controls the decay rate (position of the hump)
Key parameters:
- beta0 (f64) -- Long-term level
- beta1 (f64) -- Short-term slope factor
- beta2 (f64) -- Medium-term curvature factor
- lambda (f64) -- Decay parameter
Usage
Use this model for yield curve fitting and interpolation with a small number of parameters. The Nelson-Siegel model captures the typical shapes observed in yield curves (upward sloping, flat, humped, inverted). This struct defines the parameters; it does not implement the CurveModel trait directly (see NelsonSiegelSvensson for a full implementation).
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_stochastics/src/nelson_siegel.rs
- Lines: 1-36
Signature
pub struct NelsonSiegel {
pub beta0: f64,
pub beta1: f64,
pub beta2: f64,
pub lambda: f64,
}
impl NelsonSiegel {
pub const fn new(beta0: f64, beta1: f64, beta2: f64, lambda: f64) -> Self
}
Import
use RustQuant::stochastics::NelsonSiegel;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| beta0 | f64 | Yes | Long-term level (asymptotic rate) |
| beta1 | f64 | Yes | Short-term slope factor |
| beta2 | f64 | Yes | Medium-term curvature factor |
| lambda | f64 | Yes | Decay parameter controlling hump position |
Outputs
| Name | Type | Description |
|---|---|---|
| NelsonSiegel | struct | The parameterized Nelson-Siegel model instance |
Usage Examples
use RustQuant::stochastics::NelsonSiegel;
// Create a Nelson-Siegel model
let ns = NelsonSiegel::new(0.0806, -0.0031, -0.0625, 1.58);
// Access parameters directly
let long_term_rate = ns.beta0; // 0.0806
let slope = ns.beta1; // -0.0031
let curvature = ns.beta2; // -0.0625
let decay = ns.lambda; // 1.58