𝔖 Scriptorium
✦   LIBER   ✦

📁

Python for Algorithmic Trading Cookbook: Recipes for designing, building, and deploying algorithmic trading strategies with Py

✍ Scribed by Jason Strimpel


Publisher
Packt Publishing Pvt Ltd
Year
2024
Tongue
English
Leaves
556
Edition
1
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Harness the power of Python libraries to transform freely available financial market data into algorithmic trading strategies and deploy them into a live trading environment

Key Features
- Follow practical Python recipes to acquire, visualize, and store market data for market research
- Design, backtest, and evaluate the performance of trading strategies using professional techniques
- Deploy trading strategies built in Python to a live trading environment with API connectivity

Book Description
Discover how Python has made algorithmic trading accessible to non-professionals with unparalleled expertise and practical insights from Jason Strimpel, founder of PyQuant News and a seasoned professional with global experience in trading and risk management. This book guides you through from the basics of quantitative finance and data acquisition to advanced stages of backtesting and live trading.

Detailed recipes will help you leverage the cutting-edge OpenBB SDK to gather freely available data for stocks, options, and futures, and build your own research environment using lightning-fast storage techniques like SQLite, HDF5, and ArcticDB. This book shows you how to use SciPy and statsmodels to identify alpha factors and hedge risk, and construct momentum and mean-reversion factors. You'll optimize strategy parameters with walk-forward optimization using vectorbt and construct a production-ready backtest using Zipline Reloaded. Implementing all that you've learned, you'll set up and deploy your algorithmic trading strategies in a live trading environment using the Interactive Brokers API, allowing you to stream tick-level data, submit orders, and retrieve portfolio details.

By the end of this algorithmic trading book, you'll not only have grasped the essential concepts but also the practical skills needed to implement and execute sophisticated trading strategies using Python.

What You Will Learn
- Acquire and process freely available market data with the OpenBB Platform
- Build a research environment and populate it with financial market data
- Use machine learning to identify alpha factors and engineer them into signals
- Use VectorBT to find strategy parameters using walk-forward optimization
- Build production-ready backtests with Zipline Reloaded and evaluate factor performance
- Set up the code framework to connect and send an order to Interactive Brokers

Who this book is for
Python for Algorithmic Trading Cookbook equips traders, investors, and Python developers with code to design, backtest, and deploy algorithmic trading strategies. You should have experience investing in the stock market, knowledge of Python data structures, and a basic understanding of using Python libraries like pandas. This book is also ideal for individuals with Python experience who are already active in the market or are aspiring to be.

✦ Table of Contents


Python for Algorithmic Trading Cookbook
Contributors
About the author
About the reviewers
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Share Your Thoughts
Download a free PDF copy of this book
1
Acquire Free Financial Market Data with Cutting-Edge Python Libraries
Technical requirements
Diving into continuous futures data with Nasdaq Data Link
Getting ready…
How to do it…
How it works…
There’s more…
See also
Exploring S&P 500 ratios data with Nasdaq Data Link
How to do it…
How it works…
There’s more…
See also
Working with stock market data with the OpenBB Platform
Getting ready…
How to do it…
How it works…
There’s more…
See also
Fetching historic futures data with the OpenBB Platform
Getting ready…
How to do it…
There’s more…
See also
Navigating options market data with the OpenBB Platform
Getting ready…
How to do it…
How it works…
There’s more…
See also
Harnessing factor data using pandas_datareader
Getting ready…
How to do it…
How it works…
There’s more…
See also
2
Analyze and Transform Financial Market Data with pandas
Diving into pandas index types
How to do it…
How it works…
There’s more…
See also
Building pandas Series and DataFrames
Getting ready
How to do it…
How it works…
There’s more…
See also
Manipulating and transforming DataFrames
Getting ready…
How to do it…
How it works…
There’s more…
See also
Examining and selecting data from DataFrames
How to do it…
How it works…
There’s more…
See also
Calculating asset returns using pandas
How to do it…
How it works…
There’s more…
See also
Measuring the volatility of a return series
How to do it…
How it works…
There’s more…
See also
Generating a cumulative return series
Getting ready…
How to do it…
How it works…
See also
Resampling data for different time frames
How to do it…
How it works…
There’s more…
See also
Addressing missing data issues
Getting ready…
How to do it…
How it works…
There’s more…
See also
Applying custom functions to analyze time series data
Getting ready…
How to do it…
How it works…
There’s more…
See also
3
Visualize Financial Market Data with Matplotlib, Seaborn, and Plotly Dash
Quickly visualizing data using pandas
How to do it…
How it works…
There’s more…
See also
Animating the evolution of the yield curve with Matplotlib
How to do it…
How it works…
There’s more…
See also
Plotting options implied volatility surfaces with Matplotlib
Getting ready…
How to do it…
How it works…
There’s more…
See also
Visualizing statistical relationships with Seaborn
How to do it…
How it works…
There’s more…
See also
Creating an interactive PCA analytics dashboard with Plotly Dash
Getting ready…
How to do it…
How it works…
There’s more…
See also
4
Store Financial Market Data on Your Computer
Storing data on disk in CSV format
How to do it…
How it works…
There’s more…
See also…
Storing data on disk with SQLite
Getting ready…
How to do it…
How it works…
There’s more…
See also…
Storing data in a PostgreSQL database server
Getting ready…
How to do it…
How it works…
There’s more…
See also…
Storing data in ultra-fast HDF5 format
Getting ready…
How to do it…
How it works…
There’s more…
See also…
5
Build Alpha Factors for Stock Portfolios
Identifying latent return drivers using principal component analysis
Getting ready
How to do it…
How it works…
There’s more…
See also
Finding and hedging portfolio beta using linear regression
Getting ready
How to do it…
How it works…
There’s more…
See also
Analyzing portfolio sensitivities to the Fama-French factors
Getting ready
How to do it…
How it works…
There’s more…
See also
Assessing market inefficiency based on volatility
How to do it…
How it works…
There’s more…
See also
Preparing a factor ranking model using Zipline Pipelines
Getting ready
How to do it…
How it works…
There’s more…
See also
6
Vector-Based Backtesting with VectorBT
Building technical strategies with VectorBT
Getting ready
How to do it…
How it works…
There’s more…
See also
Conducting walk-forward optimization with VectorBT
Getting ready
How to do it…
How it works…
There’s more…
See also
Optimizing the SuperTrend strategy with VectorBT Pro
Getting ready
How to do it…
How it works…
There’s more…
See also
7
Event-Based Backtesting Factor Portfolios with Zipline Reloaded
Technical Requirements
For Windows, Unix/Linux, and Mac Intel users
For Mac M1/M2 users
Backtesting a momentum factor strategy with Zipline Reloaded
Getting ready
How to do it…
How it works…
There’s more…
See also
Exploring a mean reversion strategy with Zipline Reloaded
Getting ready
How to do it…
How it works…
There’s more…
See also
8
Evaluate Factor Risk and Performance with Alphalens Reloaded
Preparing backtest results
Getting ready…
How to do it…
How it works…
There’s more…
See also
Evaluating the information coefficient
Getting ready…
How to do it…
How it works…
There’s more…
See also
Examining factor return performance
How to do it…
How it works…
There’s more…
See also
Evaluating factor turnover
How to do it…
How it works…
There’s more…
See also
9
Assess Backtest Risk and Performance Metrics with Pyfolio
Preparing Zipline backtest results for Pyfolio Reloaded
Getting ready…
How to do it…
How it works…
There’s more…
See also
Generating strategy performance and return analytics
Getting ready…
How to do it…
How it works…
There’s more…
See also
Building a drawdown and rolling risk analysis
Getting ready…
How to do it…
How it works…
There’s more…
See also
Analyzing strategy holdings, leverage, exposure, and sector allocations
Getting ready…
How to do it…
How it works…
There’s more…
See also
Breaking Down Strategy Performance to Trade Level
Getting ready…
How to do it…
How it works…
There’s more…
See also
10
Set Up the Interactive Brokers Python API
Building an algorithmic trading app
Getting ready…
How to do it…
How it works…
There’s more…
See also
Creating a Contract object with the IB API
Getting ready…
How to do it…
How it works…
There’s more…
See also
Creating an Order object with the IB API
Getting ready…
How to do it…
How it works…
There’s more…
See also
Fetching historical market data
Getting ready…
How to do it…
How it works…
There’s more…
See also
Getting a market data snapshot
Getting ready…
How to do it…
How it works…
There’s more…
See also
Streaming live market data
Getting ready…
How to do it…
How it works…
There’s more…
See also
Storing live tick data in a local SQL database
Getting ready…
How to do it…
How it works…
There’s more…
See also
11
Manage Orders, Positions, and Portfolios with the IB API
Executing orders with the IB API
Getting ready
How to do it…
How it works…
There’s more…
See also
Managing orders once they’re placed
Getting ready
How to do it…
How it works…
There’s more…
See also
Getting details about your portfolio
Getting ready
How to do it…
How it works…
There’s more…
See also
Inspecting positions and position details
Getting ready
How to do it…
How it works…
There’s more…
See also
Computing portfolio profit and loss
Getting ready
How to do it…
How it works…
There’s more…
See also
12
Deploy Strategies to a Live Environment
Calculating real-time key performance and risk indicators
Getting ready
How to do it…
How it works…
There’s more…
See also
Sending orders based on portfolio targets
Getting ready
How to do it…
How it works…
There’s more…
See also
Deploying a monthly factor portfolio strategy
Getting ready
How to do it…
How it works…
There’s more…
See also
Deploying an options combo strategy
Getting ready
How to do it…
How it works…
There’s more…
See also
Deploying an intraday multi-asset mean reversion strategy
Getting ready
How to do it…
How it works…
There’s more…
See also
13
Advanced Recipes for Market Data and Strategy Management
Streaming real-time options data with ThetaData
Getting ready
How to do it…
How it works…
There’s more…
See also
Using the ArcticDB DataFrame database for tick storage
Getting ready
How to do it…
How it works…
There’s more…
See also
Triggering real-time risk limit alerts
Getting ready
How to do it…
How it works…
There’s more…
See also
Storing trade execution details in a SQL database
Getting ready
How to do it…
How it works…
There’s more…
See also
Index
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts
Download a free PDF copy of this book


📜 SIMILAR VOLUMES


Python for Algorithmic Trading Cookbook:
✍ Jason Strimpel 📂 Library 📅 2024 🏛 Packt Publishing 🌐 English

<p><span>Harness the power of Python libraries to transform freely available financial market data into algorithmic trading strategies and deploy them into a live trading environment</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Follow practical Python recipes to acquire, visualize

Python for Algorithmic Trading Cookbook
✍ Jason Strimpel 📂 Library 📅 2024 🏛 Packt Publishing Pvt Ltd 🌐 English

<p><span>Harness the power of Python libraries to transform freely available financial market data into algorithmic trading strategies and deploy them into a live trading environment</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Follow practical Python recipes to acquire, visualize

Learn Algorithmic Trading: Build and dep
✍ Sebastien Donadio and Sourav Ghosh 📂 Library 🌐 English

t's now harder than ever to get a significant edge over competitors in terms of speed and efficiency when it comes to algorithmic trading. Relying on sophisticated trading signals, predictive models and strategies can make all the difference. This book will guide you through these aspects, giving yo

Learn Algorithmic Trading: Build and dep
✍ Sebastien Donadio, Sourav Ghosh 📂 Library 📅 2019 🏛 Packt Publishing 🌐 English

Understand the fundamentals of algorithmic trading to apply algorithms to real market data and analyze the results of real-world trading strategies Key Features • Understand the power of algorithmic trading in financial markets with real-world examples • Get up and running with the algorithms u

The Algorithmic Designer: Designing Trad
✍ Van Der Post, Hayden 📂 Library 📅 2024 🏛 Reactive Publishing 🌐 English

Reactive Publishing Dive into the dynamic world of financial markets with "Algorithmic Designer: Designing Trading Strategies with Python," your comprehensive guide to mastering algorithmic trading. This book is a treasure trove for both beginners and seasoned traders looking to leverage the power

Stock Trading with Python: Strategies to
✍ Hayden Van Der Post 📂 Library 📅 2024 🏛 Reactive Publishing 🌐 English

In "Stock Trading with Python," embark on a journey into the world of algorithmic trading and discover how Python can revolutionize your approach to the stock market. This comprehensive guide combines theoretical knowledge with practical applications, empowering both beginners and seasoned traders t