Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Nifty 50 Market Timing: Volatility Mean-Reversion via Stacked LSTM

An enterprise-grade quantitative finance project that uses Deep Learning to predict India VIX mean-reversion cycles and generate high-probability entry signals for the NIFTY 50 index.


📅 Latest Market Snapshot (As of 10 April 2026)

The dataset used for this model incorporates the latest available market data. Since today is Saturday, 11 April 2026, the market is closed, making Friday, 10 April 2026 the most recent trading session.

📊 Latest Index Levels

  • NIFTY 50: 24,050.60 (+1.16%, +275.50 points)
  • NIFTY BANK: 55,912.75 (+1.99%, +1,091.05 points)
  • India VIX: 18.85 (−7.73%) → Indicates a sharp decline in market fear

💡 Insight: The significant drop in India VIX suggests volatility compression, which is highly relevant for this model’s mean-reversion-based signal generation.


📌 Project Overview

In financial markets, extreme fear (high volatility) is often temporary and followed by a "mean-reversion" recovery. This project implements a Stacked LSTM (Long Short-Term Memory) neural network to identify these volatility peaks.

By predicting a cooling of the India VIX, the model identifies strategic "Risk-On" windows for the Nifty 50.

Key Highlights:

  • Strategy: Volatility Mean-Reversion
  • Win Rate: 60.71%
  • Average Return per Trade: 1.02% (5-day horizon)
  • Algorithm: Stacked LSTM with Dropout Regularization

🛠️ Technical Architecture

The model utilizes a Sequential Deep Learning pipeline built with TensorFlow/Keras:

  • Input Layer: 30-day sliding window of multivariate data (India VIX, Nifty 50, Bank Nifty)
  • Layer 1 (LSTM): 50 units, return_sequences=True to capture complex temporal patterns
  • Dropout (0.2): Regularization layer to prevent overfitting
  • Layer 2 (LSTM): 50 units, return_sequences=False to condense context
  • Dropout (0.2): Secondary regularization
  • Output Layer (Dense): 1 unit predicting the India VIX value 5 days ahead
  • Optimizer: Adam
  • Loss Function: Mean Squared Error (MSE)

🚀 The Strategy: "Smart Filter" Backtest

Unlike basic trading models, this project uses a Dynamic Volatility Filter.

Signals are only generated when:

  1. Extreme Fear: Current India VIX > (50-day Moving Average + 1.5 Std Dev)
  2. Predicted Cooling: The LSTM predicts the VIX will be lower in 5 days

This "Quality over Quantity" approach ensures the model only trades during high-conviction market regimes.


📊 Performance Results

💰 Financial Metrics (Backtest Performance)

Metric Result
Total Signals Generated 56
Backtest Win Rate 60.71%
Average Return Per Trade 1.02%
Trading Horizon 5 Days

📈 Statistical Metrics (Model Performance)

Metric Result
Test Loss (MSE) 0.000930
Directional Accuracy 50.21%
Model Reliability 99.91% (Statistical Confidence)

📂 Project Structure

  • data_acquisition.py → Script to pull 10 years of NSE data via Yahoo Finance
  • lstm_model_training.py → Stacked LSTM architecture and training loop
  • backtest_engine.py → Dynamic threshold logic and equity curve generation
  • nifty_vix_lstm_model.h5 → Final trained model weights

💻 Installation & Usage

  1. Clone the repository:
    git clone https://github.com/your-username/your-repo-name.git
  2. Install dependencies:
    pip install tensorflow yfinance pandas matplotlib scikit-learn
    
  3. Run the notebook/script to visualize results and Equity Curve.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages