Quant Lab · Interactive machine learning

Can machine learning pick stocks?

Build a market, train a model and trade its predictions. Every number below is computed live in your browser: change a slider and the model is re-trained from scratch, then tested the honest way, on months it has never seen.

Trains live in your browser Simulated market Walk-forward, no look-ahead
Try a scenario

Starting…

Growth of $1

Out-of-sample only: the model had never seen any of these months when it traded them. Log scale, so equal steps are equal percentage gains. Hover or use the arrow keys to read values.

Show as table

Drawdown

How far the long–short strategy sits below its previous peak.

Return by predicted quintile

Annualised. A good model gives a staircase: the stocks it likes most should earn the most.

Prediction skill by month

Rank IC: the correlation between the model's ranking and what stocks actually did. Bars wobble a lot month to month; the average is what matters.

What the model relied on

Permutation importance: shuffle one feature and see how much the model's skill drops. Because this is a simulation, we know which features are real.

Computing…

What-if: score a stock

Dial in a stock's features (in standard deviations from the average stock) and the trained model scores it.

Model race

Run all four models on this exact market and strategy, each with its default setting. "IC seen → unseen" compares skill on training data with skill on months the model never saw.

How it works

  1. Simulate

    Each month, every stock gets six familiar features (momentum, value, quality, low volatility, reversal, size) plus any junk features you add. Next month's return is built from these plus fat-tailed noise, so the true predictability is known and you control it.

  2. Train, then predict

    On each date the model trains only on months that had already finished, then ranks every stock for the coming month. It is retrained on the schedule you choose, so there is no peeking at the future.

  3. Trade

    Buy the stocks it likes most, short the ones it likes least, equal-weighted and dollar-neutral. Costs are charged on everything traded.

  4. Judge

    Sharpe ratio, drawdown and rank IC on unseen months. Compare in-sample skill with out-of-sample skill to spot overfitting.

Read this before drawing conclusions

  • The market is simulated, not real prices. It shows how methods behave when the truth is known, not whether a strategy would make money.
  • Real markets are noisier and their patterns decay, partly because people trade on them. The "Realistic" scenario is still generous.
  • A backtest with a high Sharpe ratio is easy to produce by trying many settings and keeping the best one. Try that here and watch the "Overfitting trap".
  • Nothing on this page is investment advice.

The models (ridge, lasso, gradient-boosted trees and a small neural network) are written from scratch in JavaScript. Source: assets/lab on GitHub.