A single-script Python tool that pulls live NSE data and generates a self-contained interactive HTML report covering India's nine major equity sectors — Auto, Banking, Energy, FMCG, Infra, IT, Metal, Pharma, and Realty.
- Regime analysis — maps 10 years of quarterly sector returns against four economic regimes (Expansion, Recession, Reflation, Stagflation) and the RBI rate cycle (Hiking / Cutting / Neutral) to show which sectors historically outperform in each environment.
- Z-score heatmaps — visualises average return and Sharpe Z-scores across regimes so you can spot relative strength at a glance.
- Stock signals — computes swing and positional trade signals (RSI, MACD, EMA 20/50/200, 52-week range, momentum) for 45 representative NSE stocks across all 9 sectors.
- Interactive HTML report — six Plotly charts assembled into a single
india_sector_analysis.htmlfile that opens automatically in your browser. No server required. - CSV exports — regime stats and stock signals saved as
india_sector_analysis_stats.csvandindia_sector_analysis_stocks.csv.
| Sector | Index Symbol | Representative Stocks |
|---|---|---|
| Auto | ^CNXAUTO | MARUTI, TMCV, BAJAJ-AUTO, M&M, EICHERMOT |
| Banking | ^NSEBANK | HDFCBANK, ICICIBANK, SBIN, KOTAKBANK, AXISBANK |
| Energy | ^CNXENERGY | RELIANCE, NTPC, POWERGRID, ONGC, COALINDIA |
| FMCG | ^CNXFMCG | HINDUNILVR, ITC, NESTLEIND, BRITANNIA, DABUR |
| Infra | ^CNXINFRA | LT, ADANIPORTS, ULTRACEMCO, BHARTIARTL, IRFC |
| IT | ^CNXIT | TCS, INFY, HCLTECH, WIPRO, TECHM |
| Metal | ^CNXMETAL | TATASTEEL, JSWSTEEL, HINDALCO, COALINDIA, NMDC |
| Pharma | ^CNXPHARMA | SUNPHARMA, DRREDDY, CIPLA, DIVISLAB, TORNTPHARM |
| Realty | ^CNXREALTY | DLF, GODREJPROP, LODHA, OBEROIRLTY, PRESTIGE |
pip install -r requirements.txtpython -X utf8 india_master.pyThe report (india_sector_analysis.html) opens automatically when the script finishes. Run time is roughly 30–60 seconds depending on your internet connection.
| File | Description |
|---|---|
india_sector_analysis.html |
Full interactive dashboard (open in any browser) |
india_sector_analysis_stats.csv |
Regime-level stats per sector (avg return, win rate, Sharpe) |
india_sector_analysis_stocks.csv |
Per-stock signal table (swing & position bias) |
- Python 3.9+
- Internet connection (live data fetched via
yfinance)