SAHI DOCS

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.

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#

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.

Instrument by id#

method api.get_instrument_by_id(...)
api.get_instrument_by_id(instrument_id: int, *, timeout: float | None = None) -> dict | None

The row for an instrument_id, or None.

Raises#

  • As for get_instruments, on the first load only.

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.

Instruments by ISIN#

method api.get_instruments_by_isin(...)
api.get_instruments_by_isin(isin: str, *, timeout: float | None = None) -> list[dict]

The rows with this ISIN; a stock on both exchanges returns two.

Raises#

  • As for get_instruments, on the first load only.