Skip to content
Sarthak Bagaria
All notes

Model Code

Every formula in the notes has an implementation, and every figure was drawn by one. They live in a small Rust crate with no dependencies.

The same code is compiled twice: natively, to draw the charts in the PDFs, and to WebAssembly, so that the figures on these pages respond when you move a slider. A chart in the PDF and the same chart in the browser are therefore the same model evaluated by the same code.

The tests are part of the explanation and are worth reading. Several claims in the notes — that a lognormal model implies a flat smile, that a local volatility curve has twice the slope of the smile it came from, that a smile does not determine the dynamics — are stated as theorems in the text and checked numerically here.