Tutorials

The following are a series of articles written by me with the help of Claude, which dig into some interesting topics in the fields of Exotic Option Pricing, Algorithmic Trading and Convex Optimisation. They are written in a more pedagogical and less formal way than many articles or books. The key focus here is on intuition and understanding the application of the models.

Exotic option pricing

Stochastic Calculus — the calculus of random paths, and why finance is built on it

Ordinary calculus is the mathematics of smooth curves: things with a slope, a tangent, a well-behaved rate of change. The price of a stock, the level of an interest rate, the value of a hedge—none of these are smooth. They jitter endlessly, and the jitter does not vanish when you look closely; it is the whole point. Stochastic calculus is the calculus built for such objects, and it rests on one surprising fact: random noise accumulated over time has a size that ordinary calculus throws away. Written compactly that fact is (\dd W)^2=\dd t, and almost everything in this note is that one idea wearing a different hat. We start from Brownian motion and build the two tools a working quant uses every day—the Itô integral and Itô’s lemma—then solve the two canonical models, geometric Brownian motion and the Ornstein–Uhlenbeck process. From there we assemble the engine that turns a model into a price—martingales, Girsanov’s change of measure, the Feynman–Kac bridge between expectations and partial differential equations, and risk-neutral pricing—and put it to work pricing options in closed form: Black–Scholes, the exchange option, and the early-exercise (American) option. We then take the Markovian property seriously—the difference between a model whose future needs only its present (and so collapses to a fast, low-dimensional PDE or tree) and one that drags its whole history behind it (path dependence, rough volatility). Finally we put it all to work on the term structure of interest rates, building the Heath–Jarrow–Morton framework from scratch, deriving its no-arbitrage drift, and showing exactly when it collapses back to a one-factor Hull–White model. The aim throughout is intuition first, a figure for every idea, and just enough mathematics to make the intuition rigorous—and to leave you able to read the other notes in this series unaided.

Download PDF

A hundred-minute walk through the note, from why ordinary calculus breaks to the Heath-Jarrow-Morton framework.

The Dupire Local Volatility Model — the one model that fits every vanilla, and the one promise it breaks

Black–Scholes assigns one volatility to an asset; the option market quotes a different implied volatility for every strike and every maturity. That gap—the volatility smile—is not noise, and no single number can close it. Bruno Dupire’s 1994 insight was that we do not need a single number: if we let instantaneous volatility be a deterministic function \sloc(t,S) of time and spot, then there is exactly one such function that reprices the entire surface of traded vanilla options, and it can be read straight off market prices by a single formula. This note builds that result from the ground up. We start from the smile itself, recover the risk-neutral density from option prices (Breeden–Litzenberger), derive Dupire’s forward equation and the formula it yields, and then re-read that formula two ways—in terms of quoted implied volatilities, and as a conditional average of the “true” instantaneous volatility. We then show how the formula must be amended once interest rates are stochastic—where a correlation-dependent correction term appears and the model-free “read it off the surface” property is partly lost—and how the model is used to hedge: the behaviour of its Greeks, the backbone that biases its delta, and the vega matrix that turns an exotic’s volatility risk into a basket of vanillas. We close with what local volatility is excellent at (a perfect, unique, arbitrage-free fit to today’s surface) and the one thing it gets wrong—the dynamics of the future smile—which is exactly where stochastic volatility takes over. Appendices collect the supporting detail kept out of the main line of argument: the Black–Scholes formula and backward PDE, the Fokker–Planck equation and the full forward-equation derivation, the implied-variance form with its short-maturity “rule of two,” the SVI/SSVI surface parametrisation used to generate every figure, the change the formula needs once interest rates are stochastic, and the risk decompositions behind the Greeks. The local-volatility model is extracted from a synthetic market surface and then Monte-Carlo simulated to confirm it reprices that surface.

Download PDF

A hundred-minute walk through the note, from the problem Black-Scholes leaves behind to the forward smile and what comes next.

Hull–White Short-Rate Models

Modelling interest rates is harder than modelling a stock, and the difference is structural, not merely technical. A stock is one number; a rate market is an entire curve—a discount factor for every maturity—which the model must move coherently, which performs its own discounting, and which it must match exactly today or admit arbitrage. This note builds the Hull–White model from that starting point. It opens by starting from the familiar equity-derivatives picture—a single underlying—and stepping to a whole term structure, and the requirements that leap imposes—then meets them the way a short-rate model does: collapse the curve onto one mean-reverting rate, and fit today’s prices with a free, time-dependent drift. Part I develops the one-factor model—the Gaussian short rate, the drift that fits the curve, the affine bond-price formula, the vanilla options it prices in closed form (with a worked caplet), how its two parameters are calibrated, the smile it cannot make, and the early-exercise exotics it values on a lattice—before exposing the one thing a single factor cannot do: move rates at different maturities by anything other than lockstep. Part II adds a second factor (the G2++ model) so the curve can twist as well as shift, decorrelating rates and fitting a humped volatility term structure a single factor misses. Throughout, the spine is a two-layer split—a drift that nails today’s curve exactly, and a few volatility parameters left for the dynamics—and a diagram for every idea.

Download PDF

A hundred-minute walk through the note, from one number to a whole curve, through to what two factors price.

Local Stochastic Volatility

A local-volatility model fits today’s vanilla surface exactly but makes a specific, empirically wrong prediction about the future smile: it flattens. This note traces that defect from the start—where the skew comes from, how diffusion averages it away over a forward-start horizon, and why a stochastic-volatility process does not suffer the same fate—and then builds the cure. Local stochastic volatility (LSV) marries the two: a stochastic variance for realistic dynamics, scaled by a deterministic leverage function that restores the exact vanilla fit. We motivate the leverage function through Gyöngy’s mimicking theorem, show why calibrating it is a fixed-point problem solved by bootstrapping forward in time, and develop the two work-horse solvers—the forward-PDE (Fokker–Planck) method and the particle (Monte-Carlo) method—in detail, with pseudocode for each. Appendices cover the supporting numerics: explicit versus implicit finite differences and the Craig–Sneyd ADI scheme, Euler–Maruyama time stepping, and kernel-weighted regression.

Download PDF

A hundred-minute walk through the note, from the trade-off that motivates everything to calibrating the parameters.

The Longstaff–Schwartz Method — American Monte Carlo

A European option is easy to price by simulation: scatter a few hundred thousand random futures, average the discounted payoff, done. An American option—one its owner may cash in at any time, not only at the end—breaks that recipe, and the reason is structural, not technical. Its value is the solution of an optimal-stopping problem: at every moment the holder must weigh the payoff from exercising now against the value of holding on, the continuation value, which is an expectation over all the futures that have not happened yet. Trees and finite-difference grids compute that expectation by folding backward through time, but they collapse once there is more than a handful of underlyings. Monte Carlo scales to high dimension effortlessly—but it runs forward, and a single simulated path never sees the conditional expectation it would need to make the exercise decision. The Longstaff–Schwartz method is the bridge between the two. Its one idea is disarmingly simple: at each exercise date the simulated paths already form a cloud of points—where the underlying is now, and what each path went on to pay—and a least-squares regression through that cloud is the continuation value. Estimate it, compare it to the immediate payoff, and you have an exercise rule; replay the rule and you have a price. This note builds the method from the optimal-stopping problem up to a working algorithm, prices a small example entirely by hand, and is candid about where the bias hides and what the method cannot do. Throughout, the spine is one sentence—Monte Carlo runs forward, early exercise reasons backward, regression is the bridge—and a diagram for every idea.

Download PDF

A ninety-minute walk through the note, from the early-exercise problem to what regression can and cannot do.

The Quadratic Gaussian Model — the smile a short rate can make

The one-factor Hull–White model is a beautiful machine, and it has two holes in it. Because its short rate is Gaussian, that rate can wander below zero with real probability; and because it is Gaussian, the implied-volatility smile it makes is flat—a fixed shape, with no parameter left to bend it across strike. Both limitations have the same root: a Gaussian rate. This note develops a model that keeps almost everything good about Hull–White while fixing both, through a single change of variable: let the short rate be a quadratic function of a Gaussian factor, r_t=x_t^2+\beta x_t+\phi(t). Squaring a Gaussian gives a rate that cannot fall below a hard, tunable floor, and whose own volatility grows with its level—which is exactly a volatility skew. Remarkably, the tractability survives: bond prices are no longer exponential-affine but exponential-quadratic, with coefficients that solve a Riccati equation, and vanilla options reduce to one-dimensional Gaussian integrals because the driving factor stays Gaussian under the pricing measure. We recap only what we reuse from the companion Hull–White note, then build the quadratic Gaussian model from its two-layer spine—a drift that fits today’s curve exactly, and a few volatility parameters for the dynamics—show the floor and the skew it produces, price caps and swaptions, calibrate it, and work through the products a single Gaussian factor simply cannot price: out-of-the-money caps and floors, the swaption skew, convexity-sensitive CMS, and floored or capital-guaranteed notes.

Download PDF

A hundred-minute walk through the note, from the two gaps Hull-White leaves to choosing between models.

A Practical Introduction to the LIBOR Transition

For half a century the world’s interest-rate contracts were written on LIBOR: a term, forward-looking, credit-bearing rate you knew at the start of every period. The benchmarks that replaced it—SOFR, SONIA, €STR and their peers—are the opposite in every one of those respects: overnight, backward-looking, nearly risk-free rates known only at the end of a period. This note explains, for a reader who already knows risk-neutral pricing and the basics of exotic derivatives, what that inversion forces on every curve and every product. The organising idea is that the whole transition is, at heart, a change of projection index. We build the multi-curve picture that makes that statement precise—one discount curve, one projection curve per index—and show that swapping LIBOR for a compounded overnight rate is exactly a change of the projection curve, while the discount side had already moved years earlier, when collateral agreements pushed discounting onto the OIS curve. Along the way we meet the one genuinely new piece of mathematics the exotics desk has to absorb: a backward-looking compounded rate has a clean forward with no convexity adjustment when it is paid in the natural place, because compounding the overnight rate simply rebuilds the bank account—so the interesting optionality lives not in the vanilla coupon but in timing, in-advance conventions, and options observed during the accrual period. We close with the machinery that makes the switch fair and legally clean: the ISDA fixed spread adjustment, the fallback protocol, and the discount-curve “big bang”.

Download PDF

A hundred-minute walk through the note, from why LIBOR had to go to the hedging landscape that replaced it.

A Practical Introduction to Commodity Option Pricing

A commodity is not a stock. A stock is a claim that lives in a brokerage account and, under the risk-neutral measure, grows at the funding rate; a barrel of oil is a thing that sits in a tank, costs money to store, pays no dividend, and is bought by refineries rather than investors. That single difference—the underlying is something you store and consume—reorganises the whole of option pricing. The spot price is often not even a tradable object, so the market prices a forward curve of futures instead, its shape set by storage costs, convenience yield and seasonality; prices mean-revert toward the cost of production instead of compounding; and volatility depends on which point of the curve you look at, rising sharply as a contract approaches delivery. This note builds commodity option pricing from that starting point, for a reader who knows Black–Scholes-level risk-neutral pricing but no commodities. We establish the cost-of-carry relation and where it breaks, show why the futures—a martingale under the pricing measure—is the natural underlying, and derive Black-76, the workhorse vanilla formula. We then put dynamics under the curve: the Schwartz one-factor mean-reverting model and its saturating variance, the two-factor Schwartz–Smith model that lets the short end and the long end move separately, and deterministic seasonality. The last third treats what the desks actually trade: Asian options on settlement averages, spread options on refining and generation margins where the correlation is the price, swing and storage contracts that are options on volume, and the power market, where storage is impossible, the carry argument dies, and spot dynamics turn spiky enough that the whole toolkit has to be rebuilt on forwards.

Download PDF

A ninety-minute walk through the note, from why a commodity is not a stock to swing, storage and power.

Algorithmic trading

Time-Series Analysis for Pairs Trading and Cointegration — trading the gap between two prices, not the direction of either

Most ways of making money in markets are a bet on direction: buy something you think will go up. This note is about a different kind of bet—one that is deliberately indifferent to whether the market rises or falls, and pays off instead when the gap between two related prices closes. The catch is that “related” has to mean something much stronger than “they look like they move together”. Two prices can rise and fall in near-lockstep for years and still drift apart forever; betting on their gap is then a slow way to lose money. The property that actually licenses the trade is cointegration: although each price wanders unpredictably on its own, some fixed combination of the two is tethered to a constant level and keeps returning to it. This note builds the idea from the ground up. We start with why a single price is essentially untradeable on its own (it is a random walk), explain the statistical test that tells a genuine tether from a mirage, construct the trade from the tethered combination, and then scale the whole apparatus up from a pair to a whole basket of assets using vector autoregressions, the Johansen procedure and the vector error-correction model. Throughout, we keep an eye on the real failure mode—tethers that hold in the data you fit and snap in the data you trade.

Download PDF

A hundred-minute walk through the note, from trading the gap between two prices to what happens when the tether breaks.

The Kalman Filter and Hidden Markov Models — tracking what you cannot see, in markets and elsewhere

A price on a screen is not the thing you want to trade on. It is a noisy, fleeting shadow of something you cannot see directly: a fair value, a hedge ratio, a market mood. This note is about a single, powerful idea for recovering that hidden thing as it changes—the state-space model, and the filtering recursions that estimate its hidden state one observation at a time. Two filters dominate practice and differ only in the shape they assume for the hidden state. The Kalman filter takes the state to be a continuous number (or a short vector of numbers) that drifts smoothly—a fair value, a trend, a regression coefficient—and, under linear-Gaussian assumptions, tracks it with nothing more than a running mean and variance updated by a beautifully simple rule. The hidden Markov model (HMM) takes the state to be a discrete regime—calm versus turbulent, trending versus ranging—that switches at random times, and infers from the data which regime you are probably in right now. We build both from the same Bayesian skeleton, derive their update rules from first principles (with the linear algebra quarantined to appendices), and show each at work on a canonical trading problem: the Kalman filter on a drifting pairs-trading hedge ratio, the HMM on volatility regimes. The pairs-trading example is a deliberate sequel: the companion note A Practical Introduction to Time-Series Analysis for Pairs Trading and Cointegration  builds the trade with a hedge ratio fitted once and held fixed; here we let that ratio become a hidden state that drifts, and track it in real time. We close with an candid account of where these models help, where they mislead, and how to tell the difference.

Download PDF

A hundred-minute walk through the note, from a hidden state and its noisy shadow to a pairs trade through a regime break.

Convex optimisation

Semidefinite Programming — convex optimisation, from numbers to matrices

Most accounts of optimisation draw the important line in the wrong place. The line that matters is not between linear and nonlinear problems but between convex and nonconvex ones: convexity is what lets you trust an answer and, remarkably, lets the problem hand you a short proof that the answer is optimal. This note develops that idea and follows it to its richest practical conclusion, the semidefinite program (SDP). We climb a single ladder—optimise over numbers, then over vectors confined to a cone, then over matrices required to be positive semidefinite—and show that all three rungs are the same conic template wearing progressively roomier clothes. The positive semidefinite cone is the hero of the story: the most expressive convex set we can still optimise over efficiently. We explain what the constraint X \psd really means (it has four equivalent disguises), how a surprising range of problems collapses into an SDP through the Schur complement, why every SDP comes paired with a dual that certifies optimality, and how interior-point methods actually solve one using the -\log\det barrier. We close with three worked examples—the nearest correlation matrix, Lyapunov stability, and the Goemans–Williamson relaxation of Max-Cut—and a forty-line solver you can read in one sitting.

Download PDF

A hundred-minute walk through the note, from why convexity is the watershed to Max-Cut and the limits of relaxation.

Numerical methods

A Practical Introduction to Adjoint Algorithmic Differentiation for Greeks

A pricing model returns one number. A risk manager needs hundreds: the sensitivity of that number to every spot, every point of every volatility surface, every tenor of every curve, every correlation. The oldest way to get them is to nudge each input in turn and reprice, which costs one revaluation per input. For an exotic options book priced by Monte Carlo, that arithmetic is the binding constraint on how often risk can be computed and how finely it can be decomposed. Adjoint algorithmic differentiation removes the constraint. It treats the pricer not as a formula to be re-derived but as a program—a graph of elementary operations—and applies the chain rule to that graph backwards, from the output towards the inputs. One backward sweep produces the entire gradient, and a theorem guarantees it costs no more than a small constant multiple of a single pricing, independent of how many inputs there are. This note develops that idea from the chain rule, for a reader comfortable with calculus and Monte Carlo but assuming no background in automatic differentiation or derivatives risk. We build a working adjoint engine, check it against closed-form Black–Scholes Greeks to machine precision, and measure its cost on a worst-of autocallable: the full gradient arrives in 4.2\times the time of one price, where central bumping would need 2n. We then treat what makes exotics hard—discontinuous payoffs that defeat the pathwise derivative, the memory cost of the tape and how checkpointing buys it back, second-order risk by forward-over-reverse, and the calibration step, whose adjoint converts model sensitivities into the market sensitivities a desk can actually hedge with.

Download PDF

An eighty-minute walk through the note, from why bumping does not scale to a working reverse-mode tape.