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

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.

主站蜘蛛池模板: 阿拉善盟| 靖安县| 靖安县| 清原| 永胜县| 玉屏| 龙泉市| 太和县| 永春县| 咸阳市| 深圳市| 阿城市| 漳浦县| 晋中市| 平乐县| 张家港市| 马尔康县| 云林县| 晋宁县| 万荣县| 从江县| 浮梁县| 项城市| 周宁县| 吴堡县| 高要市| 靖宇县| 玛曲县| 廉江市| 岳池县| 洱源县| 汉源县| 平罗县| 伊宁市| 阳原县| 黎城县| 扬州市| 恩施市| 普兰县| 贵南县| 集贤县|