Machine Learning for Stock Trading: How It Works, With Real Model Results

Author:
Published:
Topic: AI Trading

Machine Learning for Stock Trading: How It Works, With Real Model Results
 

Executive summary. Machine learning for stock trading is not a crystal ball. It is a disciplined way to turn many weak, noisy clues into a decision about when to own something and when to step aside. This guide explains how machine learning trading models are built, how they are tested, where they break, and what the published record of PortfolioAI's four models actually looks like—losses included. The short version: about half of all closed calls lose money, and that is normal. What matters is how large the winners are compared with the losers.

What machine learning in trading actually does

Most people picture machine learning predicting tomorrow's stock price. In practice, useful machine learning trading strategies ask a narrower question: given what we know today, is the next stretch of time more likely to be good or bad for this security? That is a classification problem, and it is far more tractable than forecasting an exact price.

A model learns that relationship from history. Each trading day becomes one example. The features describe what was known that day—recent returns, trend strength, volatility, volume, valuation, earnings revisions, and how the stock behaves relative to its sector or the market. The label describes what happened next, for example whether the security outperformed over the following weeks. The model's job is to find combinations of features that, historically, came before good or bad outcomes.

That last word matters: historically. Markets change, so a model that learned last decade's patterns can fail in this one. Everything else in good machine learning stock trading—testing, retraining, position rules—exists to manage that one problem.

The data: features, labels and leakage

Features are where most of the edge, and most of the mistakes, live. PortfolioAI's systems use more than 192 technical and fundamental features per security, and each security gets its own models rather than one model forced to fit every ticker. A few principles apply to any machine learning for trading project:

  • Only use what you would have known at the time. Fundamentals are reported weeks after a quarter ends; index membership changes; companies get delisted. Using today's version of yesterday's data is called lookahead, and it quietly inflates results.
  • Scale features so they mean the same thing over time. A $5 move meant something different when a stock traded at $20 than at $400. Returns, z-scores and percentile ranks travel across regimes better than raw prices.
  • Pick a label that matches the trade. If you hold positions for weeks, a next-day label teaches the model the wrong thing.
  • Watch for leakage between overlapping windows. Labels built from overlapping return windows can bleed information from the test period into training unless you leave a gap.

Models used for machine learning stock trading

There is no single best algorithm. Each family trades off flexibility against the risk of memorising noise:

Model familyStrengthMain risk
Logistic regressionSimple, stable, easy to explainMisses interactions between features
Random forests and gradient-boosted treesHandle messy tabular data and non-linear interactions wellCan overfit if trees are deep and data is thin
Recurrent and sequence models (LSTM, transformers)Learn from the order of events in a time seriesNeed a lot of data; easy to fit noise in daily prices
Reinforcement learningOptimises a full trading policy, not just a forecastVery sensitive to the simulated environment and costs

For most stock trading problems, tree-based models on well-built features are a strong default. Combining several models into an ensemble usually helps more than tuning one model to perfection, because the errors of different models partly cancel out. PortfolioAI uses an ensemble of models per security and retrains them frequently as new data arrives.

From a prediction to a trade

A probability is not a position. Turning model output into a machine learning trading strategy takes a few more decisions:

  1. Choose the universe. Which securities is the model allowed to hold? A model is only as good as the menu it picks from. PortfolioAI's universes are hand-curated: the model times entries and exits, but a person decides what is worth timing.
  2. Set entry and exit rules. Buy when the model's confidence crosses a threshold, sell when it falls back. Hysteresis—different thresholds for getting in and getting out—cuts down on costly flip-flopping.
  3. Decide position sizing. Equal weight, volatility-scaled, or capped. Sizing often matters more than the model itself.
  4. Check on a fixed schedule. PortfolioAI's models are checked daily, and the daily email reports each model's In, Out and resulting portfolio.

You can see four very different applications of the same approach on PortfolioAI's system pages:

Testing: why walk-forward beats a pretty backtest

The most common way machine learning in trading goes wrong is not a bad algorithm. It is a test that lets the model see the answers. If you design features, pick thresholds and measure results on the same stretch of history, almost anything looks brilliant.

Walk-forward testing fixes that. Train on one window, freeze everything, then measure on the next window the model has never seen. Roll forward and repeat. Stitch the test windows together and you get something much closer to what an investor would have experienced in real time. Add realistic transaction costs and slippage before you believe any number.

We cover the full protocol—splits, embargo gaps, costs and regime checks—in Walk-Forward Backtesting for Quant Portfolios: An Honest Research Playbook.

The real record: PortfolioAI's closed calls, losses included

Talking about machine learning is easy. Here is what our four models have actually done. The PortfolioAI scorecard lists every closed call we can reconstruct from each system's published history: the symbol, the entry date, the exit date, and the change in system equity over the hold. As of October 2026 there are 236 closed calls: 117 up and 119 down or flat.

Closed calls by system from the published history (from 2018; from 2024 for Bitcoin). Result is the change in system equity over each hold, not a per-share return. Data as of October 9, 2026.
SystemClosed callsUpDown or flatAverage winning callAverage losing callMedian call
Market Risk On / Off1284+14.4%−2.2%+2.9%
Best of Big Tech & Friends1095851+21.3%−3.7%+0.5%
Best Two Commodities874146+10.5%−3.4%−0.3%
Bitcoin281018+17.4%−2.7%−1.3%
All systems236117119Median call across all systems: about flat (−0.1%)

Three things stand out, and they are true of most systematic trading, not just ours:

  • The win rate is roughly a coin flip. Across all four systems, slightly more calls lost than won. The Bitcoin model lost on 18 of its 28 calls. If someone shows you a machine learning trading system that wins 90% of the time, ask what the losers look like.
  • The edge is in the size of wins versus losses. In every system the average winning call is three to six times larger than the average losing call. Exits that cut losers quickly while letting winners run do more of the work than the model's accuracy.
  • Long holds make the averages lumpy. A handful of long, trending holds produce most of the gains, so the median call sits near zero. That is why you judge a system on its full record and drawdowns, not on a single good month.

Each system page shows its latest closed calls next to its CAGR, Sharpe ratio and maximum drawdown. Past performance is not indicative of future results.

What machine learning gets wrong

An honest guide to machine learning for stock trading has to spend time on failure. These are the problems we see most often, including in our own record:

  • Regime changes. A model trained in a falling-rate, low-inflation world can misread a rising-rate one. Frequent retraining helps but always lags a sudden shift.
  • Choppy, trendless markets. Timing models make money when trends persist. In sideways markets they get whipsawed: in and out, small loss after small loss. Our commodities model's median call is slightly negative for exactly this reason, and its worst single call was a 15% equity decline while holding natural gas (UNG) into early 2023.
  • Overfitting. With hundreds of features it is easy to find patterns that are pure coincidence. Walk-forward testing, simple baselines and skepticism toward results that look too smooth are the defence.
  • Costs and capacity. A strategy that trades daily on small edges can be wiped out by spreads, slippage and taxes. Always count them.
  • Crowding. When many funds use similar features, the same signals trigger at the same time and the edge shrinks. This is one reason hand-curated universes and per-security models matter.

How to use machine learning trading signals sensibly

If you are evaluating a machine learning trading system—ours or anyone else's—use this checklist:

  1. Demand the full record. Every call, including the losers, with entry and exit dates.
  2. Check how it was tested. Out-of-sample or walk-forward results, with costs, are the minimum.
  3. Look at the worst stretch, not the average. Maximum drawdown tells you whether you could actually stay with it.
  4. Compare with a simple baseline. If buy-and-hold or an equal-weight mix did almost as well with less risk, the model isn't adding much.
  5. Spread risk across uncorrelated engines. An equity timing model, a defensive pair, commodities and crypto respond to different forces. Our guide on how to weight trading strategies walks through one approach.
  6. Treat signals as information, not instructions. A model's In and Out are a record of what it did, not personalised advice. Fit them to your own goals, taxes and time horizon.

The bottom line

Machine learning for stock trading works best when it is used to answer a narrow question—when to own a carefully chosen security—and when it is tested as if the future were unknown, because it is. Expect to be wrong about half the time. Judge a system by whether its winners are meaningfully larger than its losers and whether you can live with its worst drawdown.

You can follow PortfolioAI's four models on the scorecard and on each system page, or get the daily In and Out email. Plans with real-time signals are on the pricing page.

PortfolioAI publishes general model output, not personalised investment advice. PortfolioAI is not a registered broker-dealer or investment adviser. Past performance is not indicative of future results, and you can lose money.

 

 

FAQ

How is machine learning used for stock trading?

Machine learning models learn from historical features such as trend, volatility, volume and fundamentals to estimate whether the coming period is more likely to be good or bad for a security. Trading rules then turn those estimates into entries and exits.


Does machine learning make stock trading more accurate?

Not necessarily more accurate. PortfolioAI's four models won on 117 of 236 closed calls, about half. The edge comes from winning calls being several times larger than losing calls, not from a high win rate.


Which machine learning models work best for trading?

Tree-based models such as gradient-boosted trees and random forests are strong defaults for tabular market data. Ensembles of several models usually beat a single heavily tuned model. Sequence models and reinforcement learning need much more data and are easier to overfit.


How should a machine learning trading strategy be tested?

Use walk-forward testing: train on one window, freeze the model, measure on the next unseen window, and roll forward. Include transaction costs and slippage, and compare against simple baselines such as buy-and-hold.


What are the main risks of machine learning in trading?

Regime changes, choppy trendless markets, overfitting to coincidental patterns, trading costs, and crowding when many funds use similar signals. Past performance is not indicative of future results.


 
Sign Up
Simple signals, delivered to you daily ... for FREE!