§1.4 — Trading
Derivatives Pricer (C++)
From-scratch closed-form Black-Scholes option pricer in C++, exposed to Python via pybind11 bindings.
real prices, S=70–130, K=100, T=0.5yr, r=5%, σ=25%
›the formula
Closed-form European option pricing: C = S·N(d₁) − K·e−rT·N(d₂), P = K·e−rT·N(−d₂) − S·N(−d₁), with d₁ = [ln(S/K) + (r + ½σ²)T] / (σ√T) and d₂ = d₁ − σ√T.
N(·) is the standard normal CDF, implemented directly via the complementary error function (0.5·erfc(−x/√2)) rather than a series approximation or a library call — the whole pricer is ~25 lines of real C++, no external math dependency beyond <cmath>.
put-call parity check
The source has no test suite of its own, so this is the actual verification: compiled the real, unmodified black_scholes.cpp with a small driver and confirmed C − P equals S − K·e−rT exactly, at S=100.
real architecture
black_scholes.cpp / .hpp
the pricing core — pure C++, no dependencies
bindings.cpp
pybind11 module exposing black_scholes_price() to Python
CMakeLists.txt
builds the Python extension module via pybind11_add_module
›scope, honestly
European options only — no Greeks, no implied-volatility solver, no American early exercise. It's a small, correct pricing core built to learn the C++/Python binding boundary, not a full pricing library; the parity check above is the real bar it clears, not a claim it does more than this.