NSE Swing Trading LightGBM Classification Model
Overview
A production-ready LightGBM multiclass classification model for Indian NSE stock swing trading with 5-day forward Buy/Sell/Hold signals.
Model Details
- Task: Multiclass classification (3 classes)
- Classes: SELL (0), HOLD (1), BUY (2)
- Boosting Type: GBDT
- Features: 25 selected from 40 engineered features
- Validation: TimeSeriesSplit (5 splits, gap=5)
- Class Balancing: compute_sample_weight('balanced')
Training Data
- Period: 5 years (2021-05-07 to 2026-05-07)
- Tickers: RELIANCE.NS, TCS.NS, INFY.NS, HDFCBANK.NS, ICICIBANK.NS, WIPRO.NS, AXISBANK.NS, SBIN.NS
- Macro Data: ^NSEI (Nifty 50), ^INDIAVIX (India VIX)
- Total Samples: 7,768 (after preprocessing)
- Train/Test Split: 80/20 chronological holdout
Features
Technical Indicators
- RSI (14, 28), MACD, Bollinger Bands, ATR, Stochastic, ADX, OBV, CCI, Williams %R, VWAP deviation
Lag & Return Features
- Log returns (lags 1,2,3,5,10), Rolling mean/volatility (5,10,20)
- High-Low range normalized, Close position within day range
India-Specific Features
- Nifty50 log return, India VIX level & 5-day change
- Rolling 60-day beta vs Nifty50
- Distance from 52-week high/low
Calendar Features (Categorical)
- day_of_week, month, is_expiry_week, is_monday, quarter
- Market regime (bull/bear based on 200-day SMA)
Performance
Raw Model (Top-25 features, GBDT)
- Accuracy: 0.378
- Macro F1: 0.370
Per-Class Metrics
| Class | Precision | Recall | F1 |
|---|---|---|---|
| SELL | 0.329 | 0.352 | 0.340 |
| HOLD | 0.496 | 0.441 | 0.467 |
| BUY | 0.292 | 0.315 | 0.303 |
Boosting Comparison
- GBDT: F1 = 0.368 (test)
- DART: F1 = 0.356 (test)
- Winner: GBDT
Regime Separation
- Single model with regime feature: F1 = 0.370
- Separate bull/bear models: F1 = 0.265
- Winner: Single model with regime feature
Selected Top-25 Features (by gain)
- vix_level
- month
- vix_5d_change
- atr_norm
- dist_52w_low
- adx
- beta_60
- dist_52w_high
- macd_hist
- rolling_vol_20
- rolling_vol_10
- nifty_log_return
- macd_signal
- stoch_d
- rsi_28
- rolling_vol_5
- cci_20
- bb_bandwidth
- obv_norm
- bb_pctb
- rolling_mean_ret_10
- rolling_mean_ret_20
- is_expiry_week
- rolling_mean_ret_5
- rsi_14
India-Specific Features in Top-10 SHAP
- vix_level, vix_5d_change, beta_60, dist_52w_high, dist_52w_low
Artifacts
| File | Description |
|---|---|
| Best single model (top-25 features) | |
| Bull regime model | |
| Bear regime model | |
| Top-25 feature list | |
| Full test predictions with probabilities | |
| Complete evaluation metrics | |
| Confusion matrix | |
| Feature importance (gain) | |
| Feature importance (split) | |
| SHAP summary plot |
Usage
License
MIT - For educational and research purposes only. Not financial advice.
Generated by ML Intern
This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support