Skip to main content

Crate quantlib_rs

Crate quantlib_rs 

Source
Expand description

§quantlib_rs

A ground-up, idiomatic Rust quantitative finance library inspired by QuantLib.

§Key Architectural Features

  • Fearless Concurrency: All core traits and data structures implement Send + Sync.
  • Generational Handles & Snapshots: Typed generational indices for market observables (QuoteId), avoiding cyclic smart pointers and borrow panics.
  • Machine-Precision Greeks via Autodiff: Stack-allocated forward-mode Dual and Hyper-Dual numbers evaluate exact Greeks in a single pass.
  • Zero unsafe Code: Guaranteed safe Rust under #![deny(unsafe_code)].

§Quickstart

use quantlib_rs::prelude::*;

let today = Date::from_ymd(2026, Month::September, 3).unwrap();
let maturity = Date::from_ymd(2027, Month::September, 3).unwrap();

let spot = 100.0;
let strike = 100.0;
let rate = 0.05;
let dividend = 0.02;
let vol = 0.20;

let process = GeneralizedBlackScholesProcess::new(spot, rate, dividend, vol, today);
let call = EuropeanOption::new(OptionType::Call, strike, maturity);
let engine = AnalyticEuropeanEngine::new(process);

let npv = engine.calculate(&call).unwrap();
let greeks = engine.calculate_greeks(&call).unwrap();

assert!(npv > 0.0);
assert!(greeks.delta > 0.0 && greeks.delta < 1.0);

Modules§

cashflows
Cash flow streams, coupons, and accrued interest analytics.
core
Core traits, market storage, quotes, and generational identifiers.
engines
Pricing engines for financial instruments.
instruments
Financial instruments (options, bonds, swaps).
math
Numerical and mathematical toolkit (interpolation, root solvers, distributions, and automatic differentiation).
prelude
Convenient re-exports of commonly used types and traits.
termstructures
Term structures (yield curves, volatility surfaces, and processes).
time
Time, calendar, day count conventions, and schedule generation.