官术网_书友最值得收藏!

Fetching an instrument

Instruments, also known as financial instruments or securities, are assets that can be traded in an exchange. In an exchange, there can easily be tens of thousands of instruments. This recipe demonstrates how to fetch an instrument based on its exchange and trading symbol.

Getting ready

Make sure the broker_connection object is available in your Python namespace. Refer to the first recipe in this chapter to set up this object.

How to do it…

Fetch an instrument for a specific trading symbol and exchange:

>>> broker_connection.get_instrument(segment='NSE', tradingsymbol='TATASTEEL')

You'll get the following output:

segment: NSE
exchange: NSE
tradingsymbol: TATASTEEL
broker_token: 895745
tick_size: 0.05
lot_size: 1
expiry:
strike_price: 0.0

How it works…

The broker_connection object provides a handy method, get_instrument, for fetching any financial instrument. It takes segment and tradingsymbol as attributes before returning an instrument. The return object is an instance of the Instrument class.

主站蜘蛛池模板: 蓝田县| 无棣县| 玉林市| 威海市| 高碑店市| 平顶山市| 修文县| 锡林郭勒盟| 布拖县| 呼和浩特市| 信阳市| 九江县| 滨州市| 长沙县| 师宗县| 靖西县| 得荣县| 西昌市| 东明县| 蕲春县| 余江县| 黄山市| 花垣县| 六盘水市| 焉耆| 万载县| 克什克腾旗| 塔河县| 孟连| 额济纳旗| 汉沽区| 宁河县| 揭阳市| 房山区| 乌兰县| 渭南市| 井冈山市| 轮台县| 龙岩市| 安多县| 临洮县|