Machine learning models for trading: which ones actually work on market data

You have seen the LSTM tutorial with the price line that tracks the real one almost perfectly. You have also seen the forum thread where someone tried it live. This guide is about the gap between those two, and which models close it.

"Which machine-learning model is best for trading" is the wrong question, and the right one is short: what does your data look like? Market data, for the purpose of most trading strategies, is a table — one row per bar, a few dozen columns of indicators and derived features, a label saying what happened next. It is small (ten years of daily bars is about 2,500 rows), noisy (most of the variance in the label is unpredictable), and non-stationary (the relationships drift). Those three properties decide which model families earn their keep, and the answer is not the one the tutorials suggest.

The six families

Gradient-boosted trees

A sequence of small decision trees, each one trained to correct the errors of the ones before it. XGBoost and LightGBM are the best-known implementations. On tabular data of the size and noise level found in trading, this family is the strongest default by a clear margin — it handles non-linear interactions between features, ignores irrelevant columns, needs no scaling, and has regularisation knobs that actually work.

Its risk is the same as its strength: it will fit anything, including noise, if you let it. Shallow trees, few rounds, and strong regularisation, validated out of sample, are not optional.

Random forests

Many deep trees trained on random subsets of rows and columns, with the predictions averaged. Less prone to overfitting than boosting out of the box, slightly less accurate at its best, and very forgiving of bad hyperparameters. A good second opinion, and a good first model when you have not tuned anything yet.

k-nearest neighbours

No training in the usual sense: the model keeps the history and answers each new bar by finding the most similar past bars and reporting what happened after them. It is the most transparent family — you can look at the neighbours — and the most sensitive to which features you chose and how distance is measured. Lorentzian Classification, the popular TradingView indicator, is a kNN with an unusual distance metric. kNN degrades badly with many features and needs the neighbours to be genuinely comparable, which drifting markets do not guarantee.

Support vector machines

Draws the boundary between classes that leaves the widest margin, optionally in a transformed feature space. Strong on small datasets with clean structure; less forgiving of noise, and expensive to tune. Worth having on the bench for the cases where the boundary really is simple.

Linear and regularised models

Logistic regression, ridge, lasso. They cannot learn interactions between features unless you build them by hand, which sounds like a weakness and on noisy data is often a strength: there is less to overfit. A regularised linear model is the benchmark every fancier model must beat. If your boosted trees do not outperform a ridge regression out of sample, they have learned noise and the ridge has not.

Neural networks, and why LSTMs disappoint here

Deep learning dominates images, audio and language, and every tutorial about "AI stock prediction" uses it. On tabular market data it usually loses to boosted trees, and the reasons are structural:

  1. Not enough data. Networks need many examples per parameter. A few thousand bars will not constrain a network with a hundred thousand weights; it memorises.
  2. Too much noise. Deep networks are good at finding subtle structure. When the label is mostly noise, subtle structure is mostly noise too.
  3. The trivial forecast. Price series are highly autocorrelated, so predicting "tomorrow's close ≈ today's close" scores very well on any error metric. Most LSTM tutorial curves are exactly that forecast, one step behind the real line, and the LSTM guide shows how to tell.
  4. Leakage through scaling. The standard tutorial normalises the whole series before splitting, which hands the model the future's range. Remove that and the curve gets a lot less impressive.

This is not a trading-specific finding. Grinsztajn, Oyallon and Varoquaux's 2022 paper "Why do tree-based models still outperform deep learning on tabular data?" found the same pattern across dozens of tabular datasets from many domains. Trading data is tabular, small and noisy — the case where the gap is widest.

Model families on tabular market data
FamilyTypical strengthMain riskReasonable use
Gradient-boosted treesStrongest default; handles interactions and irrelevant featuresOverfits noise if under-regularisedPrimary model, heavily regularised
Random forestRobust, forgiving, hard to breakSlightly lower ceilingSecond opinion; first model before tuning
k-nearest neighboursTransparent; no training stepFeature choice and drift; curse of dimensionalityFew, well-chosen features; regime-aware windows
SVMWide-margin boundaries on small dataNoise-sensitive; costly to tuneSimple boundaries; small feature sets
Linear / regularisedHard to overfit; interpretableCannot learn interactions on its ownThe benchmark everything must beat
Neural networksRich structure on large clean dataMemorises small noisy data; leakage via scalingRarely, and only after trees fail to beat linear

The benchmark rule

Before any model earns a place, it has to beat two things out of sample: a regularised linear model on the same features, and the base rate — always predicting the most common class. Against the base rate the right metric is not accuracy (which the base-rate predictor wins by construction) but precision and Matthews correlation; the report-reading guide covers why. A model that beats neither has learned nothing, and a model that beats the base rate but not ridge regression has learned something ridge already knew.

Ensembles: why agreement beats tuning

Different families make different mistakes. A boosted tree, a random forest and a kNN trained on the same data will disagree on the bars where the signal is weakest — which is exactly where you want to be told to sit out. Letting several models vote, and trading only when they agree, usually produces fewer trades with higher precision than any single model tuned harder. The ensemble guide covers how to weight the votes and when an ensemble is worse than its best member.

What matters more than the model

Ranked by how much they change the out-of-sample result, in our experience: how the labels are defined (see triple-barrier labelling); whether the validation is chronological with a purge gap; whether the features are computed causally; how costs are charged; and then, some distance behind, which model family. A ridge regression validated properly will beat a transformer validated carelessly, every time, and the second one will look better in the report.

The bench in Wise Apple

Wise Apple ships nineteen supervised models across the six families above — three k-nearest-neighbour models including Lorentzian Classification, two decision trees, two random forests, two XGBoost models, nine gradient-boosted learners including a LightGBM-class engine, and one SVM — and they train on your own machine, so running the whole bench against one feature set costs nothing but time. Each is scored out of sample on precision, recall and MCC, ranked, and available to the Ensemble Voting layer, where votes are weighted by skill rather than by profit. There is no neural network on the bench, for the reasons in the section above; if one ever earns a place, it will be because it beat the ridge.

Questions traders ask about ML models for trading

Which machine learning model is best for trading?

On tabular market data — one row per bar, a few dozen features — regularised gradient-boosted trees are the strongest default, with random forests close behind. But the model family matters less than how the labels are defined, whether validation is chronological with a purge gap, whether features are computed without look-ahead, and whether costs are charged. A linear model validated properly beats a complex one validated carelessly.

Do LSTMs and deep learning work for stock prediction?

Rarely, on the data retail traders have. Market data is small, noisy and tabular, and deep networks memorise small noisy datasets. The impressive tutorial curves are usually a one-step-behind copy of the price series, often helped by scaling that leaked the future. Grinsztajn and colleagues' 2022 study found tree models beat deep learning on tabular data generally; trading is the hard case of that finding.

What is the benchmark a trading model has to beat?

Two things, out of sample: a regularised linear model on the same features, and the base rate — always predicting the most common class. Against the base rate, use precision and Matthews correlation rather than accuracy, which the base rate wins by construction on imbalanced market labels.

Is an ensemble of models better than a single model?

Often, when the members make different mistakes. Voting across families trades only where they agree, which usually means fewer trades at higher precision. It is worse when the members are near-copies of each other, when a weak member is given equal weight, or when the ensemble is used to rescue models that individually failed to beat the linear benchmark.

Has anyone actually had success with machine learning in trading?

Yes, but the successes look different from the tutorials: modest predictive power on a well-defined label, used through position sizing or as a filter rather than as a crystal ball, with tree models on engineered features rather than a neural network on raw prices. Gu, Kelly and Xiu's 2020 study of machine learning in asset pricing found small but real out-of-sample gains from tree models and shallow networks. The failures are mostly leakage, fixed-horizon labels, and models judged on accuracy.