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 Backend

From Leeroopedia


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

Overview

Concrete tool for pricing European options using the Heston stochastic volatility model via characteristic function integration provided by the RustQuant library.

Description

This module implements the Heston (1993) stochastic volatility model as a standalone function heston(). The model assumes the variance follows a mean-reverting square-root (CIR) process:

dV = kappa * (theta - V) * dt + sigma * sqrt(V) * dW_V

with correlation rho between the asset and variance Brownian motions.

The implementation computes the option price via semi-analytical characteristic function inversion. It evaluates two probabilities P1 and P2 by numerically integrating the real parts of the Heston characteristic functions (using complex arithmetic from the num crate) over the interval [0.00001, 50]. The call price is S * exp(-q * tau) * P1 - K * exp(-r * tau) * P2, and the put is obtained via put-call parity. The market price of volatility risk lambda is set to zero. Test values are from Fabrice D. Rouah's The Heston Model and Its Extensions in MATLAB and C#.

Usage

Use when pricing European options under stochastic volatility, where the implied volatility surface exhibits skew or smile effects not captured by the BSM model.

Code Reference

Source Location

Signature

#[must_use]
pub fn heston(
    S0: f64,    // Initial asset value
    V0: f64,    // Initial variance value
    K: f64,     // Strike price
    r: f64,     // Risk-free rate
    q: f64,     // Dividend yield
    rho: f64,   // Correlation between asset and variance Brownian motions
    sigma: f64, // Volatility-of-volatility
    kappa: f64, // Mean reversion rate
    theta: f64, // Long-run mean variance
    evaluation_date: Option<Date>,
    expiration_date: Date,
) -> (f64, f64)

Import

use RustQuant::instruments::heston;

I/O Contract

Inputs

Name Type Required Description
S0 f64 Yes Initial asset price
V0 f64 Yes Initial variance (not volatility)
K f64 Yes Strike price
r f64 Yes Risk-free interest rate
q f64 Yes Continuous dividend yield
rho f64 Yes Correlation between asset and variance processes
sigma f64 Yes Volatility of volatility (vol-of-vol)
kappa f64 Yes Mean reversion rate of the variance process
theta f64 Yes Long-run mean of the variance process
evaluation_date Option<Date> No Valuation date; defaults to today
expiration_date Date Yes Option expiration date

Outputs

Name Type Description
(call, put) (f64, f64) Tuple of European call and put prices

Usage Examples

use RustQuant::instruments::heston;
use RustQuant::time::today;
use time::Duration;

let expiry = today() + Duration::days(183);

let (call, put) = heston(
    100.0,   // S0: spot price
    0.05,    // V0: initial variance
    100.0,   // K: strike price
    0.03,    // r: risk-free rate
    0.02,    // q: dividend yield
    -0.8,    // rho: correlation
    0.5,     // sigma: vol-of-vol
    5.0,     // kappa: mean reversion rate
    0.05,    // theta: long-run variance
    None,    // evaluation_date
    expiry,  // expiration_date
);

Related Pages

Page Connections

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