0%

Book Description

Financial trading, once the exclusive domain of institutional players, is now open to small organizations and individual traders using online platforms. The tool of choice for many traders today is Python and its ecosystem of powerful packages. In this practical book, author Yves Hilpisch shows students, academics, and practitioners how to use Python in the fascinating field of algorithmic trading.

You’ll learn several ways to apply Python to different aspects of algorithmic trading, such as backtesting trading strategies and interacting with online trading platforms. Some of the biggest buy- and sell-side institutions make heavy use of Python. By exploring options for systematically building and deploying automated algorithmic trading strategies, this book will help you level the playing field.

  • Set up a proper Python environment for algorithmic trading
  • Learn how to retrieve financial data from public and proprietary data sources
  • Explore vectorization for financial analytics with NumPy and pandas
  • Master vectorized backtesting of different algorithmic trading strategies
  • Generate market predictions by using machine learning and deep learning
  • Tackle real-time processing of streaming data with socket programming tools
  • Implement automated algorithmic trading strategies with the OANDA and FXCM platforms

Table of Contents

  1. 1. Python and Algorithmic Trading
    1. Python for Finance
      1. Python vs. Pseudo-Code
      2. NumPy and Vectorization
      3. pandas and the DataFrame Class
    2. Algorithmic Trading
    3. Python for Algorithmic Trading
    4. Focus and Prerequisites
    5. Trading Strategies
      1. Simple Moving Averages
      2. Momentum
      3. Mean-Reversion
      4. Machine and Deep Learning
    6. Conclusions
    7. Further Resources
  2. 2. Python Infrastructure
    1. Conda as a Package Manager
      1. Installing Miniconda
      2. Basic Operations with Conda
    2. Conda as a Virtual Environment Manager
    3. Using Docker Containers
      1. Docker Images and Containers
      2. Building a Ubuntu & Python Docker Image
    4. Using Cloud Instances
      1. RSA Public and Private Keys
      2. Jupyter Notebook Configuration File
      3. Installation Script for Python and Jupyter Lab
      4. Script to Orchestrate the Droplet Set-up
    5. Conclusions
    6. Further Resources
  3. 3. Working with Financial Data
    1. Reading Financial Data From Different Sources
      1. The Data Set
      2. Reading from a CSV File with Python
      3. Reading from a CSV File with pandas
      4. Exporting to Excel and JSON
      5. Reading from Excel and JSON
    2. Working with Open Data Sources
    3. Eikon Data API
      1. Retrieving Historical Structured Data
      2. Retrieving Historical Unstructured Data
    4. Storing Financial Data Efficiently
      1. Storing DataFrame Objects
      2. Using TsTables
      3. Storing Data with SQLite3
    5. Conclusions
    6. Further Resources
    7. Python Scripts
  4. 4. Mastering Vectorized Backtesting
    1. Making Use of Vectorization
      1. Vectorization with NumPy
      2. Vectorization with pandas
    2. Strategies based on Simple Moving Averages
      1. Getting into the Basics
      2. Generalizing the Approach
    3. Strategies based on Momentum
      1. Getting into the Basics
      2. Generalizing the Approach
    4. Strategies based on Mean-Reversion
      1. Getting into the Basics
      2. Generalizing the Approach
    5. Data Snooping and Overfitting
    6. Conclusions
    7. Further Resources
    8. Python Scripts
      1. SMA Backtesting Class
      2. Momentum Backtesting Class
      3. Mean Reversion Backtesting Class
  5. 5. Predicting Market Movements with Machine Learning
    1. Using Linear Regression for Market Movement Prediction
      1. A Quick Review of Linear Regression
      2. The Basic Idea for Price Prediction
      3. Predicting Index Levels
      4. Predicting Future Returns
      5. Predicting Future Market Direction
      6. Vectorized Backtesting of Regression-based Strategy
      7. Generalizing the Approach
    2. Using Machine Learning for Market Movement Prediction
      1. Linear Regression with scikit-learn
      2. A Simple Classification Problem
      3. Using Logistic Regression to Predict Market Direction
      4. Generalizing the Approach
    3. Using Deep Learning for Market Movement Prediction
      1. The Simple Classification Problem Revisited
      2. Using Deep Neural Networks to Predict Market Direction
      3. Adding Different Types of Features
    4. Conclusions
    5. Further Resources
    6. Python Scripts
      1. Linear Regression Backtesting Class
      2. Classification Algorithm Backtesting Class
  6. 6. Building Classes for Event-based Backtesting
    1. Backtesting Base Class
    2. Long Only Backtesting Class
    3. Long Short Backtesting Class
    4. Conclusions
    5. Further Resources
    6. Python Scripts
      1. Backtesting Base Class
      2. Long Only Backtesting Class
      3. Long Short Backtesting Class
34.205.246.61