Quantitative Methods · Methods
1Probability at Speed
At ten to four the imbalance of the closing auction appears on the screen, and the desk’s running estimate of the closing price, a number it has been revising all day, jumps by 14 cents. A researcher asks a sharper question than whether the estimate was right: could its revisions have been predicted from the revisions before them? If they could, the estimate was not using what it knew, and someone trading against it would have made money. An honest forecast of a fixed quantity is a conditional expectation along a flow of information, and such a process has one defining property: its revisions cannot be forecast. This chapter sets out, at the speed of a reader who has met measure theory, the objects the series computes with (information, conditional expectation, martingales, stopping times, changes of measure) and closes by fixing the notation every later book uses.
1.1 Information: sigma-algebras, filtrations and conditional expectation
A probability space is taken as known. What finance adds is time: at each instant some events are decided, and the decided ones grow.
Definition 1.1 (Filtration, adapted process)
A filtration is a family of sub--algebras of , increasing in : for . The index set is or ; in continuous time the filtration is assumed right-continuous and complete (the usual conditions). A process is an adapted process if each is -measurable: its value at is known at .
is what is known at : the prices printed so far, the cards turned over. A trading rule must be adapted; a backtest that is not has looked into the future (chapter 3).
Definition 1.2 (Conditional expectation)
Let be integrable and a sub--algebra. The conditional expectation is the almost surely unique -measurable, integrable random variable with for every . We write .
Existence is the Radon–Nikodym theorem applied to the measure on . For square-integrable there is a more useful picture: is the orthogonal projection of onto the closed subspace , the best forecast of in mean square among all -measurable random variables. Everything a forecaster can compute from the information is in that subspace, and the forecast error is orthogonal to all of it.
Proposition 1.3 (Rules of conditional expectation)
For integrable and : (i) tower: ; (ii) taking out what is known: if is -measurable and integrable, ; (iii) independence: if is independent of , ; (iv) Jensen: for convex with integrable, .
Proof. Check the defining integrals: (i) for , ; (ii) for , , then limits; (iii) ; (iv) is a supremum of countably many affine functions. ∎
Figure 1.1 shows the rules at work on the smallest example that has them all. A price starts at 100 and moves one dollar up or down on each of two days with equal probability; . After one day the information is which half of the tree we are in, and averages over that half.
Laws are handled through their transforms. The one the series uses most is defined here, so that later books (Lévy processes in chapter 6, Fourier pricing in chapter 28, stochastic volatility in One Quant Book 5) can point to it.
Definition 1.4 (Characteristic function)
The characteristic function of a random variable is , ; of a random vector, , . It exists for every law, determines it, and turns sums of independent variables into products.
Theorem 1.5 (Central limit theorem)
Let be independent with means and variances , , and suppose Lindeberg’s condition holds for every (it does for identically distributed variables with finite variance). Then .
Proof. Admitted here. ∎
The proof expands the characteristic function to second order and uses Lévy’s continuity theorem (Williams, 1991). Every standard error in Part II rests on it.
1.2 Martingales and the Doob martingale of a forecast
Definition 1.6 (Martingale)
An adapted, integrable process is a martingale if for all ; a submartingale if ; a supermartingale if .
A martingale is a fair game seen from any date. Four examples recur in the book. With independent, taking the values with probabilities and , and :
- is a martingale when , a submartingale when ;
- is a martingale when : the variance grows by one per step;
- is a martingale for every , since ;
- is a martingale when , for every real : the exponential martingale, prototype of the density processes of Section 1.4.
The example that matters most for a trading desk is not a price but a forecast.
Definition 1.7 (Doob martingale)
For an integrable random variable and a filtration , the Doob martingale of is .
It is a martingale by the tower rule. Every honest forecast of a fixed quantity (a closing price, the sum of five cards, next month’s inflation print) is a Doob martingale along the forecaster’s filtration, and what makes it testable is that its revisions are orthogonal.
Proposition 1.8 (Orthogonal increments)
Let be a square-integrable martingale with increments . Then for every square-integrable -measurable ; in particular for , and
Proof. by taking out what is known. With , , the cross terms of vanish, and likewise. ∎
Two consequences drive this chapter’s tutorial and problem. First, a forecast whose revisions can be predicted from the past (a regression of on with a nonzero slope) is not a conditional expectation: it is leaving information unused. Second, the variance of the final value splits into the variances of the revisions, so one can say how much of a closing price’s uncertainty is resolved at each time of day (Figure 1.2).
The maximal inequality bounds how far a martingale wanders over a period by where it ends; chapter 2 uses it to control Brownian paths.
Proposition 1.9 (Doob’s maximal inequality)
For a nonnegative submartingale and , ; and for , . For a square-integrable martingale, applied to : .
Proof. Admitted here. ∎
1.3 Stopping times and optional stopping
Definition 1.10 (Stopping time)
A random time with values in is a stopping time if for every : whether it has occurred by is known at .
“The first time the price touches 101” is a stopping time; “the time of the day’s high” is not, since it is known only at the close. When is a martingale’s expected value at a stopping time still its starting value?
Definition 1.11 (Uniform integrability)
A family of random variables has uniform integrability if as .
Theorem 1.12 (Optional stopping)
Let be a martingale and a stopping time. Then if either (i) is bounded, or (ii) almost surely and the stopped process is uniformly integrable; in particular if for all .
Proof. (i) If , then , and , so each term has zero mean by Proposition 1.8. (ii) Apply (i) to ; almost surely, and uniform integrability upgrades this to convergence in (Vitali), so the means converge. ∎
The theorem prices every take-profit and stop-loss rule on a martingale. A position whose value moves by tick with equal probability is closed at or . The stopped value is bounded, so : with , and
A stop close to entry and a distant profit target win rarely and lose often, and the expected profit is zero whatever and are: the rule reshapes the distribution of the result, not its mean. With a drift () the martingale gives ; Figure 1.3 compares both formulas with simulation.
Remark 1.13 (The doubling strategy)
Doubling the stake after each loss of a fair even-money bet and stopping at the first win yields almost surely, apparently contradicting the theorem. The stopping time is finite but unbounded, and the stopped process is not uniformly integrable: before the win it has lost with probability . A finite credit line bounds the stakes, makes condition (ii) hold, and restores : a small, frequent gain paid for by a rare, enormous loss.
1.4 Changing the measure
Much of quantitative finance computes under a measure other than the one that describes the world: one under which discounted prices are martingales (chapter 5), or one under which a rare loss is common enough to simulate (chapter 26).
Definition 1.14 (Change of measure)
Two probability measures and on are equivalent measures if they have the same null sets. A change of measure from to an equivalent is described by the Radon–Nikodym derivative , the almost surely unique positive random variable with for all ; then . Along a filtration, the density process is , the Radon–Nikodym derivative of restricted to .
The density process is a positive -martingale with (a Doob martingale), and conversely every such martingale defines a measure. Conditional expectations under the new measure follow from the old ones.
Proposition 1.15 (Bayes formula for a change of measure)
If with density process and is -integrable, then for and -measurable,
In particular, an adapted is a -martingale if and only if is a -martingale.
Proof. The right-hand side is -measurable. For ,
using for -measurable , and the tower rule. ∎
Example 1.16 (Shifting a Gaussian, and seeing a far tail)
Let under and . Then : under , . The change of measure has moved the mean without touching the shape. Run it backwards to estimate : sample and average , the indicator reweighted by . With 100 000 draws, plain sampling sees three exceedances and has a standard error of , half the answer; the reweighted estimate has a standard error of , eighty times smaller. Chapter 26 turns this into importance sampling, and chapter 5 does the same computation for whole Brownian paths.
1.5 The notation of the series
Every book of the series from this one on uses the symbols below. They extend the tables of One Quant Books 1 and 2, whose meanings are kept: is the bid–ask spread, a credit spread, a time to expiry, a rate, a borrow fee, a strike, a discount factor, a yield, an accrual fraction and a recovery rate. A symbol a chapter declares local may carry another meaning there.
Notation 1.17 (Probability, measures and processes)
| , | probability space; filtration (usual conditions) |
| , | conditional expectation; under another measure |
| , , | real-world measure; risk-neutral measure; money-market account |
| , ; , | generic numeraire and its measure; -forward and annuity measures |
| , | Radon–Nikodym derivative; density process |
| , ; | standard normal cdf and pdf (never ); the normal law, always with arguments |
| characteristic function, always subscripted | |
| ; , , | indicator; equality and convergence in law, in probability |
| a stopping time; where it meets a time to expiry, write ; default times are subscripted () | |
| ; | Brownian motion under the measure in force; decorated when two measures appear |
| , , | quadratic variation, covariation, stochastic exponential |
| ; , | a diffusion; its generator and the adjoint |
| Ornstein–Uhlenbeck: speed , level , half-life | |
| square-root process; Feller condition ; is the vol-of-vol throughout | |
| , | counting process and its event times |
| , | intensity (Poisson rate, hazard rate, Hawkes intensity ); compensator |
| , | Lévy triplet and characteristic exponent, |
| , | Hurst exponent; fractional Brownian motion |
Notation 1.18 (Statistics, matrices and numerics)
| , , | sample size, parameter, true value; hat an estimate, tilde a shrunk estimate, bar a sample mean |
| , | log-likelihood (always with subscript and argument); Fisher information |
| ; , | standard error; Sharpe ratio and its estimate |
| log return ( alone stays the recovery rate) | |
| , ; , | lag and difference operators; autocovariance, autocorrelation |
| , , | autoregressive and moving-average coefficients (always indexed); innovations |
| , ; | realised and integrated variance; implied volatility (never “IV” in a formula) |
| , , ; , , | covariance, correlation, sample covariance; ones vector, identity, transpose; vectors are columns |
| , | eigenvalues (always indexed); condition number |
| s.t. , | optimisation; multipliers , ; optimum , values , |
| , , | floating point in binary64, round to nearest; |
| , , ; , | time grid, space grid, numerical solution; Monte Carlo paths and estimator |
The options, rates, credit and risk symbols (, , , the Greeks with the rate Greek written Rho because is always a correlation, , , , , ) come from the same table and are introduced in One Quant Books 5 and 6.
1.6 Tutorial: the Doob martingale of a card game
Goal. Build the Doob martingale of the five-card game of One Quant Book 2, chapter 30 (the sum of five cards dealt from a 52-card deck, aces 1 to kings 13), check that its revisions behave as Proposition 1.8 says, and catch a forecaster that under-reacts. End state: the table below and Figures 1.2 and 1.3.
The forecast. After cards with sum , the remaining cards have sum , so , and . The under-reacting forecaster moves only a fraction of the way from 35 until the last card.
DECK = np.repeat(np.arange(1, 14), 4) # aces 1 ... kings 13, four suits N_CARDS = 5 # --- the card game ------------------------------------------------------------------------- def card_forecasts(n_deals: int, seed: int = 1) -> np.ndarray: """Doob martingale M_k = E[sum of 5 cards | first k revealed], k = 0..5, one row per deal.""" rng = np.random.default_rng(seed) total, size = DECK.sum(), DECK.size out = np.empty((n_deals, N_CARDS + 1)) for i in range(n_deals): cards = rng.choice(DECK, N_CARDS, replace=False) s = np.concatenate([[0], np.cumsum(cards)]) k = np.arange(N_CARDS + 1) out[i] = s + (N_CARDS - k) * (total - s) / (size - k) return out def underreacting(m: np.ndarray, a: float) -> np.ndarray: """A forecaster that moves only a fraction a of the way from the prior mean, until the end.""" f = m[:, :1] + a * (m - m[:, :1]) f[:, -1] = m[:, -1] return fListing 1.1. The Doob martingale of the card game and an under-reacting forecaster. code/methods/01-probability-at-speed/python/qm_martingales.py The test. Regress the last revision on the one before it, pooled over deals; the running project’s function does it for any panel of forecast paths.
def revision_regression(paths: np.ndarray, lag: int = 1, col: int | None = None) -> dict: """Pooled regression (no intercept) of each revision on the revision `lag` steps before it. With `col` given, regress only the revision at column `col` (of the revision array) on the one `lag` steps before it. For a martingale the slope is zero; the t-statistic uses the iid standard error of a no-intercept regression.""" d = revisions(paths) if col is None: y = d[:, lag:].ravel() x = d[:, :-lag].ravel() else: y = d[:, col] x = d[:, col - lag] sxx = float(x @ x) slope = float(x @ y) / sxx resid = y - slope * x n = y.size se = float(np.sqrt(resid @ resid / (n - 1) / sxx)) return {"slope": slope, "se": se, "t": slope / se, "n": n}Listing 1.2. Regression of a revision on an earlier one: zero slope for a martingale. code/firm/mgtest/firm_mgtest.py - Run
card_table()over 20 000 seeded deals, thenfig_martingales.pyfor the figures.
| honest forecast | under-reacting () | |
|---|---|---|
| mean revision | ||
| slope of last revision on the fourth | (theory ) | |
| -statistic of the slope | — |
Both forecasts have revisions with mean zero; only the regression tells them apart. What to change next. Let the forecaster over-react () and predict the sign of the slope; replace the card game by the closing-price model of the weekend problem and find how many days of data the test needs.
1.7 Build: martingale diagnostics
Purpose. Every forecast the miniature firm publishes (a fair value, an expected closing price, a predicted fill rate) is checked for the martingale property before anyone trades on it or against it.
Interface. revisions(paths); revision_regression(paths, lag=1, col=None) returning slope, standard error, and ; variance_ratio(increments, q); variance_shares(paths); martingale_report(paths). A panel has one row per day or deal and one column per revision time.
Rules. No intercept in the revision regression (the mean revision is reported separately); variance shares are those of the revisions, which for a martingale sum to the variance of the final value; everything seeded and vectorised.
Acceptance tests. code/firm/mgtest/tests/: random walks pass; a forecast that adds half of the news late is caught with the right slope; shares are uniform for iid revisions; the variance ratio is one for iid increments and below one for mean-reverting ones.
Stretch. Heteroskedasticity- and autocorrelation-robust standard errors (chapter 11); a test of the revisions against any -measurable signal, not only past revisions; multiple-testing control across many forecasts (chapter 12).
Sources and further reading
- A. N. Kolmogorov, Grundbegriffe der Wahrscheinlichkeitsrechnung, Springer, 1933: the measure-theoretic axioms.
- J. Ville, Étude critique de la notion de collectif, Gauthier-Villars, 1939, where the word martingale enters probability.
- J. L. Doob, Stochastic Processes, Wiley, 1953.
- O. Nikodym, “Sur une généralisation des intégrales de M. J. Radon”, Fundamenta Mathematicae 15, 1930.
- D. Williams, Probability with Martingales, Cambridge University Press, 1991: the proofs admitted here.
1.8 Exercises
Exercise 1.1 ★
In the five-card game, what is the forecast of the sum after the first card turns out to be a king?
Solution
Solution of Exercise 1.1.
, against 35 before the deal.
Exercise 1.2 ★
Which of these are stopping times for the filtration of observed prices: (a) the first time the price is 1% above the open; (b) the time of the day’s low; (c) 15:50; (d) the first time after 15:50 that the forecast of the close moves by more than 10 cents?
Solution
Solution of Exercise 1.2.
(a) Yes: whether it has happened is known at each instant. (b) No: the low is known only at the close. (c) Yes: a deterministic time is a stopping time. (d) Yes, provided the forecast is itself adapted to the observed information.
Exercise 1.3 ★
A position on a fair -tick walk is closed at or . What is the probability of the take-profit, and why is the expected profit still zero?
Solution
Solution of Exercise 1.3.
. The stopped walk is bounded, so optional stopping gives : . Winning often is paid for by losing more when it loses.
Exercise 1.4 ★★
A forecast of the close is revised by independent news of equal variance in each of the 390 minutes of a session, and nothing else. What share of the close’s variance is resolved in the last half hour?
Solution
Solution of Exercise 1.4.
The revisions are orthogonal with equal variances, so the last 30 minutes resolve of the variance.
Exercise 1.5 ★★
Under , , and . Compute and , and check that is a probability measure.
Solution
Solution of Exercise 1.5.
and , so is a probability measure equivalent to . Its characteristic function is (Example 1.16): under , so and .
Exercise 1.6 ★★
The under-reacting card forecaster publishes for and . Compute and the slope of the regression of on .
Solution
Solution of Exercise 1.6.
, so : the revision is predictable, and the slope is at . The same slope appears on the previous revision , because is a sum of orthogonal revisions of which is one.
Exercise 1.7 ★★★
Coding. With revision_regression, estimate the slope of the last revision of the under-reacting card forecaster () on the previous revision over 20 000 seeded deals, and compare it with the answer to Exercise 1.6.
Solution
Solution of Exercise 1.7.
0.661 with a -statistic of 45.9, against 0.667 in theory; the honest forecaster’s slope is .
Exercise 1.8 ★★★
Find the flaw. “Over a year our fair-value model’s revisions averaged zero to four decimals, so the model is a martingale and nobody can trade against it.” Correct it.
Solution
Solution of Exercise 1.8.
A mean of zero is necessary, not sufficient: the under-reacting card forecaster also has revisions averaging zero. A martingale’s revisions must be unpredictable from everything known before them, starting with its own past revisions, and the test is a regression of revisions on earlier information, with standard errors that allow for the clustering of volatility (chapter 11) and a correction for the many signals one tries (chapter 12).
1.9 Problem: The Fair Value of the Close
Problem 1.1
Weekend problem — how much of the close is still unknown at ten to four
A desk publishes , its forecast of a stock’s closing price . In its model the price starts at USD 100 and moves in each of the 390 minutes of the session by independent Gaussian increments with a total standard deviation of USD 1.80 over the day; at 15:50 the imbalance of the closing auction is published, which moves the forecast by an independent Gaussian amount with standard deviation USD 0.30 and zero mean; the last ten minutes of the session follow.
Part I — The forecast.
- What are the variance and standard deviation of ?
- Write before 15:50 and after the news, in terms of the observed price.
- Why is a martingale for the desk’s filtration?
- What is the revision of at the 15:50 news?
- What is the probability that the news moves the forecast by more than 14 cents?
Part II — What is resolved when.
- Why do the variances of the revisions add up to ?
- What share of is resolved by noon?
- What share is resolved at the news itself?
- What share is resolved from the news to the close, inclusive?
- Check this share against the simulation of 20 000 days.
Part III — A forecast that is too slow.
- A second desk adds only half of at 15:50 and the other half at the close. Is its forecast a martingale?
- What is the correlation between its 15:50 revision and its revision over the last ten minutes?
- What slope does the regression of the second revision on the first give, in theory and in the simulation?
- How many days of data does the test need for the slope’s -statistic to reach 2?
- A trader buys one share from that desk at its forecast at 15:50 when its revision is positive, sells one when it is negative, and closes at the close. What does it earn on average per share?
Part IV — Judgement.
- If the last ten minutes carry three times the per-minute variance of the rest of the day (with the day’s total unchanged), what share is resolved from the news to the close?
- Does the answer depend on the price level?
- Why does the share matter to a trader who can only act in the closing auction?
- State the named result: the share of the close’s variance resolved from 15:50.
- In one sentence: what does the martingale property of a forecast promise, and what does it not?
Solution
Solution of Problem 1.1.
1. ; standard deviation USD 1.82. 2. Before the news, , the price observed at (the remaining increments and have mean zero); after it, . 3. It is the Doob martingale of an integrable variable. 4. . 5. . 6. The revisions are orthogonal (Proposition 1.8), so their variances add, and is a constant. 7. . 8. . 9. : 2.7% at the news and 2.5% in the last ten minutes. 10. 5.23% in the 20 000 simulated days. 11. No: its revision over the last ten minutes contains , which its 15:50 revision predicts. 12. The two revisions are and ten minutes of increments; the correlation is . 13. Slope ; the simulation gives 0.98 with a -statistic of 72 over 20 000 days. 14. With , needs days. 15. The trade earns times the sign of , whose mean is : 12 cents a share. 16. The last ten minutes then carry , and the share is . 17. No, if both standard deviations scale with the price: the shares are ratios of variances. 18. What is resolved after the last moment one can act is risk one carries, not information one can use; a trader deciding at 15:50 faces 5.2% of the day’s variance, not 100%. 19. Named result: the fair value of the close: in the model, 5.2% of the variance of the closing price is resolved from the 15:50 news to the close (2.7% by the news itself), and 9.8% if the last ten minutes are three times as volatile. 20. It promises that the revisions cannot be predicted from the forecaster’s own information, so nobody with that information can trade profitably against it; it promises nothing about accuracy.
1.10 Interview questions
Interview question 1.1 ★ trader
You play a fair coin game for a dollar a toss and stop as soon as you are one dollar up. Isn’t that a guaranteed win?
Solution
Solution of Interview question 1.1.
With unlimited time and credit you stop at almost surely, but the stopping time is unbounded and the losses before it are not uniformly integrable; with any finite credit you win with probability and lose otherwise: expected value zero.
What the interviewer is looking for: optional stopping and why its conditions matter.
Interview question 1.2 ★ researcher
What is a martingale? Is a stock price one?
Solution
Solution of Interview question 1.2.
An adapted integrable process whose conditional expectation of any future value is its current value. A stock price has a positive expected return under the real-world measure, so it is a submartingale there; discounted by the money-market account it is a martingale under the risk-neutral measure (chapter 5).
What the interviewer is looking for: the definition and the role of the measure.
Interview question 1.3 ★★ researcher, mle
Show that the increments of a martingale are uncorrelated. What does that imply for a forecast you publish?
Solution
Solution of Interview question 1.3.
For , . A forecast that is an honest conditional expectation has revisions no one can predict from its past revisions; if a regression of today’s revision on yesterday’s has a slope, the forecast is inefficient.
What the interviewer is looking for: taking out what is known, and the testable consequence.
Interview question 1.4 ★★ trader
At the imbalance publication your forecast of the close moves 14 cents; a competitor’s moves 7 cents, then another 7 at the close, every day. What do you do?
Solution
Solution of Interview question 1.4.
The competitor’s second revision is predictable from its first, so its forecast is not a martingale: it under-reacts. Trade against its stale price at 15:50 in the direction of the news; in the chapter’s model this earns half the mean absolute news, 12 cents a share.
What the interviewer is looking for: predictable revisions mean an exploitable forecast.
Interview question 1.5 ★★ researcher, risk
When is the linear regression of on ?
Solution
Solution of Interview question 1.5.
is the best predictor among all functions of ; the linear regression is the best among affine ones. They coincide when is affine, as it is when is jointly Gaussian.
What the interviewer is looking for: projections onto nested subspaces; the Gaussian case.
Interview question 1.6 ★★★ developer, researcher
Design a daily check that a real-time fair-value service behaves like a martingale. What can make the check lie?
Solution
Solution of Interview question 1.6.
Store every published value with its timestamp; each day regress revisions over fixed horizons on the previous revision and on other information available at the earlier time (order-book imbalance, recent trades), with robust standard errors, and report the variance shares by time of day. It lies if horizons overlap (serially correlated errors), if the volatility is heteroskedastic and the standard errors ignore it, if the timestamps are those of publication rather than of the information (look-ahead), if many signals are tested and the best one is reported, and if the final value is itself revised.
What the interviewer is looking for: regression of revisions on prior information, and the ways the test fails.