Skip to content

Machine Learning for Trading

Code companion to a book on building, testing, and running ML-driven trading strategies.

Stars
21.7k
Forks
5.7k
Licence
MIT
Language
Jupyter Notebook
Last update
7 days ago
Type
Learning resource

What it is

This repository holds the code for the third edition of the book Machine Learning for Trading by Stefan Jansen, with 27 chapters and nine case studies. It walks through one workflow: sourcing market data, researching strategy ideas, evaluating them with backtests, and deploying them to live markets. People use it to learn how machine learning is applied to financial data and to run the book's examples themselves.

  • Work through the chapter notebooks to see how a trading model is built step by step
  • Explore the nine case studies, such as ETF momentum, crypto funding-rate arbitrage, or FX carry
  • Download the release artifacts of market datasets to run the case studies without sourcing data yourself
  • Study how backtests, transaction costs, and risk overlays are combined in one pipeline

Great for

  • Readers of the Machine Learning for Trading book who want to run its code
  • Students learning applied machine learning on financial time series
  • Quantitative researchers who want a worked example of an end-to-end strategy workflow
  • Developers who are comfortable with Python and Jupyter notebooks

Not ideal for

  • People looking for a ready-made profitable trading strategy: the README presents code for learning and research, not a tested investment product
  • Complete beginners to Python or finance, since the material assumes working knowledge of both
  • Readers who want the second edition: the README says it lives on a separate branch
Step-by-step guide: how to use Machine Learning for TradingInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Clone and build from source

    You'll need: Git · Python (version not stated in the README excerpt) · Jupyter Notebook

    Clone the repository

    git clone https://github.com/stefan-jansen/machine-learning-for-trading
  2. 2

    Run it

    • Clone the repository and open the Quick start section of the README for setup details
    • Download the data artifacts from the latest release (v3.1.0-artifacts) as described in the README
    • Open a chapter notebook and run it top to bottom
    • Explore a case study folder once the chapter examples make sense
  3. 3

    Get the most out of it

    • Use the Docker environments mentioned in the README so results match across machines
    • Start with the chapter guides that match the case study you care about
    • Read the evidence and validation material, such as walk-forward cross-validation, alongside the code
    • Check the companion resources section for primers and the six supporting libraries

Downloads

Strengths

  • Covers the full path from data to live execution in one consistent workflow
  • Includes nine case studies across ETFs, futures, FX, options, crypto, and equities
  • Uses reproducible Docker environments for each chapter, per the README

Trade-offs

  • Focused on learning and research code; the README does not promise trading results
  • Requires setup of data files and environments before the notebooks run, which may take effort

How it compares

ProjectStarsTypeLevelUpdatedBest for
machine-learning-for-trading (this)21.7kLearning resourceintermediate7 days agoReaders of the Machine Learning for Trading book who want to run its code
FinRL17kLibraryintermediate12 days agoStudents learning how reinforcement learning is applied to financial markets
qlib49.9kLibraryadvanced7 days agoQuant researchers who want a structured ML workflow for stock data
mit-deep-learning10.5kLearning resourcebeginner2.8 years agoStudents following MIT deep learning courses
AI-Expert-Roadmap31.3kLearning resourcebeginner1.1 years agoBeginners who are unsure what to learn next in AI or data science
AI-For-Beginners70.5kLearning resourcebeginner13 days agoBeginners who want a structured, self-paced introduction to AI

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.