Quant Memo
Advanced

Stopping Times

The precise line between an exit rule you can actually execute and one that secretly needs tomorrow's prices. Get it right and the optional stopping theorem does your algebra for you; get it wrong and you have invented look-ahead bias.

Prerequisites: Martingales, The Random Walk

Almost every trading rule is an exit rule. Stop out at minus two percent. Take profit at the target. Knock the barrier option out if it touches 90. Exercise the American put the moment holding it stops being worth it. Each is a rule for when to quit, and to compute anything about them you first have to be strict about which quitting rules are legitimate — because some, on inspection, need to know what happens next.

The analogy: selling at the high of the month

Two instructions to a trader.

"Sell the moment the stock touches $105." They can do this. They watch the tape, and the instant it prints 105 they hit the bid. At every second of the day they can answer have I sold yet? with a definite yes or no, using nothing but what has already printed.

"Sell at the highest price of the month." They cannot. On the 12th the stock touches 108 and they have no idea whether that is the high — the 27th might print 112. The high is identifiable only once the month is over, which is exactly one moment too late.

Both are "times". Only the first is a stopping time. Everything technical below is a careful way of writing that down.

Writing it down

One piece of vocabulary first. Write Ft\mathcal{F}_t (script F sub t) for the filtration: everything known up to and including time tt — every price, every fill, every headline that has already happened. It only ever grows, because you never un-learn something.

A random time τ\tau (tau) is a stopping time if, for every time tt,

{τt}Ft.\{\tau \le t\} \in \mathcal{F}_t .

In words: at any moment tt, the question "has it happened yet?" is answerable from what you already know. No peeking.

Run the two instructions through it. "The first time the price reaches 105" — at 2pm you either have seen a print at 105 or you have not, so yes. "The time of the month's high" — at 2pm you cannot know, so no.

first touch of 105: you can trade this the month's high: only visible afterwards 105
Same path, two exit rules. The green dot is decidable the instant it happens. The red dot is only identifiable once the whole path is in front of you — which is why a backtest that sells there is not a strategy.

Some rules that pass and fail the test:

rulestopping time?why
first time price 105\ge 105yeseach print arrives before you act
first time drawdown exceeds 5 percentyesdrawdown depends only on the past
min(τ,30 days)\min(\tau, 30\text{ days})yeshit the target, or give up after a month
the day of the highest pricenoneeds the rest of the path
one day before the crashnoneeds tomorrow
the last time price is above 105noyou never know it was the last

The payoff: optional stopping

The reason to be fussy is one theorem. A martingale MtM_t is a process whose expected future value equals its current value — a fair game. The optional stopping theorem says that if τ\tau is a stopping time and is well behaved (bounded, say, or the process has bounded steps and τ\tau has finite expectation), then

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

In words: you cannot change the expected outcome of a fair game by being clever about when you walk away. That sounds purely negative. In practice it is a calculation engine: spot a martingale and the theorem hands you an equation with your unknown already inside it.

Worked example 1: gambler's ruin, twice over

You start with $5, bet $1 on a fair coin over and over, and stop when you reach $10 or go broke. What is the chance you reach $10, and how many flips will it take?

Setting up. Let WtW_t be your wealth after tt flips. It is a martingale: the next flip moves you up one or down one with equal probability, so expected next wealth equals today's. And τ\tau, the first time you hit 0 or 10, is a stopping time — you just check your balance.

Question 1, the probability. Optional stopping gives E[Wτ]=W0=5E[W_\tau] = W_0 = 5. But WτW_\tau can only be 0 or 10. Writing pp for the probability of reaching 10 first,

E[Wτ]=10p+0(1p)=10p=5p=0.5.E[W_\tau] = 10p + 0(1-p) = 10p = 5 \quad\Longrightarrow\quad p = 0.5.

Half the time you double, half the time you are wiped out. In general, starting at aa with a target bb, the answer is a/ba/b — so $1 chasing $100 gives a 1 percent chance, exactly the ratio of the stakes.

Question 2, the duration. This needs a different martingale: Wt2tW_t^2 - t. Check it in one line — from wealth ww, the next squared wealth is (w+1)2(w+1)^2 or (w1)2(w-1)^2 with equal chance, and

12(w+1)2+12(w1)2=w2+1.\tfrac12 (w+1)^2 + \tfrac12 (w-1)^2 = w^2 + 1 .

So squared wealth grows by exactly 1 per flip on average, which is why subtracting tt makes it a martingale. Apply optional stopping:

E[Wτ2τ]=W020=25.E[W_\tau^2 - \tau] = W_0^2 - 0 = 25 .

And E[Wτ2]=0.5×02+0.5×102=50E[W_\tau^2] = 0.5 \times 0^2 + 0.5 \times 10^2 = 50. Therefore E[τ]=5025=25 flipsE[\tau] = 50 - 25 = \textbf{25 flips}. (The general answer is a(ba)=5×5=25a(b-a) = 5 \times 5 = 25, which matches.)

Two questions, no summations, no recursions — just a martingale and a legitimate stopping rule.

The explorer below samples Brownian paths. Set the drift to zero so each path is a fair game, pick a level in your head, and watch how many paths reach it before the window ends. Redraw a few times: the fraction that get there is stable, any individual path is not.

Path explorer
0-1time →
end (bold path) 0.02spread of ends 0.736 independent paths, same settings

Worked example 2: why the doubling system doesn't break the theorem

The oldest system in gambling: bet $1 on a coin; if you lose, double; stop at your first win. After kk straight losses you are down 1+2+4++2k1=2k11 + 2 + 4 + \cdots + 2^{k-1} = 2^k - 1, and the next bet of 2k2^k wins it all back plus one. So you always finish exactly $1 ahead, on a fair game. Optional stopping says E[Wτ]=0E[W_\tau] = 0; here it is plainly 1. Something has to give.

Nothing is wrong with τ\tau — "the first heads" is a perfectly good stopping time. What fails is the fine print:

straight lossescapital needed to continueprobability of that run
1$11 in 2
5$311 in 32
10$1,0231 in 1,024
20$1,048,5751 in 1,048,576

Read the last two columns together. In every row the money at risk and the odds against move in exact lockstep, so each row contributes about half a dollar to your expected worst deficit — and there are infinitely many rows. The exact terms are 0.250.25, then 0.3750.375, then 0.43750.4375, then 0.468750.46875: they climb toward one half and never shrink, so the total is infinite.

So the hole you must be able to fund has unbounded expected size. τ\tau is finite with probability one, but it has no bound, and the wealth runs arbitrarily far negative before it ends — exactly the condition the theorem requires and this strategy violates. In market terms, it converts a large probability of a small gain into a small probability of an unsurvivable loss, and no finite bankroll makes it safe.

What this means in practice

  • Backtesting. "Not a stopping time" is the formal definition of look-ahead bias. If an exit rule needs a value your code would not have had at that timestamp, the backtest is fiction.
  • Barrier and American options. A knock-out happens at a stopping time; an American exercise policy must be one. Pricing an American option means choosing the stopping time that maximises expected discounted payoff — which is what a binomial tree's backward induction does.
  • Risk limits. "Cut the book if drawdown passes 5 percent" is executable and can be simulated honestly. "Cut before the drawdown" cannot.
  • Sequential testing. Stopping the moment a p-value dips below 0.05 is a valid stopping time but an invalid test, because the fixed-sample theory assumed you would not. See Sequential Hypothesis Testing.

A stopping time is a rule where, at every instant, you can answer "have I stopped yet?" from what you already know. Pair one with a martingale and optional stopping gives E[Mτ]=E[M0]E[M_\tau] = E[M_0] — an equation that solves ruin probabilities, expected durations and barrier problems with no heavy machinery.

The litmus test: could a program with a live feed and no future data answer "stopped or not?" at every tick? If it needs to look ahead even one bar, it is not a stopping time.

Two errors, and the second is the expensive one. First, assuming any random time counts. The time of the maximum, the last visit to a level, and "the day before the drop" are all perfectly well-defined random times, and none is a stopping time — each needs the future. Second, applying optional stopping without checking its conditions. E[Mτ]=E[M0]E[M_\tau] = E[M_0] needs τ\tau bounded, or bounded increments with E[τ]E[\tau] finite, or uniform integrability. Skip that check and the doubling strategy appears to beat a fair game — in practice, a strategy that looks like free money right up to the day it takes the whole account.

Related concepts

Practice in interviews

Further reading

  • Williams, Probability with Martingales (ch. 10)
  • Shreve, Stochastic Calculus for Finance II (ch. 8)
  • Durrett, Probability: Theory and Examples (ch. 4)
ShareTwitterLinkedIn