| Crates.io | quant-opts |
| lib.rs | quant-opts |
| version | 0.1.0 |
| created_at | 2025-12-07 19:05:43.732608+00 |
| updated_at | 2025-12-07 19:05:43.732608+00 |
| description | High-performance Rust library for option pricing and risk |
| homepage | |
| repository | https://github.com/day01/quant-opts |
| max_upload_size | |
| id | 1972095 |
| size | 236,761 |
A high-performance Rust library for option pricing and risk, starting from a fast Black–Scholes–Merton implementation and evolving towards a more general framework (e.g. SABR and other models).
The current codebase is focused on Black–Scholes for European vanilla options. Over time, quant-opts will extend this to a broader set of models and instruments while keeping the API ergonomic and performance-oriented.
VanillaOption, MarketData, OptionStyle, OptionType)The primary way to use quant-opts today is via the core types and the
Black–Scholes model:
use quant_opts::{
BlackScholes, MarketData, OptionStyle, OptionType, VanillaModel, VanillaOption,
};
let option = VanillaOption::new(
OptionStyle::European,
OptionType::Call,
100.0, // strike
20.0 / 365.25, // time to maturity (years)
);
let market = MarketData::new(
100.0, // spot
0.05, // risk-free rate
0.01, // dividend yield
);
// Direct static API with explicit volatility
let price = BlackScholes::price(&option, &market, 0.2)?;
// Or via the generic `VanillaModel` trait
let model = BlackScholes::new(0.2);
let price_via_trait = model.price(&option, &market)?;
Error handling uses Result<_, String> to propagate issues such as
non-finite volatility or zero time to maturity.
For FFI and quick scripting use cases, you can enable the wrappers
feature to get simple function-style helpers:
[dependencies]
quant-opts = { version = "0.1.0", features = ["wrappers"] }
use quant_opts::{wrappers, OptionType};
let price = wrappers::price_eur_vanilla_bs(
OptionType::Call,
100.0, // spot
110.0, // strike
20.0 / 365.25, // maturity (years)
0.05, // risk-free rate
0.05, // dividend yield
0.2, // volatility
)?;
Rust is the primary API, but the library is being designed with FFI in mind. Planned bindings include:
These bindings are part of the roadmap and will be added as the core library stabilizes.
This library is written with performance in mind, both for single-option pricing and large batch workloads. The repository already includes Criterion-based benchmarks and throughput studies.
Up-to-date baseline numbers for pricing, Greeks and implied volatility are
documented in docs/baseline.md. The CI and benchmarking setup is described
in docs/BENCHMARKING.md.
cargo bench --no-default-features --bench pricingcargo bench --no-default-features --bench implied_volatilitycargo bench --no-default-features --bench greekscargo bench --no-default-features --bench single_optioncargo bench --no-default-features --bench single_ivcargo bench --no-default-features --bench single_greekscargo bench --no-default-features --bench batch_pricingcargo bench --no-default-features --bench batch_greekscargo bench --no-default-features --bench throughputcargo bench --no-default-features --bench scalingcargo bench --no-default-features --bench batch_size_studyRun the included examples with:
cargo run --example pricing_and_greekscargo run --example implied_volrustup target add wasm32-unknown-unknown) and wasm-bindgen-cli, then build with --features wasm-example --target wasm32-unknown-unknown --example wasm_api; run wasm-bindgen --target web --out-dir examples/wasm/pkg target/wasm32-unknown-unknown/debug/examples/wasm_api.wasm and open examples/wasm/index.html via a local server. See examples/wasm/README.md.rustup target add wasm32-wasip1 then cargo build --target wasm32-wasip1 --example wasm_cli; run with wasmtime target/wasm32-wasip1/debug/examples/wasm_cli.wasm price --spot ... (see examples/wasm/README.md).Make targets for wasm bindings (requires wasm-pack):
make wasm-bindings → builds web (target/wasm/pkg-web) and bundler (target/wasm/pkg-react) bindingsThis project started as a fork of the excellent blackscholes crate by Hayden Rose. Many thanks for the original implementation and design. The goal of quant-opts is to build on that foundation, extending model coverage and abstractions while preserving and further improving performance.
rust-toolchain.toml)LICENSE.md)CHANGELOG.md