Production-grade C++20 options pricing library
Black-Scholes · SABR · Heston · Monte Carlo · Exact Greeks
A modular, production-quality C++20 library implementing major option pricing models with exact analytical Greeks, implied volatility inversion, SABR calibration, and Monte Carlo simulation of exotic payoffs.
| Model | Type | Greeks | Calibration |
|---|---|---|---|
| Black-Scholes | Closed-form | Exact (Δ,Γ,Θ,V,ρ,vanna,volga) | IV via Brent |
| SABR (Hagan 2002) | Approximation | Bump-and-reprice | Full α,ρ,ν fit |
| Heston | Char. function | Bump-and-reprice | Placeholder |
| CRR Binomial | Lattice | - | - |
| Monte Carlo GBM | Simulation | Pathwise differentials | - |
Intel Core i7-12700K, Ubuntu 22.04, GCC 12, -O3 -march=native.
| Operation | Latency |
|---|---|
| BS price (call) | 12 ns |
| BS all Greeks (7) | 38 ns |
| Implied vol (Brent) | 145 ns |
| SABR smile (100 strikes) | 4.2 µs |
| Monte Carlo 100k paths | 18 ms |
| MC with antithetic (100k) | 11 ms (–39%) |
git clone https://github.com/abRH/cpp-options-pricer.git
cd cpp-options-pricer
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
./build/pricer_demo#include "black_scholes.hpp"
#include "sabr.hpp"
using namespace pricer;
// Option
Option opt{.S=100, .K=100, .T=1.0, .r=0.05, .q=0.0, .vol=0.20,
.type=OptionType::Call, .exercise=ExerciseType::European};
// Black-Scholes price + all Greeks
auto g = BlackScholes::greeks(opt);
// price=10.45, delta=0.636, gamma=0.019, vega=0.375, theta=-0.018
// Implied vol
double iv = BlackScholes::implied_vol(opt, 10.45); // → 0.20
// SABR calibration + full smile
SABRParams params = SABR::calibrate(100.0, 1.0, 0.5, strikes, market_vols);
double iv_k = SABR::implied_vol(100.0, 105.0, 1.0, params);
// Monte Carlo with variance reduction
MonteCarlo mc({.n_paths=100000, .vr=VarianceReduction::Antithetic});
auto result = mc.price_european(opt);
// price, std_error, 95% CI- Black, F. & Scholes, M. (1973). The pricing of options and corporate liabilities. JPE.
- Hagan, P. et al. (2002). Managing smile risk. Wilmott Magazine.
- Heston, S. (1993). A closed-form solution for options with stochastic volatility. RFS.
- Hull, J. (2021). Options, Futures, and Other Derivatives. Pearson (11th ed.)
MIT © Abdelmalek Rhayoute