Getbhavcopy Guide: Step-by-Step Bhavcopy Download & InterpretationA bhavcopy is a daily snapshot of the trading activity on Indian stock exchanges. It contains records of every trade and instrument for the trading day — prices, volumes, open/close, delivery details, and more. Getbhavcopy is a popular tool/utility (and sometimes a website or script) people use to fetch these bhavcopy files conveniently. This guide explains how to obtain bhavcopies using common Getbhavcopy methods, how to read and interpret the key fields, and practical ways traders, analysts, and developers can use the data.
Who needs bhavcopies and why
- Traders: for backtesting strategies, calculating indicators from raw daily data, and verifying fills.
- Quantitative analysts: as historical input for models and research.
- Portfolio managers: to check historical performance and corporate-action-adjusted returns.
- Developers/automation engineers: to build pipelines that ingest daily market snapshots for apps, bots, or analytics.
Part 1 — Where bhavcopies come from
Bhavcopies are published by the major Indian exchanges:
- NSE (National Stock Exchange): provides bhavcopies for equity, derivatives, and other segments.
- BSE (Bombay Stock Exchange): publishes daily CSV-style reports for listed securities.
Bhavcopies are typically available on exchange websites as zipped CSV/TXT files and sometimes mirrored by third-party services or open-source scripts (often named Getbhavcopy) that automate download and extraction.
Part 2 — Common Getbhavcopy methods
Below are typical ways people retrieve bhavcopies.
-
Official exchange sites (manual)
- Visit NSE/BSE bhavcopy sections.
- Select date and segment; download ZIP/CSV.
- Pros: authoritative, immediate. Cons: manual, repetitive.
-
Getbhavcopy scripts/tools (automated)
- Python/R scripts or command-line utilities that fetch, unzip, and store bhavcopy files.
- They may call official exchange URLs, handle date ranges, and rename files consistently.
- Example features: scheduled downloads, incremental updates, multi-segment support.
-
Third-party mirrors/APIs
- Some websites provide historical bhavcopies via APIs or bulk downloads.
- Useful when you need many years of history quickly, but check licensing and reliability.
Part 3 — Step-by-step: Download bhavcopy using a typical Python Getbhavcopy script
Below is a concise, practical outline of how an automated script works and what steps it follows.
-
Identify exchange URL pattern
- Exchanges use predictable paths for daily files (for example, NSE often uses date-formatted endpoints).
-
Build the date loop
- Iterate over the required date range; skip weekends/holidays if desired.
-
Download and handle HTTP responses
- Request the file URL; check for 200 OK.
- If the file is zipped, save and unzip.
-
Parse and store
- Read CSV/TXT into pandas (or similar), standardize column names, store to local DB or parquet files.
-
Scheduling
- Use cron, Windows Task Scheduler, or a cloud function to run daily after market close.
Example Python snippet (conceptual; adjust for actual exchange URLs and licensing):
import requests, zipfile, io, pandas as pd from datetime import datetime, timedelta def download_nse_bhavcopy(date): url = f"https://www.nseindia.com/content/historical/EQUITIES/{date.year}/{date.strftime('%b').upper()}/cm{date.strftime('%d%b%Y').upper()}bhav.csv.zip" r = requests.get(url, headers={'User-Agent':'Mozilla/5.0'}) if r.status_code == 200: z = zipfile.ZipFile(io.BytesIO(r.content)) df = pd.read_csv(z.open(z.namelist()[0])) return df return None # example use d = datetime(2025, 8, 29) df = download_nse_bhavcopy(d) print(df.head())
Part 4 — Key fields in a bhavcopy and what they mean
Bhavcopy columns vary by exchange and segment; common fields include:
- SYMBOL: ticker symbol of the security.
- SERIES: share series/type (e.g., EQ, BE).
- OPEN / HIGH / LOW / CLOSE: daily OHLC prices.
- LAST: last traded price.
- PREVCLOSE: previous trading day’s close.
- TOTTRDQTY / TOTTRDVAL: total traded quantity and value.
- DELIV_QTY / DELIV_PER (if present): delivery quantity and delivery percentage — useful for understanding participation and holding patterns.
- ISIN: unique security identifier (important for mapping across data sources).
Part 5 — Interpreting bhavcopy data: practical tips
- Use PREVCLOSE to compute daily returns: return = (CLOSE / PREVCLOSE) – 1.
- Check TOTTRDQTY to identify liquidity — low volumes can distort indicators.
- DELIV_PER gives an idea of actual settlement vs intraday trading; high delivery percentage often indicates genuine investor interest.
- Compare LAST vs CLOSE for intraday behavior (if both present).
- Cross-check ISIN when merging datasets from multiple providers.
LaTeX example for daily return calculation: [
ext{Daily Return} = rac{ ext{CLOSE} - ext{PREVCLOSE}}{ ext{PREVCLOSE}}
]
Part 6 — Use cases and examples
- Backtesting: combine bhavcopies over years to compute historic signals (moving averages, RSI).
- Corporate actions: adjust prices for bonuses, splits using corporate-action files together with bhavcopy ISIN mapping.
- Liquidity screens: filter by TOTTRDQTY and TOTTRDVAL to select tradable instruments.
- Market microstructure research: use delivery data to study investor behavior.
Example filter in pandas:
liquid = df[(df['TOTTRDQTY'] > 100000) & (df['TOTTRDVAL'] > 1e7)]
Part 7 — Common pitfalls and how to avoid them
- Missing days due to exchange holidays — maintain a holiday calendar.
- Column name/format changes across years — normalize columns in your pipeline.
- Rate-limiting or blocking by exchanges — add polite headers, respect robots.txt, and rate limits.
- Unzipping and encoding issues — detect file encoding and handle different delimiters.
Part 8 — Storage, indexing, and performance
- For many years of bhavcopies, use columnar storage (Parquet) for fast reads and compression.
- Partition by year/month for efficient queries.
- Index by SYMBOL + DATE or use a database (Postgres, ClickHouse) for complex joins.
Part 9 — Legal and ethical considerations
- Confirm licensing/terms of use for exchange data and any third-party mirrors.
- For redistribution or commercial use, ensure you have the right to reshare exchange data.
- Attribute data sources per exchange policies when required.
Conclusion
Bhavcopies are a fundamental building block for Indian market analysis. Using a Getbhavcopy approach — whether a script, scheduled job, or third-party API — you can automate daily collection, parse essential fields, and feed them into trading systems, backtests, or analytics. Focus on consistent ingestion, normalization, and appropriate storage; watch for exchange format changes and legal constraints.
Leave a Reply