Repolode
stefan-jansen

stefan-jansen/machine-learning-for-trading

Companion code for the book Machine Learning for Trading (3rd edition), covering an end-to-end workflow from data sourcing to live trading.

Stars
21,737
Forks
5,761
Open issues
1
Last commit
21 hours ago

Repolode describes open-source projects and does not give investment advice. Trading and investing can lose money: assess the risk yourself and follow the laws where you live before using this project.

What is it?

This repository contains the code for Machine Learning for Trading, 3rd Edition. It is organized as 27 chapters, each with Jupyter notebooks and a guide, plus nine case studies that run the same pipeline across different markets: ETFs, crypto perpetuals, intraday equities, options, FX, futures, and equity factor panels. The project focuses on turning a research idea into a costed, risk-aware strategy and then into a live trading system with monitoring.

The covered material spans financial data handling with Polars, feature engineering, models from linear baselines and gradient boosting to deep time-series architectures, reinforcement learning for execution and hedging, causal machine learning, and retrieval-augmented generation and agents applied to financial research. Backtesting, transaction-cost modeling, portfolio construction, and overfitting controls such as the Deflated Sharpe Ratio are treated as core topics.

Setup is provided through a Docker image or a local uv environment, with scripts to download the free datasets and verify the installation. Earlier material remains available on the second-edition branch.

Key features

  • 01Twenty-seven chapter directories with Jupytext notebooks and guides mapping sections to code
  • 02Nine case studies covering ETFs, crypto perpetuals, options, FX, futures, and equities
  • 03Gradient boosting, deep time-series, latent factor, and causal models with walk-forward validation
  • 04Backtesting, transaction-cost, and risk-management modules tied to a live-trading track
  • 05Docker and local uv setups with scripts to download free datasets and verify installation

Use cases

  • Learning an end-to-end quantitative research workflow from data to backtest
  • Reproducing or extending the nine case-study strategies on your own data
  • Comparing classic and deep learning models for return prediction under realistic costs
  • Exploring how to move a trading strategy into monitored live execution

In collections

Topics

FAQ

What is machine-learning-for-trading?
Companion code for the book Machine Learning for Trading (3rd edition), covering an end-to-end workflow from data sourcing to live trading. This repository contains the code for Machine Learning for Trading, 3rd Edition. It is organized as 27 chapters, each with Jupyter notebooks and a guide, plus nine case studies that run the same pipeline across different markets: ETFs, crypto perpetuals, intraday equities, options, FX, futures, and equity factor panels. The project focuses on turning a research idea into a costed, risk-aware strategy and then into a live trading system with monitoring.
Is machine-learning-for-trading free to use? What license does it have?
machine-learning-for-trading is open source under the MIT license. Check the license terms before using it in commercial products.
Is machine-learning-for-trading still maintained?
Actively maintained. The last commit to machine-learning-for-trading was on Nov 6, 2026.
What can I use machine-learning-for-trading for?
Learning an end-to-end quantitative research workflow from data to backtest Reproducing or extending the nine case-study strategies on your own data Comparing classic and deep learning models for return prediction under realistic costs Exploring how to move a trading strategy into monitored live execution
Where can I get machine-learning-for-trading?
The source code and installation instructions are on GitHub: https://github.com/stefan-jansen/machine-learning-for-trading

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects