Implementation:Avhz RustQuant Hull White Bond Pricing
| Knowledge Sources | |
|---|---|
| Domains | Fixed_Income, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Implements zero-coupon bond pricing under the Hull-White short-rate model, a one-factor model with time-dependent mean reversion and constant volatility.
Description
The HullWhite struct models the risk-neutral short rate dynamics according to:
dr = (theta(t) - a * r_t)dt + sigma * dW_t
where theta(t) is a time-dependent drift function that allows the model to fit the initial term structure exactly, a is the mean-reversion speed, r_t is the current short rate, and sigma is the constant diffusion coefficient.
The implementation computes the bond price analytically via the functions A() and B(). The B() function computes the standard mean-reversion factor (1/a)(1 - exp(-a)). The A() function involves numerical integration of the theta function over the interval [t, T] and additional variance correction terms. Time to maturity (tau) is computed using the default day count convention. The final bond price is given by A() * exp(-B() * r_t).
Note that the current implementation has a TODO indicating that the B() and A() functions should be made dependent on t and T explicitly.
Usage
Use this struct when pricing zero-coupon bonds under the Hull-White model. It is especially useful when you need a model that can be calibrated to match an observed yield curve through the time-dependent theta function.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_instruments/src/bonds/hull_white.rs
- Lines: 1-117
Signature
pub struct HullWhite {
a: f64,
theta_t: fn(f64) -> f64,
sigma: f64,
r_t: f64,
pub evaluation_date: Option<Date>,
pub expiration_date: Date,
}
impl HullWhite {
fn B(&self) -> f64;
fn A(&self) -> f64;
fn tau(&self) -> f64;
}
impl Instrument for HullWhite {
fn price(&self) -> f64;
fn error(&self) -> Option<f64>;
fn valuation_date(&self) -> Date;
fn instrument_type(&self) -> &'static str;
}
Import
use RustQuant::instruments::bonds::hull_white::HullWhite;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| a | f64 | Yes | Mean-reversion speed (must be > 0) |
| theta_t | fn(f64) -> f64 | Yes | Time-dependent drift function theta(t) |
| sigma | f64 | Yes | Constant diffusion coefficient (volatility) |
| r_t | f64 | Yes | Current short rate at time t |
| evaluation_date | Option<Date> | No | Valuation date; defaults to today if None |
| expiration_date | Date | Yes | Maturity date of the zero-coupon bond |
Outputs
| Name | Type | Description |
|---|---|---|
| price() | f64 | The zero-coupon bond price under the Hull-White model |
| error() | Option<f64> | Always returns None (analytic solution) |
| valuation_date() | Date | Returns evaluation_date or today |
| instrument_type() | &'static str | Returns "Zero Coupon Bond" |
Usage Examples
use RustQuant::instruments::bonds::hull_white::HullWhite;
use RustQuant::instruments::Instrument;
use RustQuant::time::today;
let hw_bond = HullWhite {
a: 2.0,
theta_t: |_x| 0.5,
sigma: 0.3,
r_t: 0.05,
evaluation_date: None,
expiration_date: today() + time::Duration::days(365 * 10),
};
let bond_price = hw_bond.price();