Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Avhz RustQuant Heston93 Model

From Leeroopedia


Knowledge Sources
Domains Option_Pricing, Stochastic_Volatility, Quantitative_Finance
Last Updated 2026-02-07 19:00 GMT

Overview

Concrete tool for Heston (1993) stochastic volatility option pricing provided by the RustQuant library.

Description

The Heston93 struct implements the Heston stochastic volatility model for European option pricing. Unlike the Black-Scholes model which assumes constant volatility, the Heston model treats volatility as a stochastic process that follows a mean-reverting square-root (CIR) diffusion:

dv = kappa * (theta - v) * dt + sigma * sqrt(v) * dW_v

where the Brownian motions driving the asset price and variance are correlated with parameter rho.

The implementation uses the semi-analytical characteristic function approach described in Heston's original 1993 paper. Option prices are computed via numerical integration of two probability integrals P1 and P2, which are evaluated using the characteristic functions of the log-asset price. The integration is performed over the range [0.00001, 50.0] using the library's integrate function.

The market price of volatility risk (lambda) is set to 0 in this implementation.

Put prices are derived from call prices using put-call parity.

Available methods:

  • price -- European call/put price.
  • delta -- First derivative with respect to the underlying asset price.
  • gamma -- Second derivative with respect to the underlying asset price. Computed via numerical integration of the characteristic function.
  • rho -- Sensitivity with respect to the risk-free interest rate.

Usage

Use the Heston model when constant-volatility assumptions are insufficient, particularly for pricing options where the volatility smile/skew is significant. It is the industry standard stochastic volatility model for equity and FX derivatives.

Code Reference

Source Location

Signature

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Heston93 {
    s: f64,      // Spot price
    v: f64,      // Initial variance
    r: f64,      // Risk-free rate
    q: f64,      // Dividend yield
    rho: f64,    // Correlation between asset and variance
    kappa: f64,  // Mean reversion speed
    theta: f64,  // Long-run variance
    sigma: f64,  // Volatility of variance (vol of vol)
}

impl Heston93 {
    pub fn new(s: f64, v: f64, r: f64, q: f64, rho: f64, kappa: f64, theta: f64, sigma: f64) -> Self;
    pub fn price(&self, k: f64, t: f64, option_type: TypeFlag) -> f64;
    pub fn delta(&self, k: f64, t: f64, option_type: TypeFlag) -> f64;
    pub fn gamma(&self, k: f64, t: f64, option_type: TypeFlag) -> f64;
    pub fn rho(&self, k: f64, t: f64, option_type: TypeFlag) -> f64;
}

Import

use RustQuant::models::Heston93;
use RustQuant::instruments::TypeFlag;

I/O Contract

Inputs

Name Type Required Description
s f64 Yes Current spot price of the underlying asset.
v f64 Yes Current instantaneous variance (v0).
r f64 Yes Risk-free interest rate.
q f64 Yes Continuous dividend yield.
rho f64 Yes Correlation between the asset price and variance Brownian motions.
kappa f64 Yes Speed of mean reversion of the variance process.
theta f64 Yes Long-run mean of the variance process.
sigma f64 Yes Volatility of variance (vol of vol).
k f64 Yes (pricing) Strike price of the option.
t f64 Yes (pricing) Time to maturity in years.
option_type TypeFlag Yes (pricing) Call or Put.

Outputs

Name Type Description
price f64 European option price under the Heston model.
delta f64 Option delta (dPrice/dS).
gamma f64 Option gamma (d2Price/dS2).
rho f64 Option rho (dPrice/dr).

Usage Examples

use RustQuant::models::Heston93;
use RustQuant::instruments::TypeFlag;

// Heston model parameters
let heston = Heston93::new(
    100.0,  // spot price
    0.04,   // initial variance (vol = 20%)
    0.05,   // risk-free rate
    0.02,   // dividend yield
    -0.7,   // correlation (negative skew)
    2.0,    // mean reversion speed
    0.04,   // long-run variance
    0.3,    // vol of vol
);

// Price a European call option
let call_price = heston.price(100.0, 1.0, TypeFlag::Call);
let put_price = heston.price(100.0, 1.0, TypeFlag::Put);

// Greeks
let delta = heston.delta(100.0, 1.0, TypeFlag::Call);
let gamma = heston.gamma(100.0, 1.0, TypeFlag::Call);
let rho = heston.rho(100.0, 1.0, TypeFlag::Call);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment