Quant / Software · Maintained software

C++ Options Pricer

Black–Scholes, binomial-tree and Monte Carlo option pricing in C++20.

My role
Independent developer
Period
2026
Source
Public repository

The question

When should independent pricing methods agree, and how do I test the disagreement?

C++20 · CMake · Black–Scholes · CRR · Monte Carlo
K = 100S = 60S = 140EUROPEAN CALL / VOLATILITY 10 · 20 · 40%
European call priceAnalytic illustration · r = 5% · T = 1 · q = 0

My contribution

Implemented a C++20 pricing library, command-line validation harness, and numerical consistency tests.

01 / problem

Pricing methods

This educational library compares a closed-form expression, a discretized tree and a stochastic estimate using shared option inputs.

Validation compares prices against references, tree convergence against the closed-form value, and analytic Greeks against finite differences.

02 / architecture

Architecture

  • Shared option specifications and payoff definitions keep contract inputs consistent across methods.
  • Black–Scholes handles European calls and puts with continuous dividend yield and analytic Greeks.
  • A Cox–Ross–Rubinstein tree supports European and American exercise through backward induction.
  • Terminal-GBM Monte Carlo uses antithetic samples and reports an estimated standard error.
  • A command-line harness runs comparisons and can export structured JSON results.

03 / decisions

Sampling error and convergence

The Monte Carlo result includes sampling uncertainty rather than presenting one draw as an exact answer. Seeded sampling makes numerical checks reproducible. The binomial implementation exposes a discretization choice, so convergence can be examined instead of hidden.

Input validation and common contract definitions reduce the chance that two methods appear to disagree simply because they were given different inputs.

04 / evaluation

Numerical tests

  • Reference call and put prices, plus put–call parity under the same assumptions.
  • CRR convergence toward the European closed-form price and an American exercise-value check.
  • Monte Carlo comparison against the closed-form value using its estimated sampling error.
  • Finite-difference checks for analytic Greeks, invalid-input checks, and a GitHub Actions build/test workflow.

05 / limitations

Limitations

The methods use simplified model assumptions. The project does not provide volatility calibration, live market-data ingestion, trade execution, or evidence of investment performance. Agreement between methods is agreement under their shared assumptions.

The interactive Black–Scholes calculation on this website is a separate JavaScript implementation. The repository viewer shows the actual C++ source; the browser does not execute that C++ library.

06 / next

Next steps

A natural next extension is a documented sweep across contract inputs and discretization choices, so the limits of convergence and numerical stability become as visible as the reference example. That is an extension direction, not a completed feature.

Interactive illustration

Black–Scholes calculator

This is a separate JavaScript Black–Scholes illustration, checked against reference call/put values and put–call parity. It assumes a European option, constant volatility, a constant continuously compounded rate and no dividends. It does not run the repository’s C++ code.

Black–Scholes · browser demo
European option
Model price / USD$10.45
Delta +0.6368
Call option price against underlying priceAt an underlying price of $100 and 20% volatility, the model price is $10.45 and delta is 0.6368. The curve shows underlying prices from $60 to $140 with the other inputs fixed.0153045606080100120140
$100
20%

A reproduced C++ run

Recorded reference output.

Recorded on 8 September 2026 using C++20, AppleClang 21 and libc++. The European call inputs are S = K = 100, r = 0.05, q = 0, σ = 0.2 and T = 1 year. Monte Carlo uses seed 42; the reported sample sizes count antithetic pairs.

These values document that run. Random draws can differ between standard-library implementations, even with the same seed.

Inspect the pinned C++ harness ↗
RECORDED C++ OUTPUT · FIXED INPUTS
European call · S=100 K=100 r=0.05 q=0 σ=0.2 T=1y. Black–Scholes = 10.4506. CRR and Monte Carlo converge toward the same benchmark under the same model assumptions.
▌ CONVERGENCE
CRR and Monte Carlo price convergence toward the Black–Scholes reference price.
methodsteps / pairspriceabs err vs BS
CRR1010.25342.0e-1
CRR5010.41074.0e-2
CRR10010.43062.0e-2
CRR50010.44664.0e-3
CRR1,00010.44862.0e-3
MC10,00010.4227 ± 0.07292.8e-2
MC100,00010.4634 ± 0.02331.3e-2
MC1,000,00010.4518 ± 0.00741.2e-3
▌ GREEKS · ANALYTIC vs FINITE DIFFERENCE
Analytic option Greeks compared with finite-difference verification values.
greekanalyticfinite diff
delta0.63680.6368
gamma0.01880.0188
vega37.524037.5240
rho53.232553.2325
theta-6.4140-6.4140

Source

Selected public files, with commit references and links to GitHub.

Public overview reviewed 8 September 2026. Repository commit: 2026-08-31.

C++ Options Pricer · Laith Masri EngTech TMIET