[workspace]
members = [
    "stochastic-rs-core",
    "stochastic-rs-distributions",
    "stochastic-rs-stochastic",
    "stochastic-rs-copulas",
    "stochastic-rs-stats",
    "stochastic-rs-quant",
    "stochastic-rs-ai",
    "stochastic-rs-viz",
    "stochastic-rs-py",
]

[workspace.package]
version = "2.4.0"

[workspace.dependencies]
# Internal crates
stochastic-rs-core = { path = "stochastic-rs-core", version = "2.4" }
stochastic-rs-distributions = { path = "stochastic-rs-distributions", version = "2.4" }
stochastic-rs-stochastic = { path = "stochastic-rs-stochastic", version = "2.4" }
stochastic-rs-copulas = { path = "stochastic-rs-copulas", version = "2.4" }
stochastic-rs-stats = { path = "stochastic-rs-stats", version = "2.4" }
stochastic-rs-quant = { path = "stochastic-rs-quant", version = "2.4" }
stochastic-rs-ai = { path = "stochastic-rs-ai", version = "2.4" }
stochastic-rs-viz = { path = "stochastic-rs-viz", version = "2.4" }

# Math / numerical core
ndarray = { version = "0.17.2", features = ["rayon", "matrixmultiply-threading"] }
ndarray-linalg = { version = "0.18.1", default-features = false }
ndarray-npy = "0.10.0"
ndarray-rand = "0.16.0"
ndarray-stats = "0.7.0"
ndrustfft = "0.6.2"
num-complex = { version = "0.4.6", features = ["rand"] }
num-traits = "0.2.19"
nalgebra = "0.33.2"

# RNG / parallel / SIMD
rand = "0.9.2"
rand_distr = "0.5.1"
rayon = "1.11.0"
wide = "1.5.0"

# Statistics / fitting / optimisation
# `statrs` is dev-deps only — used for cross-validating our closed-form
# `DistributionExt` impls. Production code never delegates to it.
statrs = "0.18.0"
kendalls = "1.0.0"
linreg = "0.2.0"
levenberg-marquardt = "0.14.0"
argmin = "0.11.0"
argmin-math = { version = "0.5", features = ["ndarray_latest-nolinalg", "vec"] }
gauss-quad = "0.3.1"
quadrature = "0.1.2"
roots = "0.0.8"
slsqp = "1.0.0"
scilib = "1.0.0"
sci-rs = "0.4.1"
owens-t = "0.1.5"

# General utility
anyhow = "1.0.89"
parking_lot = "0.12.5"
ordered-float = "5.0.0"
chrono = "0.4.38"
flate2 = "1.1.2"

# Pricing-specific
implied-vol = "2.0.0"

# Visualisation
plotly = { version = "0.10.0", features = ["plotly_ndarray"] }

# Native math (gated)
openblas-src = { version = "0.10", features = ["cblas"] }

# Python bindings
pyo3 = { version = "0.28", features = ["extension-module", "chrono"] }
numpy = "0.28"

# AI / ML
candle-core = "0.9.2"
candle-datasets = "0.9.2"
candle-nn = "0.9.2"
polars = { version = "0.43.1", features = ["lazy"] }

# GPU
cubecl = { version = "0.9.0", default-features = false }
cubecl-cuda = "0.9.0"
cubecl-wgpu = "0.9.0"
cudarc = { version = "0.19.2", features = ["cuda-12080", "cuda-version-from-build-system"] }
gpu-fft = "1.1.1"
metal = "0.33.0"

# Allocators / profiling
mimalloc = "0.1.48"
tikv-jemallocator = "0.6.1"
hotpath = "0.14"

# Yahoo finance
time = { version = "0.3.36", features = ["formatting", "parsing"] }
yahoo_finance_api = "2.3.0"
tokio-test = "0.4.4"

# Dev
romu = "0.8.0"
criterion = { version = "0.8", features = ["html_reports"] }

[package]
name = "stochastic-rs"
version.workspace = true
edition = "2024"
license = "MIT"
description = "A Rust library for quant finance and simulating stochastic processes."
homepage = "https://github.com/dancixx/stochastic-rs"
documentation = "https://docs.rs/stochastic-rs/latest/stochastic_rs/"
repository = "https://github.com/dancixx/stochastic-rs"
readme = "README.md"
keywords = ["stochastic", "quant", "finance", "simulation", "statistics"]
exclude = [ "**/*.tar.gz", "data/**", "trainsets/**", "src/ai/volatility/*TrainSet.txt.gz", ]

[dependencies]
stochastic-rs-core = { workspace = true }
stochastic-rs-distributions = { workspace = true }
stochastic-rs-stochastic = { workspace = true }
stochastic-rs-copulas = { workspace = true }
stochastic-rs-stats = { workspace = true }
stochastic-rs-quant = { workspace = true }
stochastic-rs-viz = { workspace = true }
stochastic-rs-ai = { workspace = true, optional = true }
anyhow = { workspace = true }
argmin = { workspace = true }
argmin-math = { workspace = true, features = ["ndarray_latest-nolinalg", "vec"] }
candle-core = { workspace = true, optional = true }
candle-datasets = { workspace = true, optional = true }
candle-nn = { workspace = true, optional = true }
chrono = { workspace = true }
cubecl = { workspace = true, optional = true, default-features = false }
cubecl-cuda = { workspace = true, optional = true }
cubecl-wgpu = { workspace = true, optional = true }
cudarc = { workspace = true, optional = true, features = [ "cuda-12080", "cuda-version-from-build-system", ] }
flate2 = { workspace = true }
gpu-fft = { workspace = true, optional = true }
gauss-quad = { workspace = true }
implied-vol = { workspace = true }
kendalls = { workspace = true }
levenberg-marquardt = { workspace = true }
linreg = { workspace = true }
openblas-src = { workspace = true, features = ["cblas"], optional = true }
metal = { workspace = true, optional = true }
mimalloc = { workspace = true, optional = true }
nalgebra = { workspace = true }
ndarray = { workspace = true, features = [ "rayon", "matrixmultiply-threading", ] }
ndarray-linalg = { workspace = true, optional = true }
ndarray-npy = { workspace = true }
ndarray-rand = { workspace = true }
ndarray-stats = { workspace = true }
ndrustfft = { workspace = true }
num-complex = { workspace = true, features = ["rand"] }
num-traits = { workspace = true }
numpy = { workspace = true, optional = true }
pyo3 = { workspace = true, features = ["extension-module"], optional = true }
ordered-float = { workspace = true }
owens-t = { workspace = true }
plotly = { workspace = true, features = ["plotly_ndarray"] }
polars = { workspace = true, features = ["lazy"], optional = true }
quadrature = { workspace = true }
rand = { workspace = true }
rand_distr = { workspace = true }
rayon = { workspace = true }
roots = { workspace = true }
sci-rs = { workspace = true }
scilib = { workspace = true }
slsqp = { workspace = true }
tikv-jemallocator = { workspace = true, optional = true }
time = { workspace = true, features = [ "formatting", "parsing", ], optional = true }
tokio-test = { workspace = true, optional = true }
wide = { workspace = true }
hotpath = { workspace = true, optional = true }
yahoo_finance_api = { workspace = true, optional = true }
parking_lot = { workspace = true }

[dev-dependencies]
criterion = { workspace = true, features = ["html_reports"] }
rand = { workspace = true }
rand_distr = { workspace = true }
romu = { workspace = true }

[[bench]]
name = "distributions"
harness = false

[[bench]]
name = "fgn_fbm"
harness = false

[[bench]]
name = "rl_rough"
harness = false

[[bench]]
name = "process_generation"
harness = false

[[bench]]
name = "gn_batching"
harness = false

[[bench]]
name = "dist_multicore"
harness = false

[[bench]]
name = "fgn_gpu"
harness = false
required-features = ["gpu"]

[[bench]]
name = "fgn_cuda_native"
harness = false
required-features = ["cuda-native"]

[[bench]]
name = "fgn_cuda_compare"
harness = false
required-features = ["cuda-native", "gpu-cuda"]

[[bench]]
name = "fgn_all_backends"
harness = false
required-features = ["gpu-wgpu", "metal", "accelerate"]

[[bench]]
name = "fgn_accelerate"
harness = false
required-features = ["accelerate"]

[[bench]]
name = "fgn_metal"
harness = false
required-features = ["metal"]

[[bench]]
name = "poisson_process"
harness = false

[[bench]]
name = "mle"
harness = false

[[bench]]
name = "hurst"
harness = false

[[bench]]
name = "calendar"
harness = false

[[bench]]
name = "cashflows"
harness = false

[[bench]]
name = "market"
harness = false

[[bench]]
name = "instruments"
harness = false

[[bench]]
name = "credit"
harness = false

[[bench]]
name = "risk"
harness = false

[[bench]]
name = "realized"
harness = false

[[bench]]
name = "microstructure"
harness = false

[[bench]]
name = "factors"
harness = false
required-features = ["openblas"]

[[bench]]
name = "econometrics"
harness = false

[[bench]]
name = "filtering"
harness = false

[[bench]]
name = "lattice"
harness = false

[[bench]]
name = "option"
harness = false


[[bench]]
name = "slv"
harness = false

[[bench]]
name = "hotpath_profile"
harness = false
required-features = ["hotpath"]

[[bench]]
name = "dual_stream_compare"
harness = false
required-features = ["dual-stream-rng"]

[[example]]
name = "cuda_fgn_analysis"
required-features = ["cuda-native"]

[[example]]
name = "cuda_d2h_bw"
required-features = ["cuda-native"]

[features]
ai = ["dep:stochastic-rs-ai", "stochastic-rs-ai/quant"]
cuda-native = ["dep:cudarc", "cudarc/cufft", "stochastic-rs-stochastic/cuda-native"]
default = []
# Experimental: opt in to the dual-stream RNG (`SimdRngDual` /
# `SimdNormalDual`). ~5–11% speedup on Ziggurat-based Normal/Exp bulk
# fills on Apple Silicon; deterministic output differs from the
# single-stream `SimdRng`. See `stochastic-rs-core` feature doc.
dual-stream-rng = [
    "stochastic-rs-core/dual-stream-rng",
    "stochastic-rs-distributions/dual-stream-rng",
]
openblas = [
    "dep:ndarray-linalg",
    "dep:openblas-src",
    "ndarray-linalg/openblas-system",
    "stochastic-rs-copulas/openblas",
    "stochastic-rs-quant/openblas",
    "stochastic-rs-stats/openblas",
    "stochastic-rs-stochastic/openblas",
]
# Vendored / static OpenBLAS — used by the Windows wheel CI job because the
# MSVC toolchain cannot reliably link the prebuilt MinGW `.lib`. Unix targets
# stay on `openblas` (system-link) for faster developer builds.
openblas-static = [
    "dep:ndarray-linalg",
    "dep:openblas-src",
    "ndarray-linalg/openblas-static",
    "openblas-src/static",
    "stochastic-rs-copulas/openblas-static",
    "stochastic-rs-quant/openblas-static",
    "stochastic-rs-stats/openblas-static",
    "stochastic-rs-stochastic/openblas-static",
]
accelerate = ["stochastic-rs-stochastic/accelerate"]
gpu = ["dep:cubecl", "dep:gpu-fft", "stochastic-rs-stochastic/gpu"]
metal = ["dep:metal", "stochastic-rs-stochastic/metal"]
gpu-cuda = ["gpu", "dep:cubecl-cuda", "stochastic-rs-stochastic/gpu-cuda"]
gpu-wgpu = ["gpu", "dep:cubecl-wgpu", "stochastic-rs-stochastic/gpu-wgpu"]
jemalloc = ["dep:tikv-jemallocator"]
# Python bindings live in `stochastic-rs-py` (separate cdylib). Enabling
# `python` here just turns on the upstream feature flags so the umbrella
# build is consistent with the cdylib build. The actual Python module
# (`stochastic_rs`) is produced by `cargo build -p stochastic-rs-py` or
# via `maturin develop` from the `stochastic-rs-py` directory.
python = [
    "dep:pyo3",
    "dep:numpy",
    "stochastic-rs-distributions/python",
    "stochastic-rs-stochastic/python",
    "stochastic-rs-copulas/python",
    "stochastic-rs-stats/python",
    "stochastic-rs-quant/python",
]
mimalloc = ["dep:mimalloc"]
yahoo = [
    "dep:time",
    "dep:yahoo_finance_api",
    "dep:polars",
    "dep:tokio-test",
    "stochastic-rs-quant/yahoo",
]
hotpath = ["dep:hotpath", "hotpath/hotpath"]
hotpath-alloc = ["hotpath", "hotpath/hotpath-alloc"]

[lib]
name = "stochastic_rs"
crate-type = ["lib"]
path = "src/lib.rs"
doctest = false

[profile.release]
debug = false
codegen-units = 1
lto = true

[package.metadata.docs.rs]
# Avoid `all-features = true`: it pulls in native GPU SDKs (cubecl-cuda,
# cudarc, metal), system OpenBLAS, pyo3 link, and yahoo's tokio-test
# dev-only feature, none of which build cleanly on docs.rs.
features = ["openblas", "ai", "yahoo"]
rustdoc-args = ["--html-in-header", "docs/katex-header.html"]
