LSTM Stock Forecasting: NSE Banking Anomaly & Risk Analysis
Learn how LSTM networks and Autoencoders are used for stock price prediction, anomaly detection, and Sharpe ratio risk analysis on NSE banking stocks.
Leveraging Long Short-Term Memory (LSTM) for Stock Prediction, Anomaly Detection, and Risk Analysis in the Indian Banking Sector
Stock Price Forecasting · Anomaly Detection · Risk Analysis
Prem Kumar N · Ronada Sakalesha · Rakesh MA · Rahul K
Dept. of Computer Science and Engineering, Dayananda Sagar University, Bengaluru, India
Agenda / Overview
Introduction & Motivation
Background, problem statement, and objectives
Literature Review
Existing forecasting models and their limitations
Methodology
LSTM architecture, data preprocessing, and model design
Results & Discussion
Model evaluation, predictions vs. actual data
Risk Analysis
Sharpe ratio evaluation and anomaly detection metrics
Conclusion & Future Work
Summary of findings and potential enhancements
Introduction & Motivation
Critical Component of NSE
Indian banking sector is a critical component of the National Stock Exchange (NSE).
Growth Demands Better Tools
Rapid growth of fintech and retail investor participation necessitates advanced forecasting tools.
Limitations of Traditional Models
Traditional models like ARIMA and GARCH fail to capture nonlinear dynamics and long-term temporal dependencies.
The Power of LSTM Networks
LSTM networks overcome the vanishing gradient problem and excel in forecasting complex financial time series.
Predict price movements, detect anomalies, and assess risk using LSTM.
Literature Review
Fischer & Krauss (2018)
LSTM outperforms classic models on S&P 500
Selvin et al. (2017)
Confirmed LSTM superiority using NSE data
Malhotra et al. (2016)
LSTM autoencoders detect anomalies via reconstruction error (unsupervised)
iₜ = σ(Wᵢ·hₜ₋₁ + Uᵢ·Xₜ + bᵢ)
fₜ = σ(Wf·hₜ₋₁ + Uf·Xₜ + bf)
oₜ = σ(Wo·hₜ₋₁ + Uo·Xₜ + bo)
cₜ = tanh(W·hₜ₋₁ + U·Xₜ + b)
W = recurrent weight
U = input-to-hidden weights
cₜ = candidate cell state
Methodology
Data Pipeline
NSE Data Collection
Preprocessing
LSTM Model
Anomaly Detection
Risk Metrics
OHLCV data: SBI, HDFC, ICICI | Jan 2021 – Mar 2026 | ~1,241 trading days
Preprocessing: forward-fill, MinMaxScaler [0,1] on training data only, 60-day sliding window
Train/Test split: 80:20 chronological (no look-ahead bias)
LSTM Architecture
3 stacked LSTM layers (128 → 64 → 32 units)
Dropout(0.2), Dense(1)
Adam optimizer (lr=0.001), MSE loss, early stopping patience=10
Anomaly Detection
LSTM Autoencoder, Encoder LSTM (64 units)
Trained on normal data only
Threshold = 95th percentile of reconstruction errors
Historical Price Trends (2021–2026)
Stock Price Prediction Results
Stock
MAE (INR)
MSE
MAPE (%)
Best MAPE of 1.86% — most predictable stock
Higher error due to unprecedented Aug 2025 structural break
Good accuracy but lagged in Jan-Feb 2026 parabolic surge (predicted INR 1050 vs actual INR 1220)
All three models are commercially viable in terms of predictive accuracy
Anomaly Detection Results
SBI Anomalies
Clustered in early-2026 parabolic surge
INR 1000–1200
Reflects unusual upward acceleration
HDFC Anomalies
Detected during post-crash consolidation
INR 950–1000
Following sharp -50% correction in August 2025
Most impactful anomalous event: structural break Aug 2025
ICICI Anomalies
Mid-2025 reversal zone
INR 1440–1460
Moderate anomaly cluster
Zero false positives detected during normal trading period 2021–2024
95th percentile of reconstruction error distribution
Risk Analysis Summary
Bank
Ann. Return
Ann. Volatility
Sharpe Ratio
SBI
18.5%
23.2%
0.80 ★
HDFC
14.2%
22.8%
0.34
ICICI
15.8%
21.1% ★
0.44
Growth Seekers: SBI
Best risk-adjusted returns, Sharpe Ratio 0.80
Risk-Averse Investors: ICICI
Lowest volatility 21.1%, stable growth
Caution: HDFC
Post-correction consolidation, Sharpe 0.34
SBI + ICICI Diversification = Optimal Portfolio (correlation 0.94, complementary risk exposures)
Risk-free rate used: 6.5% | 252 trading days per annum
Conclusion
Multi-layer LSTM is commercially viable
— ICICI MAPE of 1.86% proves accuracy
LSTM Autoencoder captures real market events
(HDFC Aug 2025 crash, SBI Jan 2026 surge)
SBI = Best risk-adjusted asset
(Sharpe Ratio 0.80)
ICICI = Most stable investment
(lowest volatility 21.1%)
SBI + ICICI diversification
offers optimal growth-stability tradeoff
Future Work
Integrate Transformer architectures
Expand to full NIFTY Bank Index (12 stocks)
Add NLP-based news sentiment analysis
Implement live NSE data feed system
Thank You
This research was conducted at the Dept. of Computer Science and Engineering, Dayananda Sagar University, Bengaluru, India
Prem Kumar N · Ronada Sakalesha · Rakesh MA · Rahul K
prem.kumar@dsu.edu.in | ronada.s@dsu.edu.in | rakesh.ma@dsu.edu.in | rahul.k@dsu.edu.in
Hochreiter & Schmidhuber (1997)
LSTM, Neural Computation
Fischer & Krauss (2018)
Deep learning for financial predictions, EJOR
Selvin et al. (2017)
Stock prediction LSTM/RNN/CNN, IEEE ICACCI
Malhotra et al. (2016)
LSTM encoder-decoder anomaly detection, ICML
Sharpe (1966)
Mutual fund performance, Journal of Business
Abadi et al.
TensorFlow, USENIX OSDI
- stock-forecasting
- lstm
- nse-india
- deep-learning
- anomaly-detection
- fintech
- risk-analysis
- banking-sector