High-performance SDE simulation: Rust core, Python API
Project description
pathwise
High-performance SDE simulation toolkit: Rust core, Python API.
Overview
pathwise provides composable, high-performance SDE simulation in Python backed by a Rust core. Paths are returned as NumPy arrays with shape (n_paths, n_steps+1) for scalar processes and (n_paths, n_steps+1, N) for N-dimensional processes. Built-in processes (bm, gbm, ou, cir, heston, corr_ou) execute in parallel via Rayon with the GIL released; custom Python callables run serially.
Key differentiator: pathwise ships a Taylor 1.5 (SRI) strong-order 1.5 scheme alongside standard Euler and Milstein, and extends to geodesic SDE simulation on Riemannian manifolds via the pathwise-geo crate.
Install
pip install pathwise-sde
Build from source:
git clone https://github.com/alejandro-soto-franco/pathwise.git
cd pathwise
pip install maturin
python -m venv .venv && source .venv/bin/activate
maturin develop
Quick start
import pathwise as pw
# 10,000 GBM paths, 252 daily steps, Euler-Maruyama
paths = pw.simulate(
pw.gbm(mu=0.05, sigma=0.2),
scheme=pw.euler(),
n_paths=10_000,
n_steps=252,
t1=1.0,
x0=100.0,
)
# paths: np.ndarray shape (10_000, 253), includes t=0
# Milstein scheme (strong order 1 on state-dependent diffusion)
paths = pw.simulate(
pw.gbm(0.05, 0.4),
pw.milstein(),
n_paths=5_000,
n_steps=500,
t1=1.0,
x0=1.0,
)
# SRI scheme (strong order 1.5, Kloeden-Platen Taylor 1.5)
paths = pw.simulate(
pw.gbm(0.05, 0.2),
pw.sri(),
n_paths=5_000,
n_steps=252,
t1=1.0,
x0=1.0,
)
# Cox-Ingersoll-Ross (requires Feller condition: 2*kappa*theta > sigma^2)
paths = pw.simulate(
pw.cir(kappa=1.0, theta=0.04, sigma=0.1),
pw.euler(),
n_paths=5_000,
n_steps=252,
t1=1.0,
x0=0.04,
)
# Heston stochastic volatility
# x0 = log(S0); initial variance defaults to theta
# returns shape (n_paths, n_steps+1, 2): [:,:,0] = log-price, [:,:,1] = variance
paths = pw.simulate(
pw.heston(mu=0.05, kappa=2.0, theta=0.04, xi=0.3, rho=-0.7),
pw.euler(),
n_paths=5_000,
n_steps=252,
t1=1.0,
x0=0.0, # log(S0) = log(1.0) = 0
)
log_price = paths[:, :, 0]
variance = paths[:, :, 1]
API reference
Processes
| Function | SDE | Notes |
|---|---|---|
pw.bm() |
$dX = dW$ | Standard Brownian motion |
pw.gbm(mu, sigma) |
$dX = \mu X,dt + \sigma X,dW$ | Geometric Brownian motion |
pw.ou(theta, mu, sigma) |
$dX = \theta(\mu - X),dt + \sigma,dW$ | Ornstein-Uhlenbeck |
pw.cir(kappa, theta, sigma) |
$dX = \kappa(\theta - X),dt + \sigma\sqrt{X},dW$ | Cox-Ingersoll-Ross; raises ValueError if Feller violated |
pw.heston(mu, kappa, theta, xi, rho) |
coupled log-price + CIR variance | Returns (n_paths, n_steps+1, 2) array |
pw.corr_ou(theta, mu_vec, sigma_flat) |
N-dim correlated OU | mu_vec: list of length N; sigma_flat: flattened N×N covariance; Python bindings: N=2 only |
pw.sde(drift, diffusion) |
$dX = f(X,t),dt + g(X,t),dW$ | Custom Python callables, runs serially |
Schemes
| Function | Strong order | Weak order | Notes |
|---|---|---|---|
pw.euler() |
$\tfrac{1}{2}$ | $1$ | Euler-Maruyama |
pw.milstein() |
$1$ | $1$ | Requires diffusion gradient |
pw.sri() |
$\tfrac{3}{2}$ | $2$ | Kloeden-Platen Taylor 1.5; not supported for Heston or CorrOU |
simulate
pw.simulate(
sde, # SDE object (bm, gbm, ou, cir, heston, corr_ou, or custom sde())
scheme, # euler(), milstein(), or sri()
n_paths, # number of independent paths (int)
n_steps, # time steps per path (int)
t1, # end time (float)
x0=0.0, # initial value (float)
# for Heston: x0 = log(S0); initial variance = theta
t0=0.0, # start time (float)
device="cpu", # "cpu" only in v0.2
) -> np.ndarray
# Scalar SDE: shape (n_paths, n_steps + 1)
# N-dim SDE: shape (n_paths, n_steps + 1, N)
# Heston N=2: [:,:,0] = log-price, [:,:,1] = variance
Parameter notes:
x0for Heston islog(S0), notS0. To simulate starting from price 100, passx0=math.log(100).sigma_flatforcorr_ouis the covariance matrix (not correlation) laid out in row-major order. For N=2 pass[var1, cov12, cov12, var2].- SRI raises
ValueErrorif used withhestonorcorr_ou. - CIR raises
ValueError(message contains "Feller") if2 * kappa * theta <= sigma ** 2.
Exceptions
pw.NumericalDivergence # reserved; non-finite values are stored as NaN
pw.ConvergenceError # raised on inference failures (future versions)
# ValueError # raised by cir (Feller), sri+heston, sri+corr_ou
Numerical validation
The test suite verifies convergence orders against analytic benchmarks:
- Euler strong order measured at 0.49 (expected $\tfrac{1}{2}$) on GBM via common-noise regression
- Milstein strong order measured at 0.98 (expected $1$) on GBM
- SRI strong order measured at ~1.5 (expected $\tfrac{3}{2}$) on GBM
- GBM mean/variance match $\mathbb{E}[X_T] = x_0 e^{\mu T}$ and the exact second moment formula
- OU conditional moments match analytic formulas
- CIR non-negativity verified; moments checked against closed-form
- BM increments pass Kolmogorov-Smirnov normality test ($\mathcal{N}(0, \Delta t)$)
- BM quadratic variation converges to $T$
- GBM log-normality verified via KS test on $\log X_T$
- European call price matches Black-Scholes within 1%
Run the full suite:
cargo test -p pathwise-core # Rust unit and integration tests
cargo test -p pathwise-core --test convergence
pytest tests/ # Python API and numerical tests
pathwise-geo (Rust only)
pathwise-geo is a companion crate for geodesic SDE simulation on Riemannian manifolds, backed by the cartan geometry library.
Supported manifolds: $S^n$ (hypersphere), $SO(n)$ (rotation group), $SPD(n)$ (symmetric positive-definite matrices).
Schemes: GeodesicEuler, GeodesicMilstein, GeodesicSRI.
Add to your Cargo.toml:
[dependencies]
pathwise-geo = "0.2"
Python bindings for pathwise-geo are planned for v0.3. See the crate docs for the Rust API.
Roadmap
| Version | Status | Items |
|---|---|---|
| v0.1 | released | Euler, Milstein; BM, GBM, OU; custom Python SDEs |
| v0.2 | released | SRI (Taylor 1.5); CIR, Heston, CorrOU; pathwise-geo (geodesic SDEs on S^n/SO(n)/SPD(n)) |
| v0.3 | planned | Python bindings for pathwise-geo; fractional BM; Volterra SDEs |
| v0.4 | planned | CUDA GPU acceleration |
| v0.5 | planned | MLE inference, particle filter |
| v0.6 | planned | Rough Heston / rough Bergomi surface calibration |
| v1.0 | planned | Stable API, JOSS paper |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pathwise_sde-0.2.0.tar.gz.
File metadata
- Download URL: pathwise_sde-0.2.0.tar.gz
- Upload date:
- Size: 39.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25ae3b0a7724bd294d35479929ba6dcc3b1aa1aa43848ad4ef786e45591ed9fc
|
|
| MD5 |
dad0c0bb228c4da71f6336339313d250
|
|
| BLAKE2b-256 |
add90611a0e36df0f111b47c56379fb1aaa5fef74b48d09eb37b964ae4a42447
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0.tar.gz:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0.tar.gz -
Subject digest:
25ae3b0a7724bd294d35479929ba6dcc3b1aa1aa43848ad4ef786e45591ed9fc - Sigstore transparency entry: 1181940540
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 455.1 kB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db1f389857501dc60ccf6e4a60cbf1f3c9aeb1e740f5b7ba01f984c6ef1f06ee
|
|
| MD5 |
4e7b6380f27e23ee003b1a4f7928b407
|
|
| BLAKE2b-256 |
3330f4b2ae5511ca3dc43d18775d04e4ec64e17d5d26c6ee67e94150750a1465
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
db1f389857501dc60ccf6e4a60cbf1f3c9aeb1e740f5b7ba01f984c6ef1f06ee - Sigstore transparency entry: 1181940604
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 448.8 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0227c6b01bd61d96c17586328412e8cb8d277ca2eccf024cdee010b903df401
|
|
| MD5 |
81139ae179dd607b03f416d09ee771fb
|
|
| BLAKE2b-256 |
a8509a1716a21b58747e2ef3a741a03fdfa83acdd86c853a6bc2239b172f09cd
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
b0227c6b01bd61d96c17586328412e8cb8d277ca2eccf024cdee010b903df401 - Sigstore transparency entry: 1181940619
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 303.6 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7caa371dbc4ec4514006e4bd2c9c7b6f5d1cc75f1dafb2871f49b6c762014c00
|
|
| MD5 |
57502d04c22c2c7119d0ee487bfb2c16
|
|
| BLAKE2b-256 |
9dcd1021659e97031e398ce34db1ccc2d0988e3f00c54d637510a9b7a7e2e54a
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-cp310-abi3-win_amd64.whl -
Subject digest:
7caa371dbc4ec4514006e4bd2c9c7b6f5d1cc75f1dafb2871f49b6c762014c00 - Sigstore transparency entry: 1181940632
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 457.9 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70893ef2a2e9c258293bc9a34835e22c244c4e45415b11fadac51bbeb04b5fb3
|
|
| MD5 |
b0b757905b4b6147c6b4cf33cd8b5ff5
|
|
| BLAKE2b-256 |
72e802f36746301c48db72aa89e7a495ff08d002df4dbbbb7cc5d39c5b825d36
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
70893ef2a2e9c258293bc9a34835e22c244c4e45415b11fadac51bbeb04b5fb3 - Sigstore transparency entry: 1181940562
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 448.5 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca4b8459e035b9d38e471213fab678423e3a636e4b4d62cb7cd55d2f1e50c42
|
|
| MD5 |
10fb219fd7e8c15db11670f9e9a5b956
|
|
| BLAKE2b-256 |
6192b6936285bc34f364bcbad27ee9147f2364bf1950e8954f36151620ecb895
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
3ca4b8459e035b9d38e471213fab678423e3a636e4b4d62cb7cd55d2f1e50c42 - Sigstore transparency entry: 1181940594
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 403.1 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
345b362fa5fd0ed26a4db5485b1e96a499d35222544480e10988be7fdeb760c5
|
|
| MD5 |
c85dbf41ecb08e4141bf4daa5ea4750c
|
|
| BLAKE2b-256 |
a2716239d6b0c0e0f192a0d4432c6ecd9064857927813b54a4b02a3267aa9656
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
345b362fa5fd0ed26a4db5485b1e96a499d35222544480e10988be7fdeb760c5 - Sigstore transparency entry: 1181940578
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pathwise_sde-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pathwise_sde-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 411.8 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45c64c9fb33089847fa6b1f096e38e3ca5c0fd73a13f129b469405022de3f691
|
|
| MD5 |
f12ef0457afae793d82c2904bf51d3d7
|
|
| BLAKE2b-256 |
645013e65c6061b452c39873268fd8e377ce34ca98594bdc736c4537f3e2dc82
|
Provenance
The following attestation bundles were made for pathwise_sde-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on alejandro-soto-franco/pathwise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathwise_sde-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
45c64c9fb33089847fa6b1f096e38e3ca5c0fd73a13f129b469405022de3f691 - Sigstore transparency entry: 1181940548
- Sigstore integration time:
-
Permalink:
alejandro-soto-franco/pathwise@61b32037072da2c15c1438246714a3892f4fa6b8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alejandro-soto-franco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61b32037072da2c15c1438246714a3892f4fa6b8 -
Trigger Event:
push
-
Statement type: