High-performance quantitative finance in Rust. Derivatives pricing, funding and rates analytics, credit, risk, structured products, and tooling built around a shared Rust core.
OpenFerric is a Rust library first, but this repository also ships Python bindings, WebAssembly bindings, an Excel add-in, a VS Code extension and LSP for the OpenFerric DSL, and an MCP server for tool-driven integrations.
- Trait-based pricing core built around
Instrument + Market + PricingEngine -> PricingResult. - Broad product coverage across equity, FX, rates, credit, volatility, structured products, and portfolio risk.
- Funding-rate analytics for Boros/Pendle-style swaps, including multi-venue curves, rolling stats, liquidation and margin simulation, and piecewise-linear or piecewise-constant interpolation.
- Structured product DSL with
.ofexamples, a VS Code pricing dashboard, and an LSP-backed editing experience. - Multiple delivery surfaces from one Rust core: crate, Python package, WebAssembly, Excel add-in, and MCP server.
- Performance-oriented execution with SIMD, parallel Monte Carlo, optional WebGPU, and optional Cranelift JIT support.
- Reference-validated tests against QuantLib, Haug, Alan Lewis, Fabozzi, and other external sources.
- Example hosted demo: openferric.netlify.app (example only, not the primary supported distribution surface)
- Rust examples:
examples/and docs/EXAMPLES.md - Python funding walkthrough: examples/boros_funding_swap.py
- DSL guide: docs/dsl.md
- DSL sample products:
examples/dsl/
cargo add openferricuse openferric::core::PricingEngine;
use openferric::engines::analytic::BlackScholesEngine;
use openferric::instruments::VanillaOption;
use openferric::market::Market;
let market = Market::builder()
.spot(100.0)
.rate(0.05)
.dividend_yield(0.0)
.flat_vol(0.20)
.build()?;
let option = VanillaOption::european_call(100.0, 1.0);
let result = BlackScholesEngine::new().price(&option, &market)?;
println!("price = {:.4}", result.price);
println!("delta = {:.4}", result.greeks.delta);| Component | Purpose |
|---|---|
src/ |
Core Rust library for pricing, rates, credit, volatility, calibration, models, DSL, and risk |
python/ |
PyO3 bindings for Python workflows and notebooks |
wasm/ |
wasm-bindgen bindings for browser and WebAssembly consumers |
excel-addin/ |
Excel add-in powered by the WASM build |
vscode-ext/ + lsp/ |
VS Code extension and language server for .of DSL files with a pricing dashboard |
mcp/ |
MCP server exposing OpenFerric functionality as callable tools |
Full coverage notes live in docs/COVERAGE.md. The current repo covers:
- Equity and FX: Black-Scholes, barriers, digitals, Asians, lookbacks, spreads, baskets, rainbows, power options, convertibles, employee stock options, and more.
- Volatility and calibration: Heston, SABR, SVI, local vol, Andreasen-Huge, Fengler, vanna-volga, forward variance, mixture models, and implied vol tooling.
- Rates and funding: yield curves, bonds, swaps, FRAs, caps/floors, swaptions, OIS, inflation, CMS, cross-currency products, funding-rate curves, and funding-rate swaps.
- Credit and XVA: survival curves, CDS, CDS options, CDS indices, nth-to-default baskets, CDO tranches, Gaussian copula, and XVA analytics.
- Structured products and DSL: autocallables, phoenix notes, range accruals, TARFs, MBS pass-throughs, IO/PO strips, and a dedicated product DSL.
- Risk and scenarios: VaR, Expected Shortfall, SA-CCR, portfolio aggregation, margin simulation, liquidation simulation, and stress workflows.
- Numerical engines: analytic pricers, trees, PDEs, Monte Carlo, FFT, SIMD paths, GPU support, and optional JIT-backed DSL execution.
| Benchmark | Throughput |
|---|---|
| Black-Scholes (single) | 88 ns / 11.3M ops/sec |
| Black-Scholes SIMD batch | 69M options/sec (1.8x scalar) |
| Normal CDF (SIMD) | 283M evals/sec (2.1x scalar) |
| Barrier analytic | 168 ns / 6M ops/sec |
| Heston semi-analytic | 3.9 µs / 256K ops/sec |
| American binomial (500 steps) | 1.9 ms |
| Monte Carlo 100K paths | 406 ms |
| Vol surface recalibration | < 50 ms (20 expiry slices) |
| Feature | Description |
|---|---|
parallel |
Rayon-parallel Monte Carlo and parallel-enabled benchmark/test paths |
simd |
SIMD code paths for AVX2 and NEON-enabled workloads |
gpu |
WebGPU support for GPU-accelerated pricing paths |
jit |
Cranelift-backed JIT support for DSL execution |
Core Rust workflow:
cargo build
cargo build --release
cargo fmt --all --check
cargo clippy --workspace --all-targets --features parallel,simd
cargo test --workspace --features parallel,simd
cargo benchTypeScript and Python linting:
npm ci
npm run typecheck
npm run lint
ruff check python/ examples/
ruff format --check python/ examples/Python package:
maturin build --release -m python/Cargo.toml
pip install target/wheels/*.whl
pytest python/tests/ -vWASM build:
wasm-pack build wasm --target web --out-dir ../www/pkgCoverage helpers:
make install-coverage
make coverage-test
make coverage-bench
make coverage-bench-parallel
make coverage-all
make coverage-lcovOpenFerric uses externally validated references rather than self-generated assertions wherever practical.
- QuantLib is vendored as a git submodule at
vendor/QuantLib/for reproducible cross-checks. - The test suite includes reference cases from Haug, Alan Lewis, Fabozzi, and other published sources.
- Integration tests live in
tests/, while module-level unit tests stay close to implementation code.
See docs/REFERENCES.md for source material and docs/EXAMPLES.md for end-to-end usage examples.
- Python bindings README
- Excel add-in README
- OpenAssay for SQL-oriented integration work
MIT