Preface

Algorithmic trading helps you stay ahead of the market by devising strategies in quantitative analysis to gain profits and cut losses. This book will help you to understand financial theories and execute a range of algorithmic trading strategies confidently.

The book starts by introducing you to algorithmic trading, the pyfinance ecosystem, and Quantopian. You'll then cover algorithmic trading and quantitative analysis using Python, and learn how to build algorithmic trading strategies on Quantopian. As you advance, you'll gain an in-depth understanding of Python libraries such as NumPy and pandas for analyzing financial datasets, and also explore the matplotlib, statsmodels, and scikit-learn libraries for advanced analytics. Moving on, you'll explore useful financial concepts and theories such as financial statistics, leveraging and hedging, and short selling, which will help you understand how financial markets operate. Finally, you will discover mathematical models and approaches for analyzing and understanding financial time series data.

By the end of this trading book, you will be able to build predictive trading signals, adopt basic and advanced algorithmic trading strategies, and perform portfolio optimization on the Quantopian platform.

Who this book is for

This book is for data analysts and financial traders who want to explore algorithmic trading using Python core libraries. If you are looking for a practical guide to execute various algorithmic trading strategies, then this book is for you. Basic working knowledge of Python programming and statistics will be helpful.

What this book covers

Chapter 1, Introduction to Algorithmic Trading and Python, introduces the key financial trading concepts and explains why Python is best suited for algorithmic trading.

Chapter 2, Exploratory Data Analysis in Python, provides an overview of the first step in processing any dataset, exploratory data analysis.

Chapter 3, High-Speed Scientific Computing Using NumPy, takes a detailed look at NumPy, a library for fast and scalable structured arrays and vectorized computations.

Chapter 4, Data Manipulation and Analysis with pandas, introduces the pandas library, built on top of NumPy, which provides data manipulation and analysis methods to structured DataFrames.

Chapter 5, Data Visualization Using Matplotlib, focuses on one of the primary visualization libraries in Python, Matplotlib.

Chapter 6, Statistical Estimation, Inference, and Prediction, discusses the statsmodels and scikit-learn libraries for advanced statistical analysis techniques, time series analysis techniques, as well as training and validating machine learning models.

Chapter 7, Financial Market Data Access in Python, describes alternative ways to retrieve market data in Python.

Chapter 8, Introduction to Zipline and PyFolio, covers Zipline and PyFolio, which are Python libraries that abstract away the complexities of actual backtesting and performance/risk analysis of algorithmic trading strategies. They allow you to entirely focus on the trading logic.

Chapter 9, Fundamental Algorithmic Trading Strategies, introduces the concept of an algorithmic strategy, and eight different trading algorithms representing the most used algorithms.

To get the most out of this book

Follow the instructions in the Appendix section on how to recreate the conda virtual environment using the environment.yml file stored in the book's GitHub's repository. One command restores the entire environment.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Hands-On-Financial-Trading-with-Python. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781838982881_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Let's create a zipline_env virtual environment with Python 3.6."

A block of code is set as follows:

from zipline import run_algorithm

from zipline.api import order_target_percent, symbol

from datetime import datetime

import pytz

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

from . import quandl  # noqa

from . import csvdir  # noqa

from . import quandl_eod  # noqa

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Then, specify the variable in the Environment Variables... dialog."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.178