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

Querying a list of segments

A segment is essentially a categorization of instruments based on their types. The various types of segments that are commonly found at exchanges include cash/equities, futures, options, commodities, and currency. Each segment may have a different operating time. Usually, a broker supports multiple segments within multiple exchanges. This recipe demonstrates how to find the list of segments supported by the broker.

Getting ready

Make sure the instruments object is available in your Python namespace. Refer to the second recipe of this chapter to learn how to set up this object.

How to do it…

Display the segments supported by the broker:

>>> segments = instruments.segment.unique()
>>> print(segments)

You will get the following output:

['BCD-FUT' 'BCD' 'BCD-OPT' 'BSE' 'INDICES' 'CDS-FUT' 'CDS-OPT' 'MCX-FUT' 'MCX-OPT' 'NFO-OPT' 'NFO-FUT' 'NSE']

How it works…

instruments.segment returns a pandas.Series object. Its unique method returns a numpy.ndarray object consisting of unique segments supported by the broker.

主站蜘蛛池模板: 洞头县| 哈尔滨市| 延川县| 元江| 岳阳县| 德兴市| 汤原县| 托克逊县| 新闻| 武冈市| 江都市| 甘肃省| 巫溪县| 凤城市| 留坝县| 门头沟区| 象山县| 新郑市| 延长县| 兴义市| 徐州市| 永州市| 龙陵县| 拜泉县| 启东市| 当阳市| 渭源县| 札达县| 岳普湖县| 镶黄旗| 永吉县| 视频| 右玉县| 瓦房店市| 和龙市| 阜南县| 西乌珠穆沁旗| 韶山市| 靖州| 邓州市| 上犹县|