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

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.

主站蜘蛛池模板: 卫辉市| 土默特右旗| 余干县| 桐城市| 德庆县| 伊通| 崇礼县| 磴口县| 桦甸市| 安塞县| 布尔津县| 北宁市| 晋中市| 元氏县| 西城区| 西盟| 沙雅县| 玉树县| 凤翔县| 黄大仙区| 红河县| 吴川市| 绍兴市| 临洮县| 东台市| 曲周县| 阿合奇县| 珠海市| 庆安县| 延庆县| 三门峡市| 宁化县| 耿马| 萍乡市| 昌平区| 永定县| 双柏县| 安泽县| 云梦县| 虹口区| 武汉市|