Open Family Office Datasets Tickers Strategies Portfolios Research Posts About Changelog

Advances in Financial Machine Learning

Source

Citation. Marcos López de Prado. Advances in Financial Machine Learning. John Wiley & Sons, Hoboken, New Jersey, 2018. ISBN 978-1-119-48208-6 (hardcover), 978-1-119-48211-6 (ePDF). Publisher's page. The author was a research fellow at Lawrence Berkeley National Laboratory, and taught at Cornell University. The book prints its Python code as snippets, written for Python 2 and an older pandas. It links to no code repository or data. It states that the views are the author's own, not those of his employers.

Status. Planned. #10 builds the splitters from chapters 7 and 12, and #31 sets the purge and embargo for each horizon. #8 implements the statistics of chapter 14, and #11 implements PBO from chapter 11. No code in the repo uses the book yet.

Read. Read on 2026-11-27 from the maintainer's copy of the ePDF, 393 pages, with its text extracted by pdftotext. I read chapters 7, 11, 12, 14 and 15 in full in the author's own words, and section [removed] on a strategy's life. For chapter 13 I read the text in full, and the 25 heat-maps only through their captions and the text about them. I didn't read chapters 3, 4 and 10, except where the chapters above use them. The extracted equations lost their layout. I took each formula from the code snippets where the text was unclear, and I recomputed every worked number below.

Summary

Claim. Standard cross-validation leaks information in finance, and a backtest is a weak research tool that selection bias makes easy to overfit. The book proposes purged and embargoed k-fold, combinatorial purged cross-validation (CPCV), trading rules derived from synthetic data, and a set of backtest statistics. It also gives a probability that a strategy fails its target Sharpe ratio.

Method. This is a book of methods, with no empirical study of real strategies. Each method comes with a derivation, Python code and, in places, a simulation.

Findings, as the source reports them.

Setting Number Value
Chapter 7, the embargo h that "often suffices" about 0.01 T
Chapter 11, CSCV with S = 16 combinations, as printed 12,780
Chapter 11, Figure 11.1 OOS Sharpe ratio against IS 0.87 − 0.75 · SR IS, adjusted R² = 0.17
The same, Figure 11.2 PBO 0.74
Chapter 12, N = 6 and k = 2 splits, and paths 15 and 5
Chapter 12, k = 2 paths N − 1
Chapter 12, walk-forward with warm-up t₀ share of the data that half of the decisions use, on average 3/4 · t₀/T + 1/4
Chapter 13, zero forecast, half-life 5 best Sharpe ratio, not annualised about 3.2
Chapter 13, forecast 5, half-life 5 the same about 12
Chapter 13, forecast 5, half-life 100 the same 0.32
Chapter 14, PSR and DSR threshold for a 5% test 0.95
Chapter 15, symmetric payouts, p = 0.55 bets a year for an annual Sharpe ratio of 2 396
The same, n = 52 precision for a Sharpe ratio of 2 0.6336
Chapter 15, n = 260, π⁻ = −0.01, π⁺ = 0.005 Sharpe ratio at p = 0.70, and p for θ = 2 1.173 and 0.72
The same p at which the Sharpe ratio is zero 2/3
Chapter 15, deployment rule largest P[p < p_θ*] 0.05

My checks agree with each of these, except the 12,780. C(16, 8) is 12,870. φ[6, 2] = (2/6) · 15 = 5. The p = 0.72 and 0.6667 come from the book's own binHR, and the 1.173 from its formula for θ.

The book states three "laws of backtesting". The second: "Backtesting while researching is like drinking and driving." The third: "Every backtest result must be reported in conjunction with all the trials involved in its production."

A strategy's life (section [removed]). A strategy first runs on data after the backtest's end, which the book also calls an "embargo". If that agrees with the backtest, the strategy paper-trades on a live feed, "for as long as it is needed to gather enough evidence". It then graduates to a small real allocation, which grows while it performs as expected. It ends when it performs below expectations "for a sufficiently extended period". The book gives no length for any stage.

Where the claims go beyond the evidence

The strategy-risk code mis-states the spread of p. The text approximates the bootstrap of p as N[p̄, p̄(1 − p̄)]. A share of ⌊nk⌋ bets has variance p̄(1 − p̄)/⌊nk⌋. Snippet 15.5 also passes the variance p(1 − p) to scipy.stats.norm.cdf as the standard deviation. I ran the book's own example, 2,600 draws from its mixture of Gaussians with n = 260 and θ* = 2. The code gives P[p < p_θ*] = 0.46. The correct spread gives 0.24 for k = 1 year and 0.16 for k = 2 years. So the book's rule of "disregard above 0.05" acts on a number that is wrong by a factor of two or three here.

CPCV can't drive the variance to zero. Section 12.5 says that "in the limit CPCV will report the true Sharpe ratio … with zero variance". Its own formula is σ²[μ] = φ⁻¹σ²(1 + (φ − 1)ρ̄). As φ grows, this tends to ρ̄σ², not zero, unless ρ̄ is zero. Every path uses the same T observations, so ρ̄ stays above zero. More paths don't add data. The claim that CPCV removes selection bias rests on this limit.

No test shows CPCV beats walk-forward. The book argues the case from formulas, and gives no simulation that compares false-discovery rates. Its claim that walk-backward backtests do no worse than walk-forward ones ("That is not the case") comes with no data. Arian et al. (2024) later ran that comparison, and found CPCV's lead small (backtest-overfitting-ml-era.md).

The embargo of 0.01 T has no derivation. The book says a small h "often suffices". It offers a test: raise k toward T, and check that performance stops improving. It gives no example of the test, and h doesn't depend on the horizon or on the serial correlation of the features.

The synthetic trading rule is still fit to history. The O-U parameters come from one OLS fit on the whole sample, and the simulation treats them as known. Their estimation error doesn't enter the rule. All results assume one process, σ = 1 and no costs. The conclusion states a conjecture of a unique optimal rule for any O-U process. Yet the text on Figure 13.5, an O-U process with a half-life of 100, says "there is no optimal trading rule".

Figure 11.1 has no stated data. The PBO of 0.74 and the regression come with no description of the strategies, the market or the number of trials.

The statistics come with few errors. Chapter 14 lists more than 30 statistics, such as the HHI concentration, the 95th-percentile drawdown and time under water. Only PSR and DSR come with a sampling distribution. DSR needs the number of independent trials, and chapter 14 doesn't say how to estimate it.

Inconsistencies in the text.

Credit. The author states that a backtest proves nothing, and that every backtest result must come with all its trials. He prints code for each method, so a reader can check it. That is how the error in Snippet 15.5 came to light.

Use in this repo

#10: the splitters. Snippet 7.3 gives the purge: keep a training observation before the test set only if its label ends before the test starts. After the test set, start training at the end of the last test label, plus the embargo. CPCV's count of paths is in docs/soundness.md O9 already. #10 should also keep the book's rule for paths: k = 2 and N = φ + 1 gives φ paths. It should report each path's Sharpe ratio, and the correlation ρ̄ between paths, because ρ̄ sets how much the paths really add.

#31: a test for the embargo. The book's 0.01 T has no evidence behind it. Its test gives RQ4 a method: for each horizon, raise k and find the h at which performance stops improving. A horizon whose performance keeps rising with k still leaks.

#11 and #7: the trial ledger is the third law. PBO needs the returns of every trial, and DSR the number of trials. #7 records both. The second law says to specify the model in full before the backtest, and to start again when it fails. The ledger can show this, if it records each change made after a backtest as a new trial.

#8: the backtest statistics. Chapter 14 adds statistics that docs/soundness.md doesn't list yet. Two are the number of bets (a run of positions on one side) and the average holding period. Another is the HHI concentration of gains, losses and bets in time. It also adds the time under water and the return on execution costs. None has an error in the book, so #8 must bootstrap them, as it does for CVaR (M10). The book's PSR is the 2012 form. how-to-use-the-sharpe-ratio.md gives the revised form that #8 must choose between.

#8 and #11: strategy risk, with the spread corrected. P[p < p_θ*] shows how close a strategy is to a Sharpe ratio of zero. In the book's example, p falls from 0.70 to 0.67. #11's sensitivity report could add it, with the bootstrap or with variance p̄(1 − p̄)/⌊nk⌋, never with Snippet 15.5 as printed. It assumes independent bets with two payouts.

Chapter 13 doesn't apply yet. No strategy in open_familyoffice/strategies/ has a stop-loss or a profit target. If one gets them, chapter 13's mesh is a way to set them without a backtest. Each node of the mesh is still a trial for #7.

#87 and #32: paper trading. The book's life of a strategy matches the harness's order: a held-out period, then paper trading, then a small allocation that grows. It gives no length for paper trading. RQ5 (#32) holds that question. Walk-forward results "can be reconciled with paper trading", and CPCV results can't. So the forward test should compare with a walk-forward backtest, and CPCV should judge only the backtest.

A question for the maintainer. Should the protocol hold the second law as a rule? Then the repo closes a strategy whose backtest fails, and a changed version counts as a new strategy with its own trials. That would change the decision rule, so it needs a PROTOCOL_VERSION bump.