Book description
Leverage machine learning to design and back-test automated trading strategies for real-world markets using pandas, TA-Lib, scikit-learn, LightGBM, SpaCy, Gensim, TensorFlow 2, Zipline, backtrader, Alphalens, and pyfolio.
Purchase of the print or Kindle book includes a free eBook in the PDF format.
Key Features
- Design, train, and evaluate machine learning algorithms that underpin automated trading strategies
- Create a research and strategy development process to apply predictive modeling to trading decisions
- Leverage NLP and deep learning to extract tradeable signals from market and alternative data
Book Description
The explosive growth of digital data has boosted the demand for expertise in trading strategies that use machine learning (ML). This revised and expanded second edition enables you to build and evaluate sophisticated supervised, unsupervised, and reinforcement learning models.
This book introduces end-to-end machine learning for the trading workflow, from the idea and feature engineering to model optimization, strategy design, and backtesting. It illustrates this by using examples ranging from linear models and tree-based ensembles to deep-learning techniques from cutting edge research.
This edition shows how to work with market, fundamental, and alternative data, such as tick data, minute and daily bars, SEC filings, earnings call transcripts, financial news, or satellite images to generate tradeable signals. It illustrates how to engineer financial features or alpha factors that enable an ML model to predict returns from price data for US and international stocks and ETFs. It also shows how to assess the signal content of new features using Alphalens and SHAP values and includes a new appendix with over one hundred alpha factor examples.
By the end, you will be proficient in translating ML model predictions into a trading strategy that operates at daily or intraday horizons, and in evaluating its performance.
What you will learn
- Leverage market, fundamental, and alternative text and image data
- Research and evaluate alpha factors using statistics, Alphalens, and SHAP values
- Implement machine learning techniques to solve investment and trading problems
- Backtest and evaluate trading strategies based on machine learning using Zipline and Backtrader
- Optimize portfolio risk and performance analysis using pandas, NumPy, and pyfolio
- Create a pairs trading strategy based on cointegration for US equities and ETFs
- Train a gradient boosting model to predict intraday returns using AlgoSeek's high-quality trades and quotes data
Who this book is for
If you are a data analyst, data scientist, Python developer, investment analyst, or portfolio manager interested in getting hands-on machine learning knowledge for trading, this book is for you. This book is for you if you want to learn how to extract value from a diverse set of data sources using machine learning to design your own systematic trading strategies.
Some understanding of Python and machine learning techniques is required.
Table of contents
- Preface
- Machine Learning for Trading â From Idea to Execution
-
Market and Fundamental Data â Sources and Techniques
- Market data reflects its environment
- Working with high-frequency data
- API access to market data
- How to work with fundamental data
- Efficient data storage with pandas
- Summary
- Alternative Data for Finance â Categories and Use Cases
-
Financial Feature Engineering â How to Research Alpha Factors
- Alpha factors in practice â from data to signals
- Building on decades of factor research
-
Engineering alpha factors that predict returns
-
How to engineer factors using pandas and NumPy
- Loading, slicing, and reshaping the data
- Resampling â from daily to monthly frequency
- How to compute returns for multiple historical periods
- Using lagged returns and different holding periods
- Computing factor betas
- How to add momentum factors
- Adding time indicators to capture seasonal effects
- How to create lagged return features
- How to create forward returns
- How to use TA-Lib to create technical alpha factors
- Denoising alpha factors with the Kalman filter
- How to preprocess your noisy signals using wavelets
-
How to engineer factors using pandas and NumPy
- From signals to trades â Zipline for backtests
- Separating signal from noise with Alphalens
- Alpha factor resources
- Summary
-
Portfolio Optimization and Performance Evaluation
- How to measure portfolio performance
- How to manage portfolio risk and return
- Trading and managing portfolios with Zipline
- Measuring backtest performance with pyfolio
- Summary
-
The Machine Learning Process
- How machine learning from data works
-
The machine learning workflow
- Basic walkthrough â k-nearest neighbors
- Framing the problem â from goals to metrics
- Collecting and preparing the data
- Exploring, extracting, and engineering features
- Selecting an ML algorithm
- Design and tune the model
- How to select a model using cross-validation
- How to implement cross-validation in Python
- Challenges with cross-validation in finance
- Parameter tuning with scikit-learn and Yellowbrick
- Summary
-
Linear Models â From Risk Factors to Return Forecasts
- From inference to prediction
- The baseline model â multiple linear regression
- How to run linear regression in practice
- How to build a linear factor model
- Regularizing linear regression using shrinkage
- How to predict returns with linear regression
- Linear classification
- Summary
-
The ML4T Workflow â From Model to Strategy Backtesting
- How to backtest an ML-driven strategy
- Backtesting pitfalls and how to avoid them
- How a backtesting engine works
- backtrader â a flexible tool for local backtests
- Zipline â scalable backtesting by Quantopian
- Summary
-
Time-Series Models for Volatility Forecasts and Statistical Arbitrage
- Tools for diagnostics and feature extraction
- How to diagnose and achieve stationarity
- Univariate time-series models
- Multivariate time-series models
- Cointegration â time series with a shared trend
- Statistical arbitrage with cointegration
- Summary
-
Bayesian ML â Dynamic Sharpe Ratios and Pairs Trading
- How Bayesian machine learning works
- Probabilistic programming with PyMC3
- Bayesian ML for trading
- Summary
-
Random Forests â A Long-Short Strategy for Japanese Stocks
- Decision trees â learning rules from data
- Random forests â making trees more reliable
-
Long-short signals for Japanese stocks
- The data â Japanese equities
-
The ML4T workflow with LightGBM
- From universe selection to hyperparameter tuning
- Sampling tickers to speed up cross-validation
- Defining lookback, lookahead, and roll-forward periods
- Hyperparameter tuning with LightGBM
- Cross-validating signals over various horizons
- Analyzing cross-validation performance
- Ensembling forecasts â signal analysis using Alphalens
- The strategy â backtest with Zipline
- Summary
-
Boosting Your Trading Strategy
- Getting started â adaptive boosting
- Gradient boosting â ensembles for most tasks
- Using XGBoost, LightGBM, and CatBoost
- A long-short trading strategy with boosting
- Boosting for an intraday strategy
- Summary
- Data-Driven Risk Factors and Asset Allocation with Unsupervised Learning
- Text Data for Trading â Sentiment Analysis
- Topic Modeling â Summarizing Financial News
-
Word Embeddings for Earnings Calls and SEC Filings
- How word embeddings encode semantics
- How to use pretrained word vectors
- Custom embeddings for financial news
- word2vec for trading with SEC filings
- Sentiment analysis using doc2vec embeddings
- New frontiers â pretrained transformer models
- Summary
-
Deep Learning for Trading
- Deep learning â what's new and why it matters
- Designing an NN
- A neural network from scratch in Python
- Popular deep learning libraries
- Optimizing an NN for a long-short strategy
- Summary
-
CNNs for Financial Time Series and Satellite Images
- How CNNs learn to model grid-like data
- CNNs for satellite images and object detection
-
CNNs for time-series data â predicting returns
- An autoregressive CNN with 1D convolutions
-
CNN-TA â clustering time series in 2D format
- Creating technical indicators at different intervals
- Computing rolling factor betas for different horizons
- Features selecting based on mutual information
- Hierarchical feature clustering
- Creating and training a convolutional neural network
- Assembling the best models to generate tradeable signals
- Backtesting a long-short trading strategy
- Summary and lessons learned
- Summary
-
RNNs for Multivariate Time Series and Sentiment Analysis
- How recurrent neural nets work
- RNNs for time series with TensorFlow 2
- RNNs for text data
- Summary
- Autoencoders for Conditional Risk Factors and Asset Pricing
-
Generative Adversarial Networks for Synthetic Time-Series Data
- Creating synthetic data with GANs
- How to build a GAN using TensorFlow 2
- TimeGAN for synthetic financial data
- Summary
-
Deep Reinforcement Learning â Building a Trading Agent
- Elements of a reinforcement learning system
- How to solve reinforcement learning problems
- Solving dynamic programming problems
- Q-learning â finding an optimal policy on the go
- Deep RL for trading with the OpenAI Gym
- Summary
- Conclusions and Next Steps
-
Appendix: Alpha Factor Library
- Common alpha factors implemented in TA-Lib
- WorldQuant's quest for formulaic alphas
- Bivariate and multivariate factor evaluation
- References
- Index
Product information
- Title: Machine Learning for Algorithmic Trading - Second Edition
- Author(s):
- Release date: July 2020
- Publisher(s): Packt Publishing
- ISBN: 9781839217715
You might also like
book
Hands-On Machine Learning for Algorithmic Trading
Explore effective trading strategies in real-world markets using NumPy, spaCy, pandas, scikit-learn, and Keras Key Features …
book
Probabilistic Machine Learning for Finance and Investing
There are several reasons why probabilistic machine learning represents the next-generation ML framework and technology for …
book
Quantitative Trading Strategies Using Python: Technical Analysis, Statistical Testing, and Machine Learning
Build and implement trading strategies using Python. This book will introduce you to the fundamental concepts …
book
Machine Learning and Data Science Blueprints for Finance
Over the next few decades, machine learning and data science will transform the finance industry. With …