# machine-learning-for-trading

> Code for Machine Learning for Trading, 3rd edition — from data sourcing to live execution

- Type: skill
- Field: Business & Finance
- Repository: https://github.com/stefan-jansen/machine-learning-for-trading
- GitHub stars: 22043
- Licence: MIT
- Language: Jupyter Notebook
- Last push: 2026-11-22
- Page: https://imutechz.in/agents/machine-learning-for-trading

## What it is
This is the companion code repository for the third edition of the book Machine Learning for Trading by Stefan Jansen. It walks through one end-to-end workflow, from data sourcing and strategy research to deployment and monitoring, across 27 chapters and nine case studies. It is aimed at readers who want to build, test, and run ML-driven trading strategies.

## Features
- 27 chapter guides plus nine case studies covering ETFs, crypto perpetuals, intraday equities, options, FX, futures, and equity factor panels
- Model toolkit spanning gradient boosting, deep time-series architectures, and tabular and latent-factor models
- Dedicated chapters on transaction costs, risk management, portfolio construction, and strategy synthesis
- Production track covering live trading systems, MLOps, drift detection, and safe rollout
- Generative AI, causal ML, reinforcement learning, and synthetic financial data material
- Data layer built on Polars, with reproducible Docker environments per chapter

## Best for
- Learning an end-to-end ML trading workflow
- Studying worked case studies across several asset classes
- Practising walk-forward validation and overfitting controls
- Exploring deployment and monitoring of trading strategies

## Pros
- Traces a single workflow from data infrastructure through deployment and monitoring
- Ships reproducible Docker environments so results repeat across machines
- Draws an explicit evidence boundary between tuning and evaluation
- Includes nine case studies run through the same pipeline

## Cons
- Requires Docker environments for reproducible results
- The second edition lives on a separate branch, not the default one

## Usage
```
git checkout second-edition
```

Tags: machine-learning, trading, quantitative-finance, backtesting, polars, docker, case-studies, mlops
