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 Heston Process

From Leeroopedia


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

Overview

Struct definition for the Heston stochastic volatility model provided by the RustQuant library. Note: the StochasticProcess trait methods (drift, diffusion, jump) are defined but not yet implemented (marked with todo!()).

Description

The Heston model is a two-factor stochastic volatility model where both the asset price and its variance follow stochastic processes. The system of SDEs is:

dS(t) = mu * S(t) dt + sqrt(v(t)) * S(t) dW_1(t)

dv(t) = kappa * (theta - v(t)) dt + sigma_v * sqrt(v(t)) dW_2(t)

where W_1 and W_2 are correlated Brownian motions with correlation rho. The variance process v(t) follows a CIR process, ensuring non-negative variance.

Key parameters:

  • initial_variance (ModelParameter) -- The initial variance v_0
  • long_run_variance (ModelParameter) -- The long-run variance theta
  • mean_reversion_rate (ModelParameter) -- The speed of mean reversion kappa
  • correlation (ModelParameter) -- Correlation between asset and variance Brownian motions rho
  • volatility_of_volatility (ModelParameter) -- Vol-of-vol sigma_v

Usage

Use this model for options pricing when the constant volatility assumption of Black-Scholes is inadequate. The Heston model captures the volatility smile/skew and allows for stochastic volatility dynamics. Note that the current implementation defines the struct and parameters but the StochasticProcess trait methods are not yet fully implemented.

Code Reference

Source Location

Signature

pub struct Heston {
    pub initial_variance: ModelParameter,
    pub long_run_variance: ModelParameter,
    pub mean_reversion_rate: ModelParameter,
    pub correlation: ModelParameter,
    pub volatility_of_volatility: ModelParameter,
}

impl Heston {
    pub fn new(
        initial_variance: impl Into<ModelParameter>,
        long_run_variance: impl Into<ModelParameter>,
        mean_reversion_rate: impl Into<ModelParameter>,
        correlation: impl Into<ModelParameter>,
        volatility_of_volatility: impl Into<ModelParameter>,
    ) -> Self
}

impl StochasticProcess for Heston {
    fn drift(&self, _x: f64, _t: f64) -> f64       // todo!()
    fn diffusion(&self, _x: f64, _t: f64) -> f64    // todo!()
    fn jump(&self, _x: f64, _t: f64) -> Option<f64> // todo!()
    fn parameters(&self) -> Vec<f64>
}

Import

use RustQuant::stochastics::Heston;

I/O Contract

Inputs

Name Type Required Description
initial_variance impl Into<ModelParameter> Yes Initial variance v_0
long_run_variance impl Into<ModelParameter> Yes Long-run variance theta
mean_reversion_rate impl Into<ModelParameter> Yes Mean reversion speed kappa
correlation impl Into<ModelParameter> Yes Correlation between asset and variance processes rho
volatility_of_volatility impl Into<ModelParameter> Yes Volatility of volatility sigma_v

Outputs

Name Type Description
drift() f64 Not yet implemented (todo!())
diffusion() f64 Not yet implemented (todo!())
jump() Option<f64> Not yet implemented (todo!())
parameters() Vec<f64> Returns [initial_variance(0), long_run_variance(0), mean_reversion_rate(0), correlation(0), volatility_of_volatility(0)]

Usage Examples

use RustQuant::stochastics::Heston;

// Create a Heston model
// v0=0.04, theta=0.04, kappa=2.0, rho=-0.7, sigma_v=0.3
let heston = Heston::new(0.04, 0.04, 2.0, -0.7, 0.3);

// Note: drift(), diffusion(), and jump() are not yet implemented.
// The parameters can be retrieved:
let params = heston.parameters();

Related Pages

Page Connections

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