Can ML Predict Stock Prices?

We'll train a real LSTM neural network in your browser on 5 years of data. Watch it learn — then see why it fails.

Runs left: 3 of 3 free  |  Enter email for unlimited
Enter a ticker and press TRAIN MODEL
Step 1 · Training
Training LSTM on -
Architecture
LSTM(32)
+ Dense(1)
Epoch
0/30
training...
Loss (MSE)
-
mean squared error
Val Loss
-
validation
Training Loss
live
Step 2 · Results
The model looks incredible — or does it?
R² In-Sample
-
looks perfect
R² Out-of-Sample
-
still looks good...
Direction Accuracy
-
up or down — right?
Data Points
-
5 years daily
Full period — Actual vs Predicted
-
Zoom: 30 days out-of-sample
← the 1-day shift
The R² is a trap

R² looks great because stock prices are autocorrelated — today's price is always close to yesterday's. The model learned to copy yesterday's price, not predict the future. The proof: direction accuracy is ~50% — no better than a coin flip. It can't tell you if tomorrow is up or down.

Step 3 · What quants actually do
Don't predict price. Trade a signal.
Mean reversion

When a stock drops far below its recent average (measured in standard deviations), the probability of a bounce is higher than random. Buy at -2σ, sell when it reverts to the mean. Repeat hundreds of times. Let the law of large numbers work.

20
2.0
Total Trades
-
Win Rate
-
Avg Edge/Trade
-
E[PnL]
-
-
Price with Buy / Sell Signals
-
Cumulative PnL
-
Expected PnL
E[PnL] = N × edge × avg_bet

Not one big prediction — just a small edge, repeated.

Past ≠ future

These are backtested results on historical data. Transaction costs, slippage, and regime changes can erode the edge in live trading. This is educational, not financial advice.