What the project actually is
This is a personal project built out of genuine curiosity about what machine learning can and can't do with financial data. The tool takes a stock ticker - say, Apple or Nvidia - pulls years of historical price data from Yahoo Finance, trains an LSTM neural network on it, and then generates a prediction for the next N days.
The full stack is Python and PyTorch. The model is a multi-layer LSTM with dropout regularisation to reduce overfitting. Training data is normalised, split into sequences, and fed through the network in batches. The output is a predicted closing price for each future day in the window.
What is an LSTM and why use it for stocks?
LSTM stands for Long Short-Term Memory - a type of recurrent neural network designed to learn patterns across long sequences of data. Standard neural networks treat each input independently. An LSTM has a "memory" - it carries information forward through time, so what happened 20 or 30 days ago can still influence what the model outputs today.
Stock prices are time-series data. The price today is not independent of the price yesterday - or last week, or last month. A moving average, a momentum pattern, a seasonal trend - these are all temporal relationships. That's exactly what LSTMs are built to capture, which is why they're one of the most commonly used architectures for this kind of problem.
What the model gets right
Under stable market conditions, the model is genuinely good at capturing trend direction. If a stock has been trending upward with consistent momentum, the LSTM will typically predict continued upward movement with reasonable accuracy over a short window - 5 to 15 days. It learns the shape of a price series: the rhythm of minor corrections within a larger trend, the typical volatility envelope for a given stock.
Tested across historical data with a proper train/test split, the model produces predictions that track actual prices closely enough to be interesting - not close enough to bet your savings on, but well above random chance. The visual outputs make this clear: the predicted line tends to follow the actual line in the right direction even when it doesn't nail the exact magnitude.
What it can't do - and why that matters
AI cannot predict sudden market events. An earnings miss, a Federal Reserve announcement, a war, a tweet from a CEO - none of these are visible in historical price data, and no LSTM can anticipate them. These are the events that move markets most violently, and they are by definition outside any model trained on past price sequences.
The model is also vulnerable to regime changes - periods when the market behaves fundamentally differently than the historical data it trained on. A model trained on 2018-2022 data did not know what March 2020 looked like until it happened. No amount of historical pattern recognition prepares a model for a category of event it has never seen.
The honest framing is this: the model is a sophisticated extrapolation tool, not a prediction engine. It asks "if the patterns of the past continue into the near future, what does that imply?" That's a useful question - but one with significant limitations that any serious use of the tool should account for.
Why I built it
Less about trading, more about the problem itself. Time-series prediction with neural networks is one of the genuinely interesting corners of machine learning - the feedback between past and present, the challenge of sequence modelling, the question of what "learning" even means when the data-generating process is partially non-stationary. Building a working model end-to-end - data pipeline, training loop, validation, visualisation - is a much richer learning experience than following a tutorial.
The tool also raises questions worth sitting with: if a model can predict stock prices better than chance, does that mean markets are inefficient? And if everyone uses the same models, does that inefficiency disappear? These aren't questions this project answers - but it sharpens the intuition needed to think about them seriously.