Chapter 26 — Stochastic Calculus and Advanced Pricing

"Itô's lemma is to quant finance what Newton's laws are to physics — the grammar of the universe."


After this chapter you will be able to:

  • Implement Euler-Maruyama and Milstein SDE solvers and verify Itô's lemma numerically
  • State and apply Girsanov's theorem to explain why the Black-Scholes price contains $r$ but not the stock's actual drift $\mu$
  • Use the Feynman-Kac theorem to understand why solving a PDE is equivalent to computing an expectation under the risk-neutral measure
  • Price zero-coupon bonds under the Hull-White model from first principles
  • Compute SABR model implied volatilities using the Hagan et al. approximation

Quantitative finance rests on a mathematical language that is not taught in standard calculus courses. When Fischer Black and Myron Scholes derived their option pricing formula, the critical tool was Itô's lemma — a version of the chain rule that accounts for the fact that Brownian motion is nowhere differentiable. When Vasicek and Cox, Ingersoll and Ross built their interest rate models, they wrote stochastic differential equations and solved for bond prices by deriving and solving PDEs. When modern practitioners change between the physical probability measure (what actually happens) and the risk-neutral measure (what is convenient for pricing), they apply Girsanov's theorem.

This chapter revisits these tools more rigorously than the passing references in earlier chapters. It is a concentrated advanced treatment rather than a first introduction — readers who need to build the foundations from scratch should first read Chapters 3 and 10 and consult a reference such as Shreve's Stochastic Calculus for Finance. The goal here is to give practitioners a working understanding deep enough to read research papers, derive new formulas, and recognise when a standard model is being used outside its domain of validity.

We cover numerical SDE solvers (Euler-Maruyama and Milstein), verify Itô's lemma numerically, work through Girsanov's theorem with a concrete example, and derive the Hull-White zero-coupon bond formula from first principles. We close with the SABR model, the market standard for interest rate options, and its analytic implied volatility approximation.


26.1 Brownian Motion Review

Before applying stochastic calculus, it is worth recalling what makes Brownian motion unusual as a mathematical object. A Brownian motion path $W_t$ is continuous everywhere but differentiable nowhere — at every point, however closely you zoom in, it looks jagged. This is not a numerical artefact but a mathematical certainty: the quadratic variation $\sum_i (W_{t_{i+1}} - W_{t_i})^2 \to T$ as the mesh shrinks, whereas for any smooth function the quadratic variation is exactly zero. This $dW^2 = dt$ rule is the fundamental identity of Itô calculus and the source of all the anomalous terms that distinguish stochastic from ordinary differential equations.

A standard Brownian motion $W_t$ satisfies:

  • $W_0 = 0$
  • Independent increments: $W_t - W_s \perp W_u - W_v$ for $[s,t] \cap [u,v] = \emptyset$
  • $W_t - W_s \sim N(0, t-s)$
  • Continuous paths

Key property: $E[W_t^2] = t$, so $dW \sim \sqrt{dt}$.

module Sde = struct

  (** Euler-Maruyama scheme: X_{t+dt} = X_t + μ(X_t,t)dt + σ(X_t,t)dW *)
  let euler_maruyama ~x0 ~drift ~diffusion ~tau ~n_steps () =
    let dt     = tau /. float_of_int n_steps in
    let sqrt_dt = sqrt dt in
    let path   = Array.make (n_steps + 1) x0 in
    for i = 0 to n_steps - 1 do
      let x = path.(i) in
      let dw = sqrt_dt *. Mc.std_normal () in
      path.(i + 1) <- x +. drift x (float_of_int i *. dt) *. dt
                      +. diffusion x (float_of_int i *. dt) *. dw
    done;
    path

  (** Milstein scheme: includes O(dt) correction term for diffusion *)
  let milstein ~x0 ~drift ~diffusion ~diffusion_deriv ~tau ~n_steps () =
    let dt      = tau /. float_of_int n_steps in
    let sqrt_dt = sqrt dt in
    let path    = Array.make (n_steps + 1) x0 in
    for i = 0 to n_steps - 1 do
      let x  = path.(i) in
      let t  = float_of_int i *. dt in
      let dw = sqrt_dt *. Mc.std_normal () in
      let sig = diffusion x t in
      path.(i + 1) <- x +. drift x t *. dt +. sig *. dw
                      +. 0.5 *. sig *. diffusion_deriv x t *. (dw *. dw -. dt)
    done;
    path

  (** Exact simulation of GBM (no discretisation error) *)
  let gbm_exact ~x0 ~mu ~sigma ~tau ~n_steps () =
    let dt = tau /. float_of_int n_steps in
    let path = Array.make (n_steps + 1) x0 in
    for i = 0 to n_steps - 1 do
      let dw = sqrt dt *. Mc.std_normal () in
      path.(i + 1) <- path.(i) *. exp ((mu -. 0.5 *. sigma *. sigma) *. dt +. sigma *. dw)
    done;
    path

end

26.2 Itô's Lemma

For a twice-differentiable function $f(S_t, t)$ where $S$ follows $dS = \mu S\cdot dt + \sigma S\cdot dW$:

$$df = \left(\frac{\partial f}{\partial t} + \mu S \frac{\partial f}{\partial S} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 f}{\partial S^2}\right) dt + \sigma S \frac{\partial f}{\partial S}\cdot dW$$

module Ito = struct

  (** Numerically demonstrate Itô's lemma for f(S) = ln S:
      d(ln S) = (μ - σ²/2) dt + σ dW *)
  let verify_log_sde ?(n_paths = 10000) ~mu ~sigma ~tau =
    let em = Array.init n_paths (fun _ ->
      let path = Sde.euler_maruyama ~x0:1.0
        ~drift:(fun s _ -> mu *. s)
        ~diffusion:(fun s _ -> sigma *. s)
        ~tau ~n_steps:1000 () in
      log path.(1000)
    ) in
    let exact = Array.init n_paths (fun _ ->
      let z = Mc.std_normal () in
      (mu -. 0.5 *. sigma *. sigma) *. tau +. sigma *. sqrt tau *. z
    ) in
    let mean_em = Array.fold_left (+.) 0.0 em /. float_of_int n_paths in
    let mean_ex = Array.fold_left (+.) 0.0 exact /. float_of_int n_paths in
    Printf.printf "E[ln S_T] via EM: %.4f, Exact: %.4f, Theory: %.4f\n"
      mean_em mean_ex ((mu -. 0.5 *. sigma *. sigma) *. tau)

end

26.3 Change of Measure — Girsanov's Theorem

The Core Insight

Girsanov's theorem is the mathematical engine behind risk-neutral pricing. To understand it, consider the following question: why does the Black-Scholes formula contain the risk-free rate $r$ but not the actual expected return $\mu$ of the stock? Intuitively, two investors who disagree about the stock's expected return (one thinks it will rise 5% per year, another thinks 15%) can still agree on the price of a 3-month call option. The option price does not depend on which investor is right.

This seems paradoxical: the option's payoff at expiry depends on $S_T$, which surely depends on the drift. The resolution is Girsanov's theorem. It says: you can always absorb the drift of a process into the probability measure. By changing from the real-world measure $\mathbb{P}$ (where $dS = \mu S\cdot dt + \sigma S\cdot dW^{\mathbb{P}}$) to the risk-neutral measure $\mathbb{Q}$ (where $dS = rS\cdot dt + \sigma S\cdot d\tilde{W}$), we replace $\mu$ with $r$ in the SDE — but at the cost of working with a different probability measure.

The process $\tilde{W}_t = W_t^{\mathbb{P}} + \int_0^t \theta_s\cdot ds$ (where $\theta = (\mu - r)/\sigma$ is the market price of risk) is a standard Brownian motion under $\mathbb{Q}$. Under $\mathbb{Q}$, risky assets grow at the risk-free rate $r$, not at their actual drift. This makes pricing straightforward: the fair price of any derivative is the expectation of its discounted payoff under $\mathbb{Q}$: $$V_0 = e^{-rT} E^{\mathbb{Q}}[\text{Payoff}(S_T)]$$

The change of measure is implemented by the Radon-Nikodym derivative (the density process): $$\frac{d\mathbb{Q}}{d\mathbb{P}}\bigg|_{\mathcal{F}_T} = \exp\left(-\int_0^T \theta_s\cdot dW_s - \frac{1}{2}\int_0^T \theta_s^2\cdot ds\right)$$

This is a positive martingale with expectation 1 under $\mathbb{P}$, and it defines the $\mathbb{Q}$ probability of each scenario as the $\mathbb{P}$ probability times this density. Scenarios in which $S_T$ is high (which happen more often under $\mathbb{P}$ if $\mu > r$) receive less weight under $\mathbb{Q}$, precisely compensating for the higher drift.

Feynman-Kac: PDE $\leftrightarrow$ Expectation

Girsanov's theorem connects the physical and risk-neutral measures. The Feynman-Kac theorem connects PDEs and expectations. It states: if $V(t, S)$ satisfies the PDE $$\frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0$$ with terminal condition $V(T, S) = h(S)$, then the solution is $$V(t, S) = e^{-r(T-t)} E^{\mathbb{Q}}[h(S_T) \mid S_t = S]$$

This is the Black-Scholes PDE and its risk-neutral pricing formula simultaneously. The Black-Scholes PDE is not an independent derivation — it is the statement that the derivative price is the risk-neutral expectation of the discounted payoff, expressed in differential form.

Feynman-Kac has a profound practical implication: any pricing problem can be solved either by solving a PDE or by computing an expectation via Monte Carlo, and both give the same answer. The choice between the two methods is purely computational: PDEs are fast in one or two dimensions but intractable in high dimensions (the curse of dimensionality); Monte Carlo scales to any dimension but converges slowly ($O(1/\sqrt{N})$).

Under the risk-neutral measure $\mathbb{Q}$:

$$\tilde{W}_t = W_t + \int_0^t \theta_s\cdot ds, \quad d\mathbb{Q}/d\mathbb{P} = \exp\left(-\int_0^T \theta_s\cdot dW_s - \frac{1}{2}\int_0^T \theta_s^2\cdot ds\right)$$

For Black-Scholes, $\theta = (\mu - r) / \sigma$ transforms from physical to risk-neutral drift $r$.


26.4 Term Structure Models (Advanced)

Hull-White Model

$$dr_t = (\theta(t) - a r_t)\cdot dt + \sigma\cdot dW_t$$

where $\theta(t)$ is calibrated to fit the initial yield curve exactly.

module Hull_white = struct

  type params = { a: float; sigma: float }

  (** ZCB price: P(0,T) = exp(A(T) - B(T)*r0) *)
  let zcb_price p ~r0 ~t ~initial_curve =
    let b = (1.0 -. exp (-. p.a *. t)) /. p.a in
    let fwd_t = Interpolation.instantaneous_forward initial_curve t in
    let var   = p.sigma *. p.sigma /. (2.0 *. p.a *. p.a)
                *. (1.0 -. exp (-. p.a *. t)) *. (1.0 -. exp (-. p.a *. t)) in
    let a     = Interpolation.discount_factor initial_curve t
                /. exp (-. b *. fwd_t +. 0.5 *. var) in
    a *. exp (-. b *. r0)

  (** Swaption pricing under Hull-White (analytical) *)
  let swaption_price p ~r0 ~tau_option ~swap_params ~initial_curve ~option_type =
    (* Jamshidian decomposition: sum of ZCB options *)
    let _ = (p, r0, tau_option, swap_params, initial_curve, option_type) in
    failwith "See Brigo & Mercurio Chapter 4"

end

26.5 SABR Model

The SABR model (Hagan et al., 2002) has become the market standard for swaption and caplet smiles:

$$dF = \hat{\sigma} F^\beta\cdot dW^1, \quad d\hat{\sigma} = \nu \hat{\sigma}\cdot dW^2, \quad \langle dW^1, dW^2\rangle = \rho\cdot dt$$

The approximate implied volatility formula:

$$\sigma_{\text{impl}}(K, F) \approx \frac{\sigma_0 {1 + [2\gamma_2 - \gamma_1^2 + 1/(F_{\text{mid}}^2)]\frac{\nu^2}{24}\sigma_0^2 T + \ldots}}{...}$$

module Sabr = struct

  type params = {
    alpha : float;   (* initial vol, σ_0 > 0 *)
    beta  : float;   (* CEV exponent, β ∈ [0,1] *)
    nu    : float;   (* vol of vol *)
    rho   : float;   (* S-σ correlation *)
  }

  (** Hagan et al. (2002) approximate implied vol formula *)
  let implied_vol p ~forward ~strike ~tau =
    if Float.abs (forward -. strike) < 1e-6 then
      (* ATM formula *)
      let fmid    = forward ** (1.0 -. p.beta) in
      let term1   = 1.0 +. ((1.0 -. p.beta) *. (1.0 -. p.beta) /. 24.0
                             *. p.alpha *. p.alpha /. forward ** (2.0 -. 2.0 *. p.beta)
                             +. p.rho *. p.beta *. p.nu *. p.alpha /. 4.0 /. fmid
                             +. (2.0 -. 3.0 *. p.rho *. p.rho) *. p.nu *. p.nu /. 24.0) *. tau in
      p.alpha /. fmid *. term1
    else begin
      let f1b2    = sqrt (forward *. strike) ** (1.0 -. p.beta) in
      let z       = p.nu /. p.alpha *. f1b2 *. log (forward /. strike) in
      let chi     = log ((sqrt (1.0 -. 2.0 *. p.rho *. z +. z *. z) +. z -. p.rho)
                         /. (1.0 -. p.rho)) in
      let numer   = p.alpha *. z /. chi in
      let fn_logfk = log (forward /. strike) in
      let denom1   = f1b2 *. (1.0 +. (1.0 -. p.beta) *. (1.0 -. p.beta) /. 24.0
                               *. fn_logfk *. fn_logfk
                               +. (1.0 -. p.beta) ** 4.0 /. 1920.0
                               *. fn_logfk *. fn_logfk *. fn_logfk *. fn_logfk) in
      let correct  = 1.0 +. ((1.0 -. p.beta) *. (1.0 -. p.beta) /. 24.0
                              *. p.alpha *. p.alpha /. (sqrt (forward *. strike)) ** (2.0 -. 2.0 *. p.beta)
                              +. p.rho *. p.beta *. p.nu *. p.alpha /. 4.0 /. f1b2
                              +. (2.0 -. 3.0 *. p.rho *. p.rho) /. 24.0 *. p.nu *. p.nu) *. tau in
      numer /. denom1 *. correct
    end

end

26.6 Chapter Summary

Stochastic calculus is the mathematical infrastructure underlying almost every model in quantitative finance. Itô's lemma is the operational heart: it tells you how to compute the dynamics of any smooth function of a stochastic process, and the extra quadratic variation term is what distinguishes options from forwards — the gamma contribution to the Black-Scholes PDE exists because of Itô correction.

Numerical SDE schemes — Euler-Maruyama and Milstein — translate the continuous-time SDE into a discrete-time simulation. Euler-Maruyama has $O(\sqrt{dt})$ strong convergence (the pathwise error shrinks as the square root of the step size), which is adequate for most purposes. Milstein adds the diffusion derivative term and achieves $O(dt)$ strong convergence, making it preferable for problems where path accuracy is critical, such as barrier options or variance swaps. For GBM, the exact simulation formula completely eliminates discretisation error and should always be preferred for terminal-value problems.

Girsanov's theorem is the mechanism behind risk-neutral pricing. By changing the probability measure from $\mathbb{P}$ (the physical, real-world measure) to $\mathbb{Q}$ (the pricing measure), we remove the stock's actual drift from the problem entirely. Prices are expectations under $\mathbb{Q}$, not under $\mathbb{P}$. This is why the Black-Scholes formula contains $r$ but not $\mu$ — and why two investors with very different views on stock returns still agree on option prices.

The Hull-White model illustrates how to build a rates model that is simultaneously analytically tractable (affine structure giving closed-form bond and option prices) and consistent with market data (the time-dependent parameter $\theta(t)$ is fit to match the initial yield curve exactly). SABR is the interest rate counterpart to Black-Scholes for caps and swaptions: it introduces stochastic volatility with a particular structure that yields an accurate closed-form implied volatility approximation, which is why it dominates rates volatility markets.


Exercises

26.1 Verify Itô's lemma numerically: simulate $d(\ln S)$ via Euler-Maruyama on $dS = \mu S dt + \sigma S dW$ and compare directly to the analytic result $(\mu - \sigma^2/2)T$.

26.2 Compare Euler-Maruyama and Milstein convergence for the CIR process. Plot $E[|X_T^h - X_T|]$ vs step size $h = dt$.

26.3 Implement SABR calibration: fit $(\alpha, \nu, \rho)$ to a set of market implied vols at fixed $\beta = 0.5$ using least-squares minimisation.

26.4 Implement the Hull-White ZCB price formula and validate that $P(0, T)$ matches the initial discount curve inputs for all $T$.


Next: Chapter 27 — Machine Learning in Quantitative Finance