- Python Algorithmic Trading Cookbook
- Pushpak Dagade
- 155字
- 2021-06-11 18:29:23
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.
- 零起步輕松學單片機技術(第2版)
- R Data Mining
- 錯覺:AI 如何通過數據挖掘誤導我們
- Drupal 7 Multilingual Sites
- 極簡AI入門:一本書讀懂人工智能思維與應用
- 機器人智能運動規劃技術
- 工業機器人入門實用教程(KUKA機器人)
- 西門子S7-200 SMART PLC實例指導學與用
- Learn CloudFormation
- Windows Server 2008 R2活動目錄內幕
- 從零開始學C++
- ESP8266 Robotics Projects
- 水晶石影視動畫精粹:After Effects & Nuke 影視后期合成
- Windows安全指南
- FANUC工業機器人配置與編程技術