19K stars for a book repo that actually runs
Companion notebooks for an 800-page quantitative finance textbook, from linear regression to deep reinforcement learning trading agents.

What it does This repository houses over 150 Jupyter notebooks that implement the techniques from Stefan Jansen’s Machine Learning for Algorithmic Trading, 2nd edition. It covers the full pipeline: sourcing market, fundamental, and alternative data; engineering financial features; training models from linear regression through CNNs, RNNs, and GANs; and backtesting the resulting strategies. The book itself spans 23 chapters across 800+ pages, and the notebooks are meant to be reviewed alongside the text.
The interesting bit The second edition replicates several recent academic papers directly—turning time-series into images for CNN-based return prediction, using autoencoders for conditional risk factors, and generating synthetic training data with GANs. There’s also a customized version of the Zipline backtesting engine designed to ingest ML model predictions cleanly.
Key highlights
- Over 150 executed notebooks covering supervised, unsupervised, and reinforcement learning for trading
- Replications of peer-reviewed research from 2018–2019, including Sezer & Ozbahoglu’s CNN approach and Gu, Kelly & Xiu’s autoencoder asset pricing
- Expanded data sources beyond US equities: international stocks, ETFs, minute-frequency intraday data, SEC filings, earnings transcripts, and satellite imagery
- New appendix cataloging 100+ alpha factors
- Updated for pandas 1.0 and TensorFlow 2.2 (at time of writing)
Caveats
- The dependency stack is wide and version-sensitive; the README explicitly warns against installing everything at once and notes that the
ml4tconda channel is outdated - Some data sources require separate download and preprocessing steps
- Notebooks are supplementary material; the book itself is required for full context
Verdict Worth bookmarking if you’re a quant developer or data scientist crossing into finance, or a finance professional who wants executable implementations rather than hand-wavy strategy descriptions. Skip it if you’re looking for a lightweight, standalone trading framework—this is educational scaffolding, not a production system.
Frequently asked
- What is stefan-jansen/machine-learning-for-trading?
- Companion notebooks for an 800-page quantitative finance textbook, from linear regression to deep reinforcement learning trading agents.
- Is machine-learning-for-trading open source?
- Yes — stefan-jansen/machine-learning-for-trading is open source, released under the MIT license.
- What language is machine-learning-for-trading written in?
- stefan-jansen/machine-learning-for-trading is primarily written in Jupyter Notebook.
- How popular is machine-learning-for-trading?
- stefan-jansen/machine-learning-for-trading has 20k stars on GitHub and is currently cooling off.
- Where can I find machine-learning-for-trading?
- stefan-jansen/machine-learning-for-trading is on GitHub at https://github.com/stefan-jansen/machine-learning-for-trading.