Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Algorithmic Trading Cookbook

You're reading from   Python Algorithmic Trading Cookbook All the recipes you need to implement your own algorithmic trading strategies in Python

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781838989354
Length 542 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Pushpak Dagade Pushpak Dagade
Author Profile Icon Pushpak Dagade
Pushpak Dagade
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Handling and Manipulating Date, Time, and Time Series Data 2. Stock Markets - Primer on Trading FREE CHAPTER 3. Fetching Financial Data 4. Computing Candlesticks and Historical Data 5. Computing and Plotting Technical Indicators 6. Placing Regular Orders on the Exchange 7. Placing Bracket and Cover Orders on the Exchange 8. Algorithmic Trading Strategies - Coding Step by Step 9. Algorithmic Trading - Backtesting 10. Algorithmic Trading - Paper Trading 11. Algorithmic Trading - Real Trading 12. Other Books You May Enjoy Appendix I
1. Appendix II
2. Appendix III

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:

  1. Import the necessary class from the pyalgotrading module:
>>> from pyalgotrading.broker.broker_connection_zerodha import BrokerConnectionZerodha
  1. List the order transaction types:
>>> list(BrokerConnectionZerodha.ORDER_TRANSACTION_TYPE_MAP.keys())

We'll get the following output:

[<BrokerOrderTransactionTypeConstants.BUY: 'BUY'>,
<BrokerOrderTransactionTypeConstants.SELL: 'SELL'>]
  1. 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'>]
  1. 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'>]
  1. 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.
You have been reading a chapter from
Python Algorithmic Trading Cookbook
Published in: Aug 2020
Publisher: Packt
ISBN-13: 9781838989354
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image