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

From Leeroopedia
Revision as of 14:31, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Avhz_RustQuant_CIR_Process.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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

Overview

Concrete implementation of the Cox-Ingersoll-Ross (CIR) stochastic process provided by the RustQuant library.

Description

The Cox-Ingersoll-Ross model is a mean-reverting, square-root diffusion process defined by the SDE:

dX(t) = theta * (mu - X(t)) dt + sigma * sqrt(X(t)) dW(t)

where theta is the speed of mean reversion, mu is the long-run mean level, and sigma is the volatility. The square-root diffusion term ensures that the process remains non-negative (under the Feller condition 2*theta*mu >= sigma^2).

Key parameters:

  • mu (ModelParameter) -- The long-run mean level
  • sigma (ModelParameter) -- The volatility (must be non-negative)
  • theta (ModelParameter) -- Mean reversion speed

Usage

Use this process for modeling interest rates, default intensities, or any non-negative mean-reverting quantity. The CIR model is widely used in fixed income for short-rate modeling (e.g., bond pricing) and in credit risk for intensity-based default models.

Code Reference

Source Location

Signature

#[derive(Debug)]
pub struct CoxIngersollRoss {
    pub mu: ModelParameter,
    pub sigma: ModelParameter,
    pub theta: ModelParameter,
}

impl CoxIngersollRoss {
    pub fn new(
        mu: impl Into<ModelParameter>,
        sigma: impl Into<ModelParameter>,
        theta: impl Into<ModelParameter>,
    ) -> Self
}

impl StochasticProcess for CoxIngersollRoss {
    fn drift(&self, x: f64, t: f64) -> f64
    fn diffusion(&self, x: f64, t: f64) -> f64
    fn jump(&self, _x: f64, _t: f64) -> Option<f64>
    fn parameters(&self) -> Vec<f64>
}

Import

use RustQuant::stochastics::CoxIngersollRoss;

I/O Contract

Inputs

Name Type Required Description
mu impl Into<ModelParameter> Yes The long-run mean level
sigma impl Into<ModelParameter> Yes The volatility (must be non-negative)
theta impl Into<ModelParameter> Yes Mean reversion speed

Outputs

Name Type Description
drift() f64 Returns theta(t) * (mu(t) - x) -- mean-reverting drift
diffusion() f64 Returns sigma(t) * sqrt(x) -- square-root diffusion
jump() Option<f64> Always returns None (no jump component)
parameters() Vec<f64> Returns [mu(0), sigma(0), theta(0)]

Usage Examples

use RustQuant::stochastics::CoxIngersollRoss;
use RustQuant::stochastics::{StochasticProcessConfig, StochasticScheme};

// Create a CIR process with mu=0.15, sigma=0.45, theta=0.01
let cir = CoxIngersollRoss::new(0.15, 0.45, 0.01);

// Configure simulation: x0=10.0, t_start=0.0, t_end=0.5, n_steps=100, 100 paths
let config = StochasticProcessConfig::new(
    10.0, 0.0, 0.5, 100, StochasticScheme::EulerMaruyama, 100, false, None
);

let output = cir.generate(&config);

// Access simulated paths
let paths = &output.paths;

Related Pages

Page Connections

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