Python SDK
Scrip master
Load the daily instrument file and look instruments up by id, symbol or ISIN.
The daily scrip master file of every instrument, and lookups over it.
- The file is downloaded from
https://assets.sahi.com/external/instruments.csv. To use another copy, passscrip_master_url=when you build the client or setSAHI_SCRIP_MASTER_URL. - Columns.
idis theinstrument_idfor market data;symbolandsegmentare what orders take assymbolandexchange_segment. - Values are strings, except
id,lot_size,freeze_quantity,tokenandprice_precision. See Units in the file. - Loaded once per process, on first use, and refreshed after the daily rebuild around 06:00 IST. It takes over 100 MB in memory.
Every instrument#
method
api.get_instruments(...)
api.get_instruments(*, refresh: bool = False, timeout: float | None = None) -> list[dict]
Every row of the file.
refresh
bool
Optional
Download again even if the copy is current.
timeout
float
Optional
Download timeout; default 30 seconds.
Returns#
A list of row dicts. Treat them as read-only.
Raises#
SahiConnectionException,SahiTimeoutExceptionorSahiAPIException: the download failed.
Units in the file#
The file and the API use different units; the SDK converts neither.
| Column | In the file | In the API |
|---|---|---|
tick_size, strike_price |
Rupees, string: "0.05" |
Paise, integer: 5 |
expiry_date |
DD-MM-YYYY |
YYYY-MM-DD |
Find an index#
Indices have no symbol; find one by company_name.
Find an option contract#
Filter on the underlying, type, strike and expiry, in the file's units. Or
start from the option chain,
whose legs carry the instrument_id.
Instruments by symbol#
method
api.get_instruments_by_symbol(...)
api.get_instruments_by_symbol(symbol: str, exchange_segment: str | None = None, *, timeout: float | None = None) -> list[dict]
The rows with this symbol, as a list: a symbol can be in more than one
segment.
symbol
str
Required
The file's
symbol column.
exchange_segment
str
Optional
Narrow to
NSE, NFO, BSE or BFO.
timeout
float
Optional
Download timeout for the first load.
Raises#
- As for
get_instruments, on the first load only.