Can deep learning predict short-term stock index returns?
This project investigates one of the most common assumptions in quantitative finance:
Can a deep learning model outperform a simple statistical baseline when forecasting the next 25-minute return of the NIFTY 50 Index?
To answer this question, four forecasting models were evaluated using a strict chronological train-validation-test split:
- Naive Baseline
- Hidden Markov Model (HMM)
- Long Short-Term Memory Network (LSTM)
- Hybrid HMM + LSTM
Rather than optimizing until a positive result appeared, the goal was to objectively evaluate whether increasingly sophisticated models genuinely improved forecasting performance.
- NIFTY 50 Index
- Two years of historical 1-minute OHLCV data
- Resampled to 5-minute candles
- Approximately 37,000 observations after feature engineering
The forecasting models were trained using technical and volatility-based features including:
- Log Returns
- Rolling Volatility (5, 10 and 20 bars)
- ATR Ratio
- EMA Distance (10,20,50)
- EMA Spread
- RSI(14)
For the HMM, only market-state variables were used:
- Log Return
- Volatility
- ATR Ratio
1-Minute Data │ ▼ 5-Minute Resampling │ ▼ Feature Engineering │ ▼ Predict 25-Minute Return │ ▼ ──────────────────────────────── Naive Baseline │ LSTM │ Gaussian HMM │ Hybrid HMM + LSTM ──────────────────────────────── │ ▼ Out-of-Sample Evaluation
Assumes the next return is approximately equal to the current return.
This provides the minimum benchmark every forecasting model should outperform.
2. Gaussian Hidden Markov Model
Learns latent market regimes directly from market behaviour using:
- Returns
- Volatility
- ATR
Instead of predicting returns directly, the HMM predicts hidden market states.
For forecasting, each hidden state predicts the average future return historically observed in that regime.
A recurrent neural network trained using:
- 10-candle lookback window
- 32 hidden units
- Dropout Regularization
- Adam Optimizer
- Early Stopping
The hidden market regime discovered by the HMM is one-hot encoded and appended to the LSTM feature vector.
This tests whether latent market-state information improves neural network forecasting.
Each model was evaluated using:
- Mean Absolute Error (MAE)
- Root Mean Squared Error (RMSE)
- R² Score
- Directional Accuracy
- Sharpe Ratio
- Maximum Drawdown
- Final Equity Curve
A simple long-short signal strategy with transaction costs was also simulated to evaluate economic usefulness.
The experiment produced an unexpected result.
While the Hybrid HMM + LSTM consistently improved upon the standalone LSTM, none of the machine learning models outperformed the naive baseline out-of-sample.
This highlights an important lesson in quantitative finance:
Increasing model complexity does not necessarily improve predictive performance.
- Chronological validation is essential for financial machine learning.
- Naive benchmarks are surprisingly difficult to beat.
- HMM-derived market regimes improved neural network performance but not enough to outperform a simple baseline.
- Short-horizon return prediction remains an extremely challenging problem.
Forecasting-Short-Term-NIFTY-Returns/
│ ├── data/ │ ├── results/ │ ├── model_comparison.csv │ ├── feature_correlation.png │ ├── hmm_regimes.png │ ├── residuals_grid.png │ ├── training_curves.png │ ├── predicted_vs_actual_grid.png │ ├── model_performance_summary.png │ └── comparison_equity_curves.png │ ├── main.py │ ├── requirements.txt │ └── README.md
This project intentionally concludes with a negative result.
Rather than continuing to optimize return prediction, future work focuses on:
- Market regime classification
- Probabilistic forecasting
- Multi-horizon market state prediction
- Regime-aware decision support systems
Those ideas are implemented in the follow-up project:
NIFTY Market State Engine
- Python
- TensorFlow / Keras
- hmmlearn
- NumPy
- Pandas
- Scikit-learn
- Matplotlib
- Seaborn
Anand Rai
Quantitative Finance • Machine Learning • Systematic Trading
If you found this project useful, consider starring the repository.