library to get BSE India data
Project description
bseindia 1.0.0
A Python library for fetching publicly available market data from the BSE India website and API endpoints. It wraps the CSV/JSON/HTML feeds that power bseindia.com and returns clean pandas DataFrames (or Python dicts) ready for analysis.
Tested on Python 3.9+. Data is scraped from public BSE endpoints — be mindful of request rates.
Installation
Fresh install:
pip install bseindia
Upgrade:
pip install bseindia --upgrade
Dependencies
Installed automatically via pip:
requestspandas(>= 2.0.0)numpybeautifulsoup4lxmlxlrd
Quick start
import bseindia
# Trading holiday calendar for the equity segment
holidays = bseindia.trading_holiday_calendar()
# Full BSE equity security master (cached locally to bse_security_list.csv)
securities = bseindia.all_listed_securities()
# Historical price/volume for a stock
from bseindia import equity
hist = equity.historical_stock_data(symbol="SBIN", period="1M")
# Today's bulk deals
deals = equity.bulk_deal_as_on_today()
# Derivatives bhavcopy for a given trade date
from bseindia import derivatives
fo_bhav = derivatives.derivative_bhav_copy(trade_date="01-07-2024")
Dates are always dd-mm-YYYY strings (e.g. "10-06-2024").
API reference
Top level — bseindia
| Function | Purpose |
|---|---|
trading_holiday_calendar(year=None) |
BSE equity-segment holiday list. Optional year filter. |
all_listed_securities(refresh=False) |
Equity security master (security_code, symbol, isin_no, group, …). Cached locally; pass refresh=True to re-download. |
Equity — bseindia.equity
| Function | Purpose |
|---|---|
historical_stock_data(symbol, from_date=None, to_date=None, period=None) |
Historical OHLCV for a symbol. Supply either from_date/to_date or period (1D, 1W, 1M, 3M, 6M, 1Y). |
stock_info(symbol) |
Quote-header dict for a symbol (face value, group, market cap, 52w high/low, …). |
equity_bhav_copy(trade_date) |
CM-UDiFF bhavcopy for the given trade date, as a DataFrame. |
equity_turnover() |
Year-wise equity turnover key statistics. |
equity_segment_history() |
Yearly equity-segment history (listed companies, trades, turnover) from 1997‑98 onwards. |
category_wise_turnover(period='monthly', month='01', year='2026', from_date=..., to_date=...) |
Category-wise turnover. period can be 'monthly', 'yearly', or range-based (provide from_date/to_date). |
market_cap() |
Yearly market-capitalisation key statistics. |
market_capitalisation() |
Current market cap by instrument type (Equity, REIT/INVIT, ETF, MF, Corporate Bonds, CP). Values in ₹ Crores. |
top_market_cap() |
Top 100 companies by market capitalisation. |
gross_delivery(trade_date) |
Gross delivery report for the given date (scrip-wise delivery qty, value, turnover, %). |
bulk_deal_as_on_today() |
Today's bulk deals. |
block_deal_as_on_today() |
Today's block deals. |
Derivatives — bseindia.derivatives
| Function | Purpose |
|---|---|
market_summary() |
F&O market summary. Returns a tuple (index_df, equity_df). |
derivative_bhav_copy(trade_date) |
Derivatives UDiFF bhavcopy for the given trade date. |
Examples
Holidays for a specific year
bseindia.trading_holiday_calendar(year=2026)
Historical data by date range
from bseindia import equity
equity.historical_stock_data(
symbol="SBIN",
from_date="01-06-2023",
to_date="10-06-2023",
)
Historical data by period
equity.historical_stock_data(symbol="TCS", period="6M")
Bhavcopy
equity.equity_bhav_copy(trade_date="01-07-2024")
Derivatives market summary
from bseindia import derivatives
index_df, equity_df = derivatives.market_summary()
Look up a scrip code
all_listed_securities() returns the full master. Pass refresh=True to bypass the local cache and re-fetch from BSE.
bseindia.all_listed_securities(refresh=True)
Notes & gotchas
- BSE endpoints sometimes rate-limit or time out; functions raise
NSEdataNotFoundorCalenderNotFoundin those cases. Retry after a short pause. historical_stock_dataresolves a symbol to a BSE scrip code via the cached security master, with a live smart-search fallback if the symbol is missing. Numeric inputs (e.g."500325") are treated as scrip codes directly.- The security master is cached at
bseindia/bse_security_list.csvinside the installed package directory. - All date inputs use the
dd-mm-YYYYformat unless otherwise noted.
Contributing
Issues and pull requests are welcome on the GitHub repo.
- Bug reports / feature requests — open an issue at https://github.com/RuchiTanmay/bseindia/issues.
- Patches — fork, branch, commit, open a PR against
main. - Docs & examples — blog posts, notebooks and Q&A help the community; please share links in issues so they can be referenced.
Changelog
See CHANGE_LOG.md for release history.
License
Distributed under the terms of the LICENSE bundled with this repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bseindia-1.1.tar.gz.
File metadata
- Download URL: bseindia-1.1.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63fb1a55d1e9ba71d9de5645e92ee7689ab56b108c7c0ae15b266f062a11021f
|
|
| MD5 |
256838031cc512260853924ef7c0ca01
|
|
| BLAKE2b-256 |
ae6771afe3ef42b82b33eb9f7aff65325fa7052100aebf740169249fee560ba2
|
File details
Details for the file bseindia-1.1-py3-none-any.whl.
File metadata
- Download URL: bseindia-1.1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d2c834aaec5fb908131a396731247f9b1eca59b35af9daf89d4176c1960ef63
|
|
| MD5 |
7db973e2b5f354e10a81fe414f969b89
|
|
| BLAKE2b-256 |
fb6bd3e489249b019fa87e42fa254bdb73de30dd3b855bca2f0dc0d7c7ec5dad
|