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

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.

主站蜘蛛池模板: 芮城县| 泉州市| 神农架林区| 梁平县| 元江| 岢岚县| 中超| 临潭县| 施秉县| 抚松县| 阿勒泰市| 姚安县| 上林县| 介休市| 那坡县| 车致| 来宾市| 清苑县| 麻城市| 丹凤县| 东阿县| 建水县| 高邮市| 织金县| 乐平市| 金华市| 祁连县| 苏尼特右旗| 巧家县| 江北区| 昌平区| 邯郸市| 麻阳| 徐州市| 五华县| 瓮安县| 雅安市| 中卫市| 东光县| 东海县| 青海省|