- Python Algorithmic Trading Cookbook
- Pushpak Dagade
- 318字
- 2021-06-11 18:29:23
Knowing other attributes supported by the broker
For placing an order, the following attributes are needed: order transaction type, order variety, order type, and order code. Different brokers may support different types of order attributes. For example, some brokers may support just regular orders, while others may support regular and bracket orders. The value for each of the attributes supported by the broker can be queried using the broker specific constants provided by the pyalgotrading package.
How to do it…
We execute the following steps to complete this recipe:
- Import the necessary class from the pyalgotrading module:
>>> from pyalgotrading.broker.broker_connection_zerodha import BrokerConnectionZerodha
- List the order transaction types:
>>> list(BrokerConnectionZerodha.ORDER_TRANSACTION_TYPE_MAP.keys())
We'll get the following output:
[<BrokerOrderTransactionTypeConstants.BUY: 'BUY'>,
<BrokerOrderTransactionTypeConstants.SELL: 'SELL'>]
- List the order varieties:
>>> list(BrokerConnectionZerodha.ORDER_VARIETY_MAP.keys())
We'll get the following output:
[<BrokerOrderVarietyConstants.MARKET: 'ORDER_VARIETY_MARKET'>,
<BrokerOrderVarietyConstants.LIMIT: 'ORDER_VARIETY_LIMIT'>,
<BrokerOrderVarietyConstants.STOPLOSS_LIMIT: 'ORDER_VARIETY_STOPLOSS_LIMIT'>,
<BrokerOrderVarietyConstants.STOPLOSS_MARKET: 'ORDER_VARIETY_STOPLOSS_MARKET'>]
- List the order types:
>>> list(BrokerConnectionZerodha.ORDER_TYPE_MAP.keys())
We'll get the following output:
[<BrokerOrderTypeConstants.REGULAR: 'ORDER_TYPE_REGULAR'>,
<BrokerOrderTypeConstants.BRACKET: 'ORDER_TYPE_BRACKET'>,
<BrokerOrderTypeConstants.COVER: 'ORDER_TYPE_COVER'>,
<BrokerOrderTypeConstants.AMO: 'ORDER_TYPE_AFTER_MARKET_ORDER'>]
- List the order codes:
>>> list(BrokerConnectionZerodha.ORDER_CODE_MAP.keys())
We'll get the following output:
[<BrokerOrderCodeConstants.INTRADAY: 'ORDER_CODE_INTRADAY'>,
<BrokerOrderCodeConstants.DELIVERY: 'ORDER_CODE_DELIVERY_T0'>]
How it works…
In step 1, we import the BrokerConnectionZerodha class from pyalgotrading. This class holds the order attributes mapping between pyalgotrading and broker specific constants as dictionary objects. The next steps fetch and print these mappings. Step 2 shows that your broker supports both BUY and SELL order transaction types.
Step 3 shows that your broker supports MARKET, LIMIT, STOPLOSS_LIMIT, and STOPLOSS_MARKET order varieties. Step 4 shows that your broker supports REGULAR, BRACKET, COVER, and AFTER_MARKET order types. Step 5 shows that your broker supports INTRADAY and DELIVERY order codes.
The outputs may differ from broker to broker, so consult your broker documentation if you are using a different broker. A detailed explanation of all these types of parameters will be covered in Chapter 6, Placing Trading Orders on the Exchange. This recipe is to just give an overview of the parameters, as they are needed in the subsequent recipes of this chapter.
- 亮劍.NET:.NET深入體驗與實戰(zhàn)精要
- PowerShell 3.0 Advanced Administration Handbook
- 協(xié)作機器人技術(shù)及應用
- Getting Started with Containerization
- 工業(yè)機器人工程應用虛擬仿真教程:MotoSim EG-VRC
- 數(shù)據(jù)通信與計算機網(wǎng)絡
- 自動控制理論(非自動化專業(yè))
- Splunk Operational Intelligence Cookbook
- 單片機C語言應用100例
- 電腦日常使用與維護322問
- Pentaho Analytics for MongoDB
- PowerMill 2020五軸數(shù)控加工編程應用實例
- ZigBee無線通信技術(shù)應用開發(fā)
- Raspberry Pi Projects for Kids
- 智能小車機器人制作大全(第2版)