Quickstart
A 5-minute end-to-end tour — simulate an OU path, price a Heston call, and run a Hurst estimator. Same code shown in Rust and Python side by side.
Quickstart
Three vignettes, each shown in Rust and Python. Pick whichever language you are working in — the API surface is intentionally close.
1. Simulate an OU path
The Ornstein-Uhlenbeck process
with , , , , on with 1000 steps:
Rust
use stochastic_rs::prelude::*;
use stochastic_rs::stochastic::diffusion::ou::Ou;
fn main() {
let p = Ou::<f64>::new(2.0, 0.0, 1.0, 1_000, Some(0.0), Some(1.0));
let path = p.sample();
println!("len = {}, mean = {:.3}", path.len(), path.mean().unwrap());
}Python
import stochastic_rs as srs
p = srs.Ou(theta=2.0, mu=0.0, sigma=1.0, n=1000, x0=0.0, t=1.0)
path = p.sample()
print("len =", path.shape[0], "mean =", path.mean())For the API contract see the Processes catalog.
2. Price a Heston European call
The Heston model is the workhorse stochastic-volatility model. The Fourier pricer uses Cui's analytic Jacobian for fast and stable characteristic-function evaluation.
Rust
use stochastic_rs::prelude::*;
use stochastic_rs::quant::pricing::heston::HestonPricer;
use stochastic_rs::quant::types::OptionType;
fn main() {
let pricer = HestonPricer::<f64>::new(
/* s0 */ 100.0, /* k */ 100.0, /* tau */ 1.0,
/* r */ 0.03, /* q */ 0.0,
/* v0 */ 0.04, /* kappa */ 2.0, /* theta */ 0.04,
/* sigma */ 0.3, /* rho */ -0.5,
);
let price = pricer.price(OptionType::Call);
let greeks = pricer.greeks(OptionType::Call);
println!("call = {:.4}, delta = {:.4}, vega = {:.4}",
price, greeks.delta, greeks.vega);
}Python
import stochastic_rs as srs
pricer = srs.HestonPricer(
s0=100, k=100, tau=1.0, r=0.03, q=0.0,
v0=0.04, kappa=2.0, theta=0.04, sigma=0.3, rho=-0.5,
)
price = pricer.price("call")
greeks = pricer.greeks("call")
print(f"call={price:.4f}, delta={greeks.delta:.4f}, vega={greeks.vega:.4f}")3. Estimate Hurst from a fractional-Brownian path
The Fukasawa estimator gives a strongly consistent Hurst estimate from high-frequency increments. It is the recommended estimator for empirical roughness studies.
Rust
use stochastic_rs::prelude::*;
use stochastic_rs::stochastic::noise::fgn::Fgn;
use stochastic_rs::stats::fukasawa_hurst::FukasawaHurst;
fn main() {
let fgn = Fgn::<f64>::new(0.3, 1.0, 4096, Some(1.0));
let path = fgn.sample();
let est = FukasawaHurst::<f64>::new().estimate(path.view());
println!("H = {:.3} ± {:.3}", est.point, est.se);
}Python
import stochastic_rs as srs
fgn = srs.Fgn(hurst=0.3, sigma=1.0, n=4096, t=1.0)
path = fgn.sample()
est = srs.fukasawa_hurst(path)
print(f"H = {est.point:.3f} ± {est.se:.3f}")Where next
- Concepts: traits & prelude — the trait surface is the single most important thing to internalise.
- Quant catalog — pricing, calibration, vol surface, risk.
- Python bindings — full parity table.
Installation (Python)
Install the stochastic-rs Python bindings — pre-built wheels via pip, or build locally with maturin and Bun-equivalent uv-pip workflow.
Workspace layout
How the stochastic-rs Cargo workspace is organised — sub-crates, dependency topology, and how the umbrella re-exports preserve v1.x import paths.