API Reference¶
- class bsedata.bse.BSE(update_codes=False)¶
Class which implements the functionality for Bombay Stock Exchange (BSE)
- getBhavCopyData(statsDate: date)¶
Get historical OHLCV data from Bhav Copy released by BSE everyday after market closing. The columns available in the data and their description is as given below.
Dictionary Field
Description
scripCode
Unique code assigned to a scrip of a company by BSE
open
The price at which the security first trades on a given trading day
high
The highest intra-day price of a stock
low
The lowest intra-day price of a stock
close
The final price at which a security is traded on a given trading day
last
The last trade price of the stock
prevClose
The closing price of the stock for the previous trading day
totalTrades
The total number of trades of a scrip
totalSharesTraded
The total number of shares transacted of a scrip
netTurnover
Total turnover of a scrip
scripType
Scrip category: Equity, Preference, Debenture or Bond
securityID
Name of the company
The Bhav Copy files have been mapped to the above mentioned custom fields. The complete documentation for Bhav Copy can be found here: https://www.bseindia.com/markets/MarketInfo/BhavCopy.aspx.
- Parameters:
statsDate – A datetime.date object for the for which you want to fetch the data
- Returns:
A list of dictionaries which contains OHLCV data for that day for all scrip codes active on that day
- Raises:
BhavCopyNotFound – Raised when Bhav Copy file is not found on BSE
- getIndices(category)¶
- Parameters:
category – A category of indices
- Returns:
A dictionary with details about the indices belonging to the given category
- getQuote(scripCode)¶
- Parameters:
scripCode – A stock code
- Returns:
A dictionary which contain details about the stock
- Raises:
InvalidStockException – Raised for stocks which have been suspended or no longer trading on BSE
- getScripCodes()¶
- Returns:
A dictionary with scrip codes as keys and company names as values
- topGainers()¶
- Returns:
A sorted list of codes of top gainers
- topLosers()¶
- Returns:
A sorted list of codes of top losers
- updateScripCodes()¶
Download a fresh copy of the scrip code listing
- Returns:
None
- verifyScripCode(code)¶
- Returns:
Company name if it is a valid stock code, else None
- exception bsedata.exceptions.InvalidStockException(status: str = 'Inactive stock')¶
Exception raised for stocks which have been suspended or no longer trading on BSE.
- Parameters:
status – the status of the stock as mentioned on BSE website
- exception bsedata.exceptions.BhavCopyNotFound¶
Exception raised when the BhavCopy file is not found on BSE website.