A deep learning LSTM architecture trained on 10 years of TCS historical data, using a 60-day sliding window to forecast next-day stock price trends.
Stock price prediction is one of the canonical time-series problems in applied deep learning. Most beginner implementations reach for simple linear regression on a few recent candles — which captures noise, not signal. Prices are shaped by trends that unfold over weeks, not just the last few bars.
The challenge was building a model that genuinely captures long-range temporal dependencies in price movements. LSTM networks were designed for exactly this — they maintain a cell state that can carry relevant information forward across many timesteps, making them theoretically well-suited for multi-week price pattern learning on a single stock.
10 years of TCS daily OHLCV data was fetched via Yahoo Finance, MinMax scaled per feature, then converted into 60-day sliding window sequences. Each sequence maps to a single next-day closing price. The LSTM stack uses three layers with dropout regularisation between each to prevent overfitting on the relatively small dataset.
Training used Adam optimiser with early stopping — patience of 10 epochs monitoring validation loss. This prevented the model from overfitting past the natural convergence point around epoch 130–150 on typical runs.
Raw price values in the thousands caused gradient instability during early training runs. Applying MinMaxScaler per feature to the [0, 1] range before sequence construction stabilised convergence immediately.
There's no theoretical answer to "how many days." Too short (15 days) failed to capture weekly seasonality. Too long (120 days) introduced pre-earnings noise that hurt validation loss. 60 days was the empirical sweet spot for TCS specifically.
Without dropout, the model memorised the training curve and generalised poorly. Without early stopping, it continued "learning" noise after epoch 140. Both together are the minimum viable regularisation for finance LSTM work.
Low MSE doesn't mean the model is useful for trading. Direction accuracy — predicting up vs. down — matters far more than minimising the squared price error. I'd add a direction accuracy metric to every evaluation run in future work.
The full training notebook, data pipeline, and evaluation plots are on GitHub. Great starting point for any time-series deep learning project.