Skip to content

Raj1984/india_sector_analysis

Repository files navigation

India Sector Master Analysis

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.

What it does

  • 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.html file that opens automatically in your browser. No server required.
  • CSV exports — regime stats and stock signals saved as india_sector_analysis_stats.csv and india_sector_analysis_stocks.csv.

Sectors & Stocks Covered

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

Setup

pip install -r requirements.txt

Usage

python -X utf8 india_master.py

The report (india_sector_analysis.html) opens automatically when the script finishes. Run time is roughly 30–60 seconds depending on your internet connection.

Output Files

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)

Requirements

  • Python 3.9+
  • Internet connection (live data fetched via yfinance)

About

Macroeconomic regime-based sector rotation model for Indian equities using NSE stocks, economic cycle mapping (2000–2026), and multi-factor analysis across 9 sectors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors