AnyLearn
All lessons
AIadvanced

Why Standard Machine Learning Fails on Market Data

Machine learning practice assumes independent samples, a stable data-generating process, and an environment that does not react to you. Financial data violates all three, and the result is models that validate beautifully and lose money. This lesson establishes what is actually broken before the rest of the course fixes it.

Updated · AI-authored, review-gated · how lessons are made

Not signed in: your progress and quiz score won't be saved.
Progress1 / 10

The transfer that does not happen

Take a practitioner who is genuinely good at machine learning, hand them price history, and the usual result is a model with excellent validation metrics that loses money in production. This is not a skills problem and it is not bad luck.

The standard workflow, split the data, cross-validate, tune on the validation score, ship the best model, rests on assumptions that are approximately true for images and text and are flatly false for markets.

Key idea: Financial data breaks three separate assumptions at once: that samples are independent, that the data-generating process is stable, and that the environment does not respond to your predictions. Each has its own failure mode, each is invisible in a validation score, and each has a specific remedy. This course is those remedies.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. The transfer that does not happen

Take a practitioner who is genuinely good at machine learning, hand them price history, and the usual result is a model with excellent validation metrics that loses money in production. This is not a skills problem and it is not bad luck.

The standard workflow, split the data, cross-validate, tune on the validation score, ship the best model, rests on assumptions that are approximately true for images and text and are flatly false for markets.

Key idea: Financial data breaks three separate assumptions at once: that samples are independent, that the data-generating process is stable, and that the environment does not respond to your predictions. Each has its own failure mode, each is invisible in a validation score, and each has a specific remedy. This course is those remedies.

2. The signal is very small, and that changes the method

In most applied machine learning, a model that is right 53 percent of the time is useless. In trading it can be a business.

That inversion has a consequence people miss. When the true edge is a couple of percentage points above chance, it sits well inside the range that noise, leakage and selection can manufacture on their own. In image classification, a leak that inflates accuracy by three points is a rounding error against a 97 percent baseline. Here it is larger than everything you were looking for.

Key idea: The lower the true signal, the higher the standard of evidence has to be, because the size of the effect you are hunting is comparable to the size of the mistakes you might be making. Most of the machinery in this course exists to keep methodological artefacts smaller than the edge, and in finance that is a demanding requirement rather than a formality.

3. Broken assumption one: the samples are not independent

Cross-validation assumes that holding out a sample tells you something about unseen data. That requires the held-out sample to be independent of the training ones, and financial samples are entangled in three distinct ways.

  • Overlapping labels. Label a sample by the return over the next 10 days, sample daily, and consecutive labels share 9 of their 10 returns. Two rows in your dataset can be built from almost the same future.
  • Serial correlation in features. A trailing 20-day volatility on Tuesday and on Wednesday are nearly the same number. Neighbouring rows are near-duplicates.
  • Cross-sectional correlation. On any given day, most equities move together. A thousand names is nowhere near a thousand independent observations.

Definition: Two samples are concurrent when their label windows overlap in time, so their outcomes are determined partly by the same price moves. Concurrency is the specific mechanism that lets information cross a train-test boundary without anything obviously wrong having been done.

4. What that entanglement is worth, measured

Predict first

Generate 3,000 days of pure Gaussian noise. There is no signal, by construction. Build trailing-window features, label each day by the sign of the next 10 days of return, and run an ordinary shuffled 5-fold cross-validation with a random forest. What accuracy comes back?

That experiment is reproducible in about forty lines, and it is worth running yourself, because the number is the whole argument. A validation procedure that reports skill on noise cannot be used to detect skill in anything else.

5. Broken assumption two: the process does not sit still

A cat in 2015 and a cat in 2025 are the same object. A market is not. Regulation changes, participants enter and leave, tick sizes change, volatility regimes shift, and the relationships a model learned can weaken or invert.

This is not drift in the usual monitoring sense, where the input distribution wanders while the underlying mapping holds. Here the mapping itself is a moving target, and a model trained across a regime boundary is fitting an average of two different worlds.

Gotcha: More history is not automatically better. Extending a training set back through a structurally different period adds rows and subtracts relevance, and the validation score will usually improve anyway because there are more samples to interpolate between. Sample size and sample relevance pull in opposite directions here, which is unusual and easy to get backwards.

The practical consequences, detection and retraining policy, get a lesson of their own later in this path.

6. Broken assumption three: the data fights back

No other machine learning domain has this property. Handwritten digits do not rearrange themselves once you learn to read them. Markets do, for two mechanical reasons.

  • Your own trading moves the thing you predicted. A signal that says buy causes buying, which moves the price toward the prediction and away from the profit. Edge and size are therefore not separable, and a strategy that works at one million can be worthless at a hundred.
  • Everyone else is running the same search. Any pattern discoverable from public data is being looked for by well-resourced competitors, and its returns fall as it is found and traded. Publication accelerates this.

Key idea: In supervised learning the labels are fixed and the only question is whether you can predict them. In markets the labels are produced by a process that includes participants reacting to predictions, including yours. That makes the target reflexive, and it is why a discovered edge has a shelf life rather than a value.

7. The four failures, and where each is fixed

Broken assumptionHow it shows upWhere it is fixed
Samples are independentvalidation reports skill that does not existpurging, embargo, sample weights (lesson 4)
The label is well posedfixed-horizon labels ignore risk and pathtriple-barrier labelling, meta-labelling (lesson 2)
The series is stationarydifferencing destroys the memory you neededfractional differentiation (lesson 3)
The environment is passivelive results decay away from backtestout of scope here, covered by the trading courses on execution and capacity

The fourth row is deliberately handed off. Capacity, impact and alpha decay are economic questions rather than data-preparation ones, and the catalogue's execution and backtesting courses cover them properly.

In practice: The ordering matters. Fixing validation last is the common mistake, because it means every earlier decision was made against a metric that was lying to you.

8. The traps that are not statistical at all

Before any modelling, a financial dataset has to survive a set of bookkeeping problems that silently insert the future into the past.

  • Restatements. Company fundamentals are revised after publication. A database holding the final revised figure lets a model see an earnings number months before anyone had it. The fix is point-in-time data, which stores what was known on each date rather than what turned out to be true.
  • Survivorship. An index constituent list downloaded today contains the firms that survived. Backtesting on it quietly removes every bankruptcy from history.
  • Timestamp semantics. Is that field stamped when the event happened, when it was published, or when your vendor ingested it? The gap between the three is where look-ahead lives.
  • Corporate actions. Splits and dividends must be adjusted consistently, and an inconsistent adjustment creates a fake return on the action date.

Gotcha: None of these is detectable from the model side. Every one produces a clean, well-behaved dataset that trains without complaint and validates well, and the only defence is auditing how each field was constructed.

9. Why the answer is not simply a better model

The instinct when results disappoint is to reach for a stronger architecture. In this setting that instinct makes things worse, and it is worth seeing why.

A more expressive model fits whatever structure is present, and in a leaked dataset the leakage is structure. Capacity that would find a real pattern will find the artificial one faster and more completely, so upgrading from logistic regression to a deep network typically raises the validated score and lowers the live performance.

Key idea: In low signal-to-noise problems, model capacity amplifies whatever your data preparation got wrong. That is why this course spends four lessons on labels, features and validation and none on architecture: the binding constraint is almost never the model.

The corollary is a useful test. If a change to your data pipeline moves the validated score more than a change of model class does, the pipeline is what you are actually measuring.

10. What this course covers, and what it does not

The three lessons that follow build the dataset, in the order the decisions have to be made.

  1. Labels. What are you predicting? Fixed-horizon returns are the default and are close to unusable, because they ignore risk, path and holding period. The triple-barrier method and meta-labelling replace them.
  2. Features. How do you make a series stationary without deleting the memory that carried the signal? Fractional differentiation is the answer, and it is a genuine dial rather than a binary choice.
  3. Validation. How do you measure anything, once you accept that neighbouring samples share futures? Purging, embargo, sample uniqueness weights, and the combinatorial variant.

In practice: This course stops at the point where you have an honest dataset and an honest score. What to do with them, backtest protocol, capacity, execution and risk, is covered by the existing courses on backtesting, trade execution and trading risk, and none of it is repeated here. The intended reading order is this course first, since those courses assume the data underneath them is sound.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. A shuffled 5-fold cross-validation on pure Gaussian noise with 10-day overlapping labels returns 54% accuracy. Why?
    • The random forest is overfitting the feature noise
    • Neighbouring samples share most of their forward returns, so shuffling puts near-duplicates of the test labels into training
    • Gaussian noise has a slight positive drift
    • Five folds is too few for a dataset of that size
  2. Why does a small true edge raise the standard of evidence rather than lower it?
    • Because small edges require larger datasets to reach statistical significance
    • Because small edges are more likely to be arbitraged away
    • Because the effect being sought is comparable in size to the artefacts leakage and selection can produce
    • Because transaction costs scale inversely with edge size
  3. Why is upgrading to a more expressive model often counterproductive on leaked financial data?
    • Larger models need more data than financial history provides
    • Deep models cannot represent financial relationships
    • Larger models train too slowly to be retrained as regimes change
    • Leakage is structure, so extra capacity fits the artefact faster and more completely
  4. What problem does point-in-time data solve?
    • Restatements: it stores what was known on each date rather than the later revised figure
    • Serial correlation between neighbouring feature rows
    • Non-stationarity of the return series
    • Cross-sectional correlation across many instruments
  5. Which assumption breakage is unique to markets among machine learning domains?
    • Samples are not independent
    • The data-generating process is non-stationary
    • The environment reacts to your predictions, through your own impact and through competitors finding the same pattern
    • The label is noisy

Related lessons

AI
advanced

Validation: Measuring Anything at All

Shuffled cross-validation reports 54 percent accuracy on data containing no signal, because neighbouring samples share their futures. This lesson builds purging, embargo and sample uniqueness weights, shows the illusion scaling with label overlap and vanishing when the fix is applied, and covers why a single walk-forward path is weak evidence.

10 steps·~15 min
AI
advanced

Why Reported Order Book Results Do Not Replicate

At a one-event horizon, 92 percent of mid-price labels are exactly no-change, so a model that always predicts flat scores 92 percent accuracy. This lesson computes that baseline across horizons and works through the four mechanisms that turn a genuine measurement into a number nobody can reproduce.

10 steps·~15 min
AI
advanced

Features: Stationarity Without Erasing the Memory

Prices are non-stationary and returns are stationary but forget everything, so the standard fix throws away the level information a model needed. This lesson builds fractional differentiation, which makes the choice a dial rather than a switch, and shows by computation that most of the memory can be kept while still passing a stationarity test.

10 steps·~15 min
AI
advanced

Evaluating a Book Model Honestly

If your cost per round trip equals the move you are trying to capture, you need 100 percent directional accuracy to break even. This lesson computes that hurdle, replaces accuracy with metrics tied to a tradeable decision, and covers the capacity and latency limits that decide whether a real edge is worth anything.

10 steps·~15 min