A high-performance C++ framework for derivative valuation and quantitative risk analytics.
Disclaimer: This was not vibe coded. Every line and comment was written with intent and validated against closed-form analytical solutions, because a Monte Carlo engine that hasn't been sanity-checked against Black-Scholes is just an expensive random number generator.
Martingale is a C++ derivatives pricing engine built from first principles. It simulates the evolution of asset prices under the risk-neutral measure
Under
where
The name comes from the mathematical concept of a martingale process, which is the foundation of risk-neutral pricing in quantitative finance. When the asset price is discounted by the risk-free money-market account, the resulting process is a martingale under
This is precisely what guarantees an arbitrage-free price.
Integrating the GBM SDE exactly gives the terminal stock price under the risk-neutral measure:
The present value of any European-style instrument is then:
where
For path-dependent instruments the payoff
Asian options replace
The geometric average variant
Barrier options add a knock-out condition: a down-and-out call pays the vanilla
call payoff only if the asset never touches the barrier
The continuous-monitoring closed-form (Rubinstein & Reiner, 1991) for
clang++org++with C++20 support
c++ -std=c++20 -O2 -Iinclude \
src/Option.cpp src/Payoff.cpp src/PathPayoff.cpp src/PathOption.cpp \
src/MonteCarloPricer.cpp src/main.cpp \
-o option_pricer && ./option_pricerc++ -std=c++20 -O2 -Iinclude \
src/Option.cpp src/Payoff.cpp src/PathPayoff.cpp src/PathOption.cpp \
src/MonteCarloPricer.cpp tests/test_pricer.cpp \
-o test_pricer && ./test_pricerMIT License © 2026 Gunj Joshi
You are free to use, modify, and distribute this software, provided that the original copyright notice and this permission notice are included in all copies or substantial portions of the software.