Machine Learning for Trading — 3rd Edition
A book companion repository with code, case studies and libraries for building, testing and deploying machine learning-based trading strategies, from data sourcing through live execution.
This repository holds the code for the third edition of "Machine Learning for Trading" by Stefan Jansen, organized around one workflow: developing a research idea into a strategy that can run, and keep running, in a live market. Nine case studies walk through the book's 27 chapters, from raw data through features, models, backtests, costs and risk to deployment.
The new edition adds generative AI and autonomous agents, bringing retrieval-augmented generation, knowledge graphs and multi-agent systems into financial research, and widens the model toolkit with gradient boosting, deep time-series architectures, and tabular and latent-factor models. New chapters cover transaction costs, risk management, portfolio construction and strategy synthesis.
A companion website provides primers, agent skills and production Python libraries, and a production track covers live trading through brokers such as Interactive Brokers and Alpaca, along with MLOps practices such as drift detection and safe rollout.