Implementation:Avhz RustQuant SABR Model
| Knowledge Sources | |
|---|---|
| Domains | Volatility_Modeling, Option_Pricing, Quantitative_Finance |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
Concrete tool for SABR (2002) stochastic volatility model provided by the RustQuant library.
Description
The Sabr02 struct implements the SABR (Stochastic Alpha Beta Rho) model introduced by Hagan et al. (2002). The SABR model is a stochastic volatility model that produces an analytical approximation for implied Black volatility as a function of strike, which can then be fed into the Black-76 model for option pricing.
The model has five parameters:
f-- Forward price of the underlying.alpha-- Initial volatility level (at-the-money vol parameter).beta-- CEV exponent controlling the backbone of the smile. Special cases: beta=0 (normal model), beta=0.5 (CIR model), beta=1 (lognormal model).rho-- Correlation between the forward price and volatility Brownian motions. Controls skew.nu-- Volatility of volatility. Controls the curvature (smile) of the implied vol surface.
The analytical implied volatility formula involves several components:
- A coefficient term involving the z/chi ratio that handles the strike-dependent adjustment.
- A numerator containing correction terms proportional to time involving alpha, beta, rho, and nu.
- A denominator that accounts for the (F*K) power and log-strike corrections.
The module also provides a calibration capability via the Sabr02Calibrator struct, which implements the argmin::CostFunction trait. Calibration uses Particle Swarm Optimization (PSO) with 100 particles over up to 1000 iterations to fit alpha, rho, and nu to observed market volatilities (beta is held fixed).
Available methods:
volatility-- Computes the SABR implied Black volatility for a given strike and time to expiry.fit-- Calibrates the model (alpha, rho, nu) to a set of market-observed volatilities and strikes using Particle Swarm Optimization.
Usage
Use the SABR model for interpolating and extrapolating the implied volatility smile/surface, particularly in interest rate and FX derivatives markets. It is the industry standard for modeling the volatility smile for European swaptions, caps/floors, and FX options. The calibrated SABR volatilities are typically used as inputs to the Black-76 pricing formula.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_models/src/sabr.rs
- Lines: 1-205
Signature
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Sabr02 {
f: f64, // Forward price
alpha: f64, // Initial volatility
beta: f64, // CEV exponent
rho: f64, // Correlation
nu: f64, // Vol of vol
}
impl Sabr02 {
pub fn new(f: f64, alpha: f64, beta: f64, rho: f64, nu: f64) -> Self;
pub fn volatility(&self, k: f64, t: f64) -> f64;
pub fn fit(
&mut self,
volatilities: &[f64],
strikes: &[f64],
t: f64,
) -> Result<(), argmin::core::Error>;
}
pub(crate) fn sabr_volatility(
f: f64, k: f64, t: f64, alpha: f64, beta: f64, rho: f64, nu: f64,
) -> f64;
Import
use RustQuant::models::Sabr02;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| f | f64 |
Yes | Forward price of the underlying. |
| alpha | f64 |
Yes | Initial volatility parameter. |
| beta | f64 |
Yes | CEV exponent (0 = normal, 0.5 = CIR, 1 = lognormal). Held fixed during calibration. |
| rho | f64 |
Yes | Correlation between forward and vol processes (-1 to 1). |
| nu | f64 |
Yes | Volatility of volatility. |
| k | f64 |
Yes (volatility) | Strike price for implied vol computation. |
| t | f64 |
Yes (volatility/fit) | Time to expiry in years. |
| volatilities | &[f64] |
Yes (fit) | Observed market implied volatilities for calibration. |
| strikes | &[f64] |
Yes (fit) | Corresponding strike prices for calibration. |
Outputs
| Name | Type | Description |
|---|---|---|
| volatility | f64 |
SABR implied Black volatility for a given strike and expiry. |
| fit result | Result<(), Error> |
Updates alpha, rho, and nu in-place after calibration. |
Usage Examples
use RustQuant::models::Sabr02;
// Create SABR model with initial parameters
let mut sabr = Sabr02::new(
100.0, // forward price
0.2, // alpha (initial vol)
0.5, // beta (CIR backbone)
0.0, // rho (no correlation initially)
0.4, // nu (vol of vol)
);
// Compute implied volatility for a specific strike and expiry
let vol = sabr.volatility(100.0, 1.0); // ATM, 1 year
// Calibrate to market data
let market_strikes = vec![90.0, 95.0, 100.0, 105.0, 110.0];
let market_vols = vec![0.25, 0.22, 0.20, 0.18, 0.16];
sabr.fit(&market_vols, &market_strikes, 1.0)
.expect("SABR calibration failed");
// After calibration, alpha, rho, nu are updated
let calibrated_vol = sabr.volatility(97.5, 1.0);