Quant Ladder

Martingales and Optional Stopping: The Fair-Game Machine

3 min read

A handful of interview questions — gambler's ruin, "can I quit while ahead?", first-passage times — all dissolve under one tool. This article is that tool.

The definition that matters

A process MtM_t is a martingale if its expected future value, given everything known now, is its current value:

E[Mt+1Ft]=MtE[M_{t+1} \mid \mathcal{F}_t] = M_t

A fair game: no information available today predicts drift. Your bankroll in fair coin-flipping is a martingale; in roulette it's a supermartingale (drifts down). Two non-obvious examples worth carrying:

  • If SnS_n is a fair ±1 walk, then Sn2nS_n^2 - n is a martingale (the walk's square grows exactly like nn on average — variance accumulation made literal).
  • For a biased walk with up-probability p12p \neq \tfrac12, the process (1pp)Sn\left(\frac{1-p}{p}\right)^{S_n} is a martingale — the exponential trick that unlocks biased-ruin problems.

Optional stopping: no system beats a fair game

The optional stopping theorem (OST): for a martingale and a "reasonable" stopping rule τ\tau (bounded, or bounded increments with finite expected time — conditions that hold in every interview setting),

E[Mτ]=M0.E[M_\tau] = M_0.

No strategy for deciding when to quit — however clever, however adapted to the history — changes the expected outcome of a fair game. This is the mathematically precise version of "there is no betting system."

The machine in action

Gambler's ruin, one line. Start with \20, opponent \80, fair \1betsuntilsomeoneisbroke.Bankrollisamartingaleandthestoppingtimeislegal,so1 bets until someone is broke. Bankroll is a martingale and the stopping time is legal, soE[\text{final}] = 20. The final bankroll is \100 (probability pp) or \0:0:100p = 20 \Rightarrow p = 1/5$. No difference equations needed.

Expected duration, two lines. Using the second martingale: E[Sτ2τ]=0E[S_\tau^2 - \tau] = 0 where SS measures your fortune around... concretely, with absorbing barriers at 00 and aa starting from xx, E[τ]=x(ax)E[\tau] = x(a - x). For 20/80: 20×80=160020 \times 80 = 1600 expected bets. The quadratic — leaving from the middle takes longest — is the t\sqrt{t} law again from the other side.

"Quit while I'm ahead." "I'll flip fair coins and stop the moment I'm +1. I always end positive — free money?" OST says E[profit]=0E[\text{profit}] = 0... yet you do reach +1 with probability 1. The resolution: the strategy needs an unbounded bankroll and unbounded time — the rare, arbitrarily long excursions deep into the red exactly cancel the certain small win. With any finite bankroll BB, you sometimes bust, and P(bust)×BP(\text{bust}) \times B eats precisely your expected gain. The theorem's "reasonable stopping rule" conditions aren't legal fine print; they're where the economics lives — and explaining that is what separates a real answer from a memorized one.

Why traders should care beyond puzzles

  • Prices as martingales. Efficient-market logic says properly discounted prices should be (approximately) martingales under the right measure — if tomorrow's price were predictably above today's, buying today would already have moved it. The risk-neutral measure of options theory is exactly the measure making discounted prices martingales; "pricing = expectation" is martingale theory in production.
  • Stopped strategies aren't magic. Stop-losses and take-profits reshape the distribution of P&L (clip a tail here, fatten one there) but cannot manufacture expectation from a zero-edge process. Any backtest whose profitability comes purely from exit rules on a driftless underlying is a bug hunt.
  • Fair-value bookkeeping. In market-making games, "my expected P&L from here is my current mark" is the martingale property; deviations from it are either edge or error.

The interview version

The biased follow-up completes the pattern: with win probability p<12p < \tfrac12, apply OST to the exponential martingale rSnr^{S_n}, r=1ppr = \frac{1-p}{p}, to get P(reach a before 0 from x)=1rx1raP(\text{reach } a \text{ before } 0 \text{ from } x) = \frac{1 - r^{x}}{1 - r^{a}}. Sanity check it: at p=0.49p = 0.49 starting with 20 versus 80, ruin is already overwhelming — small edges compound viciously over many bets. Casinos are not lucky; they own a supermartingale and the OST guarantees the rest.