Derivatives for developers

Derivatives for developers. What the products are and why they exist, how they’re priced and risked, and what happens to a trade over its life — then the stochastic calculus behind the option pricers, taught at engineer’s level: every rule verified numerically before it’s derived, every page with a check that fails if you’ve misunderstood it.

Part 0 — Orientation

0.1Why derivatives exist

Risk transfer; hedgers, speculators, market makers; OTC vs exchange-traded.

0.2Linear vs nonlinear

The thesis, a map of the parts, how to use the demos and checks.

0.3Conventions

Notation, units (annualised vol, continuous vs simple rates, day counts), prerequisites, how to run the code.

Part 1 — Products

Each page: what it is · who needs it and why · how it’s priced · how it’s risked · lifecycle from booking to settlement.

1.0Cash and discountingTBC

Time value, discount factors, zero and forward curves, compounding conventions.

1.1ForwardsTBC

Cash-and-carry gives F = S·e^((r−q)T) with no stochastics at all; MTM value after inception; delta of one.

1.2FuturesTBC

Exchange-traded forwards: clearing, initial and variation margin, daily settlement, rolling; why they exist (credit risk removed, liquidity); basis risk.

1.3SwapsTBC

Interest rate swaps: PV(fixed) − PV(float), the par rate, why the floating leg is worth par at a reset; PV01 and bucketed curve risk; fixings, resets, netting, collateral.

1.4OptionsTBC

Calls, puts, payoffs, moneyness, intrinsic vs time value; why they exist (asymmetry, leverage, income); European vs American. The price is the cost of hedging.

1.5The trade lifecycle and the risk systemTBC

Capture → confirmation → settlement → lifecycle events → EOD risk and P&L → reporting. Why the batch reruns everything overnight.

Part 2 — Stochastic calculus

Engineer’s level: every rule is verified numerically before it’s derived. Python/numpy experiments while learning; the same invariants become library tests.

2.1Random walks and scaling

Variance adds, standard deviation doesn’t: √n. Why the continuous limit needs increments of size √dt.

2.2Brownian motion

Continuous everywhere, differentiable nowhere, and the same roughness at every magnification. Independent Gaussian increments, martingale, Markov; simulated as a cumulative sum of √dt·Z.

2.3Quadratic variation

Σ(ΔW)² → T while Σ|ΔW| → ∞. The rulebook: (dW)² = dt, dW·dt = 0, (dt)² = 0. The whole reason ordinary calculus fails.

2.4The Itô integral

Left-endpoint sums and why (non-anticipation); ∫W dW = ½W_T² − ½T; zero mean, martingale, Itô isometry; Stratonovich as an aside.

2.5Itô’s lemma

Second-order Taylor plus the rulebook: df = (∂f/∂t + a·∂f/∂x + ½b²·∂²f/∂x²)dt + b·∂f/∂x dW. Worked: W², log S, e^(W−t/2).

2.6SDEs and geometric Brownian motion

dS = μS dt + σS dW; solve via log S; the −½σ² correction (mean vs median, volatility drag); exact sampling vs Euler–Maruyama; where the √dt comes from.

2.7Delta hedging and the Black–Scholes PDE

Π = V − ΔS; Itô on V; choose Δ = ∂V/∂S to kill dW; risk-free must earn r; μ vanishes.

2.8Risk-neutral pricing

V = e^(−rT)·E^Q[payoff]; drift becomes r; Girsanov as reweighting paths, not changing volatility; Feynman–Kac ties the expectation to the PDE.

2.9The Black–Scholes formula

Derive by integrating the lognormal against the payoff; what N(d₁) and N(d₂) mean; put–call parity; dividends; Black-76 for forwards and futures.

2.10Greeks

Delta, gamma, vega, theta, rho — what each measures and who watches it. The PDE re-read as a P&L statement: theta pays for gamma.

2.11Where it breaks

Constant vol, continuous frictionless trading, lognormal returns vs reality; smile and skew; why the model survives as a quoting convention (vol is the unit of price).

Part 3 — Implementation

3.1Closed form in codeTBC

N(x) numerics; edge cases (T→0, σ→0, deep ITM/OTM); units and conventions; reference implementation and its tests.

3.2Monte CarloTBC

Exact GBM vs Euler; standard error and convergence; antithetics and control variates; seeds and reproducibility; parallelism; when MC is the only option.

3.3Finite differencesTBC

Discretise the PDE; explicit, implicit, Crank–Nicolson; stability; American options via early exercise; when PDE beats MC.

3.4Implied vol and the surfaceTBC

Root finding; the surface as an object; interpolation; where it lives in the system and who owns it.

3.5Greeks in practiceTBC

Analytic vs bump-and-revalue (bump sizes, MC noise) vs pathwise and AAD; what’s actually on the risk report.

3.6In the systemTBC

Pricing library ↔ market data ↔ trade store ↔ risk engine; the EOD batch; P&L explain; model validation; why the quant’s library has separate model and calibration layers.

3.7Reading QuantLibTBC

How the QuantLib-Python oracle generates the golden values, and how to read the library those values come from.

Part 4 — Later

v2 candidates, not commitments: vol surfaces properly (arbitrage-free interpolation, SVI) · local vol (Dupire) · stochastic vol (Heston) · jumps · rates (curve building, multi-curve, caps and swaptions, SABR) · exotics (barriers, Asians, digitals and why they’re hard to hedge) · American options in depth · counterparty risk (CVA) · credit (CDS).