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 (script F sub t) for the filtration: everything known up to and including time — every price, every fill, every headline that has already happened. It only ever grows, because you never un-learn something.
A random time (tau) is a stopping time if, for every time ,
In words: at any moment , 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.
Some rules that pass and fail the test:
| rule | stopping time? | why |
|---|---|---|
| first time price | yes | each print arrives before you act |
| first time drawdown exceeds 5 percent | yes | drawdown depends only on the past |
| yes | hit the target, or give up after a month | |
| the day of the highest price | no | needs the rest of the path |
| one day before the crash | no | needs tomorrow |
| the last time price is above 105 | no | you never know it was the last |
The payoff: optional stopping
The reason to be fussy is one theorem. A martingale is a process whose expected future value equals its current value — a fair game. The optional stopping theorem says that if is a stopping time and is well behaved (bounded, say, or the process has bounded steps and has finite expectation), then
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 be your wealth after 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 , the first time you hit 0 or 10, is a stopping time — you just check your balance.
Question 1, the probability. Optional stopping gives . But can only be 0 or 10. Writing for the probability of reaching 10 first,
Half the time you double, half the time you are wiped out. In general, starting at with a target , the answer is — so $1 chasing $100 gives a 1 percent chance, exactly the ratio of the stakes.
Question 2, the duration. This needs a different martingale: . Check it in one line — from wealth , the next squared wealth is or with equal chance, and
So squared wealth grows by exactly 1 per flip on average, which is why subtracting makes it a martingale. Apply optional stopping:
And . Therefore . (The general answer is , 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.
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 straight losses you are down , and the next bet of wins it all back plus one. So you always finish exactly $1 ahead, on a fair game. Optional stopping says ; here it is plainly 1. Something has to give.
Nothing is wrong with — "the first heads" is a perfectly good stopping time. What fails is the fine print:
| straight losses | capital needed to continue | probability of that run |
|---|---|---|
| 1 | $1 | 1 in 2 |
| 5 | $31 | 1 in 32 |
| 10 | $1,023 | 1 in 1,024 |
| 20 | $1,048,575 | 1 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 , then , then , then : 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. 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 — 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. needs bounded, or bounded increments with 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)