Skip to content
Projets

À propos

High-performance quantitative finance in Rust and Python — 130+ stochastic processes, option pricing, calibration, fixed income, risk & copulas, with SIMD/GPU acceleration.

Gestion et finance

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
+1
in 7 days
+2
in 15 days
+3
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Build Workflow Crates.io docs.rs Downloads PyPI License codecov DOI

stochastic-rs

Quantitative finance in Rust: stochastic process simulation, option pricing and calibration, volatility surfaces, fixed income and credit, risk, statistics, copulas and neural volatility surrogates. Simulation is generic over f32 / f64, with SIMD on the CPU, CUDA and Metal back-ends, and Python bindings via PyO3.

Documentation

stochastic.rust-dd.com is the reference; this README only gets you installed and running.

What is inside

One workspace, one umbrella crate (stochastic-rs) that re-exports the sub-crates:

Crate Contents
stochastic-rs-core the SIMD RNG and seed sources (Deterministic, Unseeded)
stochastic-rs-distributions SIMD samplers with closed-form pdf / cdf / characteristic function / moments, special functions
stochastic-rs-stochastic 130 processes behind one ProcessExt trait: diffusion, jump, stochastic and rough volatility, short rate, HJM / LMM, fractional noise, Volterra
stochastic-rs-copulas 15 bivariate and 6 multivariate copulas, vine fitting, goodness of fit
stochastic-rs-stats Hurst and diffusion estimators, unit-root and cointegration tests, realised volatility, filters, extreme values, risk measures
stochastic-rs-quant closed-form, Fourier, PDE, lattice and Monte Carlo pricers, calibrators, vol surfaces, curves, credit, XVA, market microstructure
stochastic-rs-ai experimental neural volatility surrogates and surrogate calibration (ai feature)
stochastic-rs-py the Python module: distributions, processes, pricers, calibrators, copulas and estimators, NumPy in and out

Installation

The Rust crates require Rust 1.89 or newer; on Apple Silicon the ai feature needs Rust 1.94 or newer.

[dependencies]
stochastic-rs = "3.0.0-rc.5"

Device back-ends and other optional parts are cargo features (cuda, metal, accelerate, ai, unstable-dual-stream-rng; metal requires Apple Silicon with macOS 15 or newer, accelerate requires macOS); the installation guide and the feature flags page list what each pulls in. Sub-crates can be depended on directly for lean builds.

The ai feature and the stochastic-rs-ai crate are experimental and outside the stability promise.

pip install stochastic-rs

The wheels (Linux, macOS, Windows) are CPU-only and carry everything except the ai surrogates. A source build with a device back-end: maturin develop --release --features metal (or cuda) in a checkout.

Public dependencies

The umbrella re-exports ndarray, num_complex, num_traits, rand and chrono (as stochastic_rs::ndarray and so on) because callers build and pass their types; use these paths or depend on the same versions. A semver-incompatible release of any of these five crates (for a 0.x crate, a minor bump such as ndarray 0.17 → 0.18) is a major release of stochastic-rs. The wide vectors behind the SIMD kernels are an implementation detail: the trait items that name them are hidden and outside the stability promise.

use stochastic_rs::ndarray::Array1;
use stochastic_rs::prelude::*;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::process::bm::Bm;

fn total(path: &Array1<f64>) -> f64 {
  path.sum()
}

let path = Bm::<f64>::new(16, Some(1.0), Unseeded).sample();
assert!(total(&path).is_finite());

Quickstart

use stochastic_rs::prelude::*;
use stochastic_rs::simd_rng::Unseeded;
use stochastic_rs::stochastic::diffusion::ou::Ou;
use stochastic_rs::quant::pricing::heston::HestonParams;
use stochastic_rs::quant::pricing::heston::HestonPricer;

fn main() {
    // Mean-reverting Ornstein-Uhlenbeck path: Ou::new(theta, mu, sigma, n, x0, t, seed)
    let ou = Ou::<f64>::new(2.0, 0.0, 1.0, 1_000, Some(0.0), Some(1.0), Unseeded);
    let path = ou.sample();
    println!("OU path points: {}", path.len());

    // Heston (1993) European option, closed form. The model holds only its own
    // parameters; the pricing query is passed to the call, so one model can
    // price a whole strike/maturity grid.
    let params = HestonParams { v0: 0.04, kappa: 2.0, theta: 0.04, sigma: 0.3, rho: -0.5 };
    let pricer = HestonPricer::new(params);
    // price_call/price_put args: s, k, r, q, tau
    let call = pricer.price_call(100.0, 100.0, 0.03, 0.0, 1.0);
    let put = pricer.price_put(100.0, 100.0, 0.03, 0.0, 1.0);
    println!("call={call:.4}, put={put:.4}");
}
import stochastic_rs as srs

# PyOu(theta, mu, sigma, n, x0=None, t=None, seed=None, dtype=None, device=None): a mean-reverting
# OU path, here a numpy.ndarray of shape (1000,).
path = srs.PyOu(2.0, 0.0, 1.0, 1000, x0=0.0, t=1.0, seed=42).sample()

# Heston European option, closed form
pricer = srs.HestonPricer(
    s=100, v0=0.04, k=100, r=0.03, kappa=2.0, theta=0.04, sigma=0.3,
    rho=-0.5, tau=1.0, q=0.0,
)
call, put = pricer.call_put()

A process samples on a device by re-typing it: Gbm::new(...).on::<Metal>() (Cuda, Accelerate), with handle.probe() to check the device first; from Python, device="metal" on the device-capable classes. The GPU support page has the support matrix, and notebooks/ a Colab notebook that runs the CUDA back-end on a free T4.

Benchmarks

Criterion suites live under benches/; the benchmarks page carries the numbers: fractional Gaussian noise on CPU, Accelerate, Metal and cuFFT, the Euler engine on Metal and CUDA, and the SIMD Normal sampler against rand_distr.

Citing

The concept DOI 10.5281/zenodo.21553307 always resolves to the latest release; CITATION.cff carries the version DOI of the current one.

Contributing

Bug reports, suggestions and pull requests are welcome on GitHub. The contributing page has the development rules; per-feature recipes (add-diffusion-process, adding-distribution, calibration-pattern, …) live under .claude/skills/.

License

MIT — see LICENSE.

Explorer des projets similaires

Chargement…