Python Algorithmic Trading Cookbook
All the recipes you need to implement your own algorithmic trading strategies in Python
Pushpak Dagade
BIRMINGHAM - MUMBAI
Python Algorithmic Trading Cookbook
Copyright 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Sunith Shetty
Acquisition Editor: Ali Abidi
Content Development Editor: Athikho Sapuni Rishana
Senior Editor: Roshan Kumar
Technical Editor: Manikandan Kurup
Copy Editor: Safis Editing
Project Coordinator: Aishwarya Mohan
Proofreader: Safis Editing
Indexer: Manju Arasan
Production Designer: Vijay Kamble
First published: August 2020
Production reference: 1280820
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-83898-935-4
www.packt.com
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Pushpak Dagade has been working in the area of algorithmic trading for more than 3 years. He is the co-founder and CEO of AlgoBulls, an algorithmic trading platform. He is also a long-time Pythonista with more than a decade of Python experience. He is a graduate from the Indian Institute of Technology (Delhi) and holds engineering degrees in the fields of computer science, electronics, and physics.
About the reviewers
Ratanlal Mahanta is currently working as a quantitative analyst at bittQsrv, a global quantitative research company offering quant models for its investors. He has several years of experience in the modeling and simulation of quantitative trading. Ratanlal holds a master's degree in science in computational finance, and his research areas include quant trading, optimal execution, and high-frequency trading. He has over 9 years' experience in the finance industry and is gifted at solving difficult problems that lie at the intersection of markets, technology, research, and design.
Akhil Jain has a master's degree in computer science from the University of Mumbai. He started his IT career in 2007 in a multi-national company. He worked for 4 years as a Technology Analyst and finally decided to pursue his passion for teaching. He joined his UG alma mater as a lecturer in 2012 and has been teaching ever since. Akhil is using Python in his teachings which spans across the fields of data structures, artificial intelligence, cloud computing, and ethical hacking. He also uses Python extensively to perform stock market analysis and code algorithmic trading strategies. Akhil has also written a book titled Protecting Your Email ID in 2013.
Praxal Shah has a master's degree from IIT Delhi, one of the most reputable universities in India. He has been actively associated with trading derivatives in the Indian stock market for 4 years now and he has been developing a few of his own strategies for options trading, with the help of algo-trading, as a hobby. Praxal believes that this book is a good reference point for anyone who wants to start with algo-trading; this book can help you jump-start your learning as it covers most of the practical aspects of algo-trading.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
Python is a very popular language that is used to build and execute algorithmic trading strategies. If you want to find out how you can build a solid foundation in algorithmic trading using Python, this cookbook is here to help.
Starting by setting up the Python environment for trading and connectivity with brokers, you'll then learn the important aspects of financial markets. As you progress through this algorithmic trading book, you'll learn to fetch financial instruments, query and calculate various types of candles and historical data, and finally, compute and plot technical indicators. Next, you'll discover how to place various types of orders, such as regular, bracket, and cover orders, and understand their state transitions. You'll also uncover challenges faced while devising and executing powerful algorithmic trading strategies from scratch. Later chapters will take you through backtesting, paper trading, and finally real trading for the algorithmic strategies that you've created from the ground up. You'll even understand how to automate trading and find the right strategy for making effective decisions that would otherwise be impossible for human traders.
By the end of this book, you'll be able to use Python for algorithmic trading by implementing Python libraries to conduct key tasks in the algorithmic trading ecosystem.
Next page