Jump to ratings and reviews
Rate this book

Machine Learning for Algorithmic Trading: Predictive Models to Extract Signals from Market and Alternative Data for Systemic Trading Strategies with Python

Rate this book
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 FeaturesDesign, train, and evaluate machine learning algorithms that underpin automated trading strategiesCreate a research and strategy development process to apply predictive modeling to trading decisionsLeverage NLP and deep learning to extract tradeable signals from market and alternative dataBook DescriptionThe 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 learnLeverage market, fundamental, and alternative text and image dataResearch and evaluate alpha factors using statistics, Alphalens, and SHAP valuesImplement machine learning techniques to solve investment and trading problemsBacktest and evaluate trading strategies based on machine learning using Zipline and BacktraderOptimize portfolio risk and performance analysis using pandas, NumPy, and pyfolioCreate a pairs trading strategy based on cointegration for US equities and ETFsTrain a gradient boosting model to predict intraday returns using AlgoSeek's high-quality trades and quotes dataWho this book is forIf 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 ContentsMachine Learning for Trading – From Idea to ExecutionMarket and Fundamental Data – Sources and TechniquesAlternative Data for Finance – Categories and Use CasesFinancial Feature Engineering – How to Research Alpha FactorsPortfolio Optimization and Performance EvaluationThe Machine Learning ProcessLinear Models – From Risk Factors to Return ForecastsThe ML4T Workflow – From Model to Strategy Backtesting(N.B. Please use the Look Inside option to see further chapters)

820 pages, Paperback

Published July 31, 2020

Loading...
Loading...

About the author

Stefan Jansen

11 books9 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
25 (37%)
4 stars
25 (37%)
3 stars
13 (19%)
2 stars
3 (4%)
1 star
1 (1%)
Displaying 1 - 7 of 7 reviews
Profile Image for Ayush.
23 reviews
April 20, 2021
This is the most comprehensive (800+ pages) and up to date book on Quant I've read. It combines the best elements of Prado, Chan and Moore's book and combines with latest in ML world as well. It is full of practical advise with clean code that you can instantly use in python on latest libraries which is big help. It also comes with set of notebooks that you can run on your own and learn by doing.

Best book hands down!
Profile Image for Richard.
187 reviews
February 18, 2022
Introduction
Financial markets generate enormous quantities of data, ranging from stock prices and company financial statements to economic indicators, news articles, social media activity and satellite imagery. Extracting meaningful information from these diverse sources and converting it into profitable trading decisions is one of the most challenging problems in modern quantitative finance. In Machine Learning for Algorithmic Trading, Stefan Jansen provides a comprehensive, practical guide to addressing this challenge. Rather than concentrating exclusively on individual machine learning algorithms, the book develops an end-to-end framework for designing, implementing, evaluating and refining systematic trading strategies using Python. The book's central philosophy is that successful algorithmic trading requires much more than developing a predictive model. It involves collecting reliable data, engineering meaningful features, selecting appropriate algorithms, conducting rigorous backtests, managing portfolio risk and ultimately translating research into executable trading decisions. Jansen brings together concepts from machine learning, statistics, financial economics, natural language processing and deep learning to demonstrate how these disciplines can be applied to real-world investment problems. The result is an ambitious and technically detailed textbook that provides a valuable bridge between theoretical machine learning and practical quantitative investment research.

1. Building the Foundations: Financial Data and Alternative Information
One of the book's most important contributions is its emphasis on data engineering. Machine learning models are only as useful as the information on which they are trained, and financial data presents several distinctive challenges. Jansen explores how to access and process market data, fundamental information and alternative data through APIs, web scraping and other automated techniques. The discussion covers traditional financial information, including historical prices, trading volumes, company financial statements and macroeconomic indicators. It then moves into alternative data, which has become increasingly important in quantitative investment research.

Particularly interesting examples include extracting information from:
Corporate earnings announcements and conference call transcripts.
SEC filings and company financial disclosures.
Financial news and social media.
Satellite imagery and geolocation information.
Consumer behaviour and business activity.

The underlying idea is that useful information about future market movements may exist outside conventional financial datasets. For example, satellite imagery of commercial parking facilities could potentially provide insights into retail activity, while sentiment extracted from earnings calls might help identify changes in management expectations. Jansen also explains financial feature engineering and the development of alpha factors: measurable characteristics that may help predict future asset returns. The use of statistical techniques, Alphalens and model interpretation tools such as SHAP helps readers understand how to evaluate the usefulness and contribution of individual features. This section is particularly valuable because it demonstrates that developing a successful trading strategy begins with asking the right questions about data, rather than immediately selecting a sophisticated machine learning algorithm.

2. Machine Learning and Statistical Methods for Financial Prediction

The second major theme is the application of conventional machine learning techniques to financial prediction. Jansen introduces supervised and unsupervised learning methods, explaining how different algorithms can be used to identify patterns in market data and generate investment signals.

The supervised learning discussion includes:
Linear and logistic regression.
Decision trees and random forests.
Gradient boosting techniques.
XGBoost and LightGBM.
Other ensemble learning approaches.

These algorithms are applied to problems such as forecasting asset returns, identifying market patterns, ranking investment opportunities and constructing portfolios. An especially useful aspect of the book is its treatment of time-series analysis and statistical arbitrage. Financial markets are not ordinary datasets. Observations are temporally dependent, market conditions change, and relationships between variables can be unstable. Consequently, applying machine learning without accounting for these characteristics can produce misleading results. Jansen explores volatility forecasting, Bayesian approaches, cointegration and pairs trading. The discussion of pairs trading is particularly interesting. By identifying two assets whose prices exhibit a historically stable relationship, a quantitative strategy can attempt to exploit temporary deviations from their long-term relationship. The book also examines unsupervised learning, including clustering and dimensionality reduction, for discovering underlying risk factors and improving asset allocation. These techniques demonstrate that machine learning is not limited to predicting whether a stock price will rise or fall. It can also help investors understand the structure of financial markets and identify relationships that may not be immediately apparent.

3. Natural Language Processing: Extracting Signals from Financial Text
One of the most fascinating aspects of modern quantitative finance is the ability to process information that is not naturally expressed in numerical form. Financial news, corporate announcements, earnings calls and regulatory filings contain information that may influence investor expectations and market prices. Jansen dedicates considerable attention to natural language processing (NLP), demonstrating how textual information can be transformed into quantitative features suitable for machine learning models. The book introduces tools such as spaCy and Gensim and explores techniques including:
Text classification and sentiment analysis.
Topic modelling.
Word embeddings.
Semantic analysis of financial documents.
Extracting information from earnings calls and SEC filings.

For example, a sentiment analysis model can attempt to classify financial news as positive, negative or neutral. Topic modelling can identify recurring themes in large collections of financial articles, while word embeddings can capture relationships between words and concepts. These techniques provide an opportunity to incorporate qualitative information into systematic investment strategies. The discussion is particularly relevant because financial markets frequently respond to information before its implications become fully reflected in conventional financial indicators. However, extracting reliable trading signals from text is challenging. Language is context-dependent, financial terminology can be ambiguous, and the market's interpretation of apparently positive or negative news may depend on expectations that are already reflected in prices. The book provides a useful practical foundation for understanding these challenges.

4. Deep Learning: Discovering Complex Patterns in Financial Markets
Jansen moves beyond conventional machine learning to explore deep learning architectures and their potential applications in financial prediction.

This section introduces neural network techniques, including:
Convolutional Neural Networks (CNNs): These architectures can identify patterns in structured representations of financial time series and other data, including satellite imagery.
Recurrent Neural Networks (RNNs): Designed to process sequential information, these models are particularly relevant to financial time series, where the order and historical context of observations matter.
Autoencoders: These networks learn compressed representations of complex datasets and can be applied to dimensionality reduction, latent risk factors and asset pricing.
The book also explores generative adversarial networks (GANs), including their application to synthetic financial time-series data.

The generation of synthetic data is an interesting research area because historical financial observations are limited, and financial markets rarely repeat precisely the same conditions. Generative models offer a way to investigate alternative scenarios and expand the datasets available for experimentation. However, synthetic financial data must be treated carefully: generating realistic-looking observations does not necessarily mean that the resulting data reproduces the statistical properties or extreme events of actual markets. The practical implementation of these techniques using TensorFlow and other Python libraries makes this section particularly useful for readers interested in applying deep learning to quantitative finance.

5. Reinforcement Learning: Teaching Machines to Trade
Perhaps the most ambitious part of the book is its introduction to reinforcement learning. Unlike supervised learning, where a model learns from labelled historical observations, reinforcement learning involves an agent interacting with an environment and learning through rewards and penalties. In an algorithmic trading context, an agent can observe market conditions, select actions and receive feedback based on the consequences of its decisions. Jansen demonstrates how reinforcement learning can be applied to the development of trading agents using environments such as OpenAI Gym and deep Q-learning techniques. This opens up several interesting possibilities:
Learning trading and execution policies.
Optimising decisions under changing market conditions.
Balancing risk and potential returns.
Developing strategies that adapt through interaction with simulated environments.
The concept is intellectually appealing because it moves beyond predicting market movements towards learning how to make decisions.

Nevertheless, reinforcement learning in financial markets presents substantial difficulties. An agent trained in a simulated environment may perform poorly when exposed to real markets, where transaction costs, liquidity constraints, market impact and changing market regimes complicate the decision-making process. Jansen's treatment provides a valuable introduction to this emerging field while illustrating its potential and practical challenges.

6. Backtesting, Portfolio Optimisation and Performance Evaluation
Developing a predictive model is only one stage in building a systematic trading strategy. Equally important is determining whether the strategy would have generated meaningful returns under realistic market conditions. Jansen recognises this and places considerable emphasis on strategy backtesting and portfolio construction. The book introduces tools such as Zipline and Backtrader for testing trading strategies against historical data. An important lesson is the danger of backtesting errors. Two particularly significant problems are:
Look-ahead bias: Using information that would not have been available at the time a trading decision was supposedly made.
Survivorship bias: Constructing historical datasets using only companies that survived until the present, thereby excluding businesses that failed or disappeared.
The book also addresses the broader problem of overfitting. A strategy may appear exceptionally profitable when tested against historical data simply because its parameters have been optimised to capture historical noise rather than persistent market behaviour.

This is one of the most important lessons for anyone developing algorithmic trading systems: a convincing backtest does not automatically imply a viable trading strategy. The portfolio optimisation material is equally valuable. Jansen explores established approaches such as:
Mean-variance optimisation.
Risk-based portfolio allocation.
The Black-Litterman framework.
The Kelly Criterion.
Performance measurement using the Sharpe ratio and drawdown analysis.
The use of tools such as pyfolio provides a practical means of evaluating portfolio performance and understanding the relationship between returns and risk.

This section reinforces the idea that successful systematic investing is not simply about identifying assets with attractive predicted returns. It also requires controlling exposure, managing uncertainty and understanding how individual positions interact within a portfolio.

7. Strengths and Limitations
The greatest strength of Machine Learning for Algorithmic Trading is its breadth and practical orientation. Rather than treating machine learning, financial economics and portfolio management as separate subjects, Jansen integrates them into a coherent research workflow. The extensive use of Python examples is particularly helpful. Readers are encouraged to implement algorithms, explore datasets, experiment with features and evaluate their results rather than simply study mathematical descriptions. Another major strength is the emphasis on the complete investment process. Data acquisition, feature engineering, model development, backtesting and portfolio optimisation are treated as interconnected activities. The book also deserves credit for introducing relatively advanced topics, including alternative data, NLP, deep learning, synthetic data generation and reinforcement learning. However, its scope also creates some limitations. First, the technical learning curve is substantial. Readers need a reasonable understanding of Python, statistics, probability and machine learning to benefit fully from the material. It is not an ideal starting point for someone with no programming or quantitative background. Second, the book is extensive and demanding. At approximately 820 pages, it is better approached as a reference textbook and practical learning resource than as a book to read quickly from beginning to end. Third, the technological landscape evolves rapidly. The second edition was published in 2020, and some of its libraries, software interfaces and computational approaches may require updating or adaptation. Readers should consult the accompanying code repository and current documentation when implementing the examples. Finally, the book does not provide a guaranteed route to profitable trading. Financial markets are competitive, unpredictable and subject to structural changes. Machine learning can identify statistical relationships, but those relationships may disappear, weaken or fail to survive transaction costs and execution constraints. This distinction is important: the book teaches readers how to research and develop systematic strategies, not how to guarantee investment returns.

Conclusion: A Comprehensive Guide to Modern Quantitative Trading
Machine Learning for Algorithmic Trading is an ambitious and technically rich exploration of how machine learning can transform the way financial markets are analysed and traded. Stefan Jansen successfully demonstrates that building an algorithmic trading strategy involves much more than training a model to forecast stock prices. It requires an integrated understanding of financial data, statistical modelling, feature engineering, portfolio construction, risk management and the practical mechanics of trading. The book's greatest contribution is its end-to-end perspective. It takes the reader from sourcing financial information and discovering predictive signals to developing machine learning models, testing investment strategies and evaluating portfolio performance. Its treatment of alternative data, natural language processing, deep learning and reinforcement learning is particularly valuable because these areas illustrate how the boundaries of quantitative investment research are expanding. Perhaps the most important lesson is that sophisticated algorithms alone do not create successful trading systems. Sound research methodology, reliable data, careful validation and disciplined risk management are equally important. Although some of the software examples inevitably reflect the technological environment of its publication date, the underlying principles remain highly relevant. For anyone interested in understanding how artificial intelligence, machine learning and quantitative finance intersect, this book provides an exceptionally comprehensive practical foundation.

Overall verdict: An excellent, hands-on reference for aspiring quantitative researchers, data scientists and algorithmic traders. Challenging but rewarding, it offers a substantial education in the process of transforming financial data into systematic investment strategies. Its greatest value lies not in promising profitable algorithms, but in teaching readers how to research, develop, test and critically evaluate them.
Profile Image for Anthony Tremblay.
3 reviews1 follower
January 1, 2025
Very insightful (and up to date) ideas on how to build ML-based market neutral equity strategies. Loved how feature engineering is presented.

Profile Image for Ranjan R. Lamichhane.
169 reviews6 followers
January 6, 2026
It's a decent book, however this book doesn't seem comprehensive enough and also is kind of awkward to follow linearly. The book also seems repetitive and redundant at times, and tends to focus on insiginificant things every now and then.
1 review
July 22, 2026
More like lectures notes rather than a coherent book. Surface level content.
Profile Image for Josua Naiborhu.
99 reviews6 followers
June 13, 2025
I really enjoy every chapter alongside the hands-on approaches for any kind of utilization of ML for trading and also the feature engineering in trading context.
Displaying 1 - 7 of 7 reviews