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)

  1. vix_level
  2. month
  3. vix_5d_change
  4. atr_norm
  5. dist_52w_low
  6. adx
  7. beta_60
  8. dist_52w_high
  9. macd_hist
  10. rolling_vol_20
  11. rolling_vol_10
  12. nifty_log_return
  13. macd_signal
  14. stoch_d
  15. rsi_28
  16. rolling_vol_5
  17. cci_20
  18. bb_bandwidth
  19. obv_norm
  20. bb_pctb
  21. rolling_mean_ret_10
  22. rolling_mean_ret_20
  23. is_expiry_week
  24. rolling_mean_ret_5
  25. 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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support