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 CarloMy 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.
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 ↗| method | steps / pairs | price | abs err vs BS |
|---|---|---|---|
| CRR | 10 | 10.2534 | 2.0e-1 |
| CRR | 50 | 10.4107 | 4.0e-2 |
| CRR | 100 | 10.4306 | 2.0e-2 |
| CRR | 500 | 10.4466 | 4.0e-3 |
| CRR | 1,000 | 10.4486 | 2.0e-3 |
| MC | 10,000 | 10.4227 ± 0.0729 | 2.8e-2 |
| MC | 100,000 | 10.4634 ± 0.0233 | 1.3e-2 |
| MC | 1,000,000 | 10.4518 ± 0.0074 | 1.2e-3 |
| greek | analytic | finite diff |
|---|---|---|
| delta | 0.6368 | 0.6368 |
| gamma | 0.0188 | 0.0188 |
| vega | 37.5240 | 37.5240 |
| rho | 53.2325 | 53.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.