---
title: "machine-learning-for-trading"
type: "tool"
slug: "stefan-jansen-machine-learning-for-trading"
canonical_url: "https://www.graphcanon.com/tools/stefan-jansen-machine-learning-for-trading"
github_url: "https://github.com/stefan-jansen/machine-learning-for-trading"
homepage_url: "https://ml4trading.io"
stars: 19576
forks: 5362
primary_language: "Jupyter Notebook"
license: "MIT"
categories: ["data-retrieval", "ai-agents", "model-training"]
tags: ["data-science", "deep-learning", "backtesting", "artificial-intelligence", "large-language-models", "algorithmic-trading", "finance", "investment-strategies"]
updated_at: "2026-07-07T18:27:12.490011+00:00"
---

# machine-learning-for-trading

> Code repository for Machine Learning for Trading, focusing on developing and deploying trading strategies using ML techniques.

This repository is associated with the book 'Machine Learning for Trading' (3rd Edition) by Stefan Jansen. It includes code snippets and projects related to algorithmic trading, data science, deep learning, and reinforcement learning in quantitative finance contexts. Additionally, it highlights applications of generative AI and autonomous agents.

## Facts

- Repository: https://github.com/stefan-jansen/machine-learning-for-trading
- Homepage: https://ml4trading.io
- Stars: 19,576 · Forks: 5,362 · Open issues: 1 · Watchers: 445
- Primary language: Jupyter Notebook
- License: MIT
- Last pushed: 2026-07-07T02:57:59+00:00

## Categories

- [Data & Retrieval](/categories/data-retrieval.md)
- [AI Agents](/categories/ai-agents.md)
- [Model Training](/categories/model-training.md)

## Tags

data-science, deep-learning, backtesting, artificial-intelligence, large-language-models, algorithmic-trading, finance, investment-strategies

## Related tools

- [ECC](/tools/affaan-m-ecc.md) - The agent harness performance optimization system (★ 226,962)
- [hermes-agent](/tools/nousresearch-hermes-agent.md) - The self-improving AI agent built by Nous Research (★ 210,880)
- [AutoGPT](/tools/significant-gravitas-autogpt.md) - AutoGPT: Build, Deploy, and Run AI Agents (★ 185,417)
- [ollama](/tools/ollama-ollama.md) - Get up and running with Kimi-K2.6, GLM-5.1, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models. (★ 175,659)
- [transformers](/tools/huggingface-transformers.md) - 🤗 Transformers: the model-definition framework for state-of-the-art machine learning models (★ 162,347)
- [langflow](/tools/langflow-ai-langflow.md) - Langflow is a powerful platform for building and deploying AI-powered agents and workflows. (★ 151,298)
- [dify](/tools/langgenius-dify.md) - Production-ready platform for agentic workflow development (★ 148,070)
- [firecrawl](/tools/firecrawl-firecrawl.md) - The API to search, scrape, and interact with the web at scale. (★ 147,117)

## README (excerpt)

```text
# Machine Learning for Trading — 3rd Edition

**Build, test, and deploy ML-driven trading strategies — from data sourcing to live execution.**

This repository hosts the code for [*Machine Learning for Trading, 3rd Edition*](https://amzn.to/4eigy2F)
by [Stefan Jansen](https://www.linkedin.com/in/applied-ai/) — a ground-up
rebuild, organized around one end-to-end workflow: how you define a research idea and develop it iteratively into a
strategy you can actually run, and keep running, in a live market.

- [Nine case studies](https://www.ml4trading.io/case-studies/) illustrate the workflow throughout the 27 chapters of the
  book, from raw data through features, models, backtests, costs, and risk to deployment.
- **Generative AI** and **autonomous agents** are new to this edition and cut across that workflow, bringing
  retrieval-augmented generation, knowledge graphs, and multi-agent systems to financial research.
- The [companion website](https://ml4trading.io) features [112 primers](https://ml4trading.io/primer/),
  [56 agent skills](https://ml4trading.io/skills/),
  and [six production Python libraries](https://ml4trading.io/libraries/)
  that facilitate substantial parts of the workflow.

<p align="center">
  <a href="https://amzn.to/4eigy2F"><img src="assets/cover.png" width="45%" alt="Machine Learning for Trading, 3rd Edition"></a>
</p>

## 🎓 New: Live Courses & Lightning Lessons

For the first time, the third edition comes with a **live cohort course**, hands-on **workshops**, and free
**lightning lessons** taught by Stefan on [Maven](https://maven.com/stefan-jansen) — full schedule on the
[courses page](https://ml4trading.io/courses/).

- **▶ [Machine Learning for Trading: From Research to Production](https://maven.com/stefan-jansen/research-to-production)**
  — the flagship live cohort course: take a research idea all the way to a deployed, monitored strategy, working
  through the book's end-to-end workflow with direct feedback. **The first cohort starts Monday, July 6, 2026 —
  enrollment closes Friday, July 3.**
- **[Getting Stuff Done with Coding Agents](https://maven.com/p/8394ac/getting-stuff-done-with-coding-agents?utm_medium=ll_share_link&utm_source=instructor)**
  — a free lightning lesson on putting coding agents to work.
- **[Building Multi-Agent Forecasting Systems](https://maven.com/stefan-jansen/forecasting-agents)**
  — a hands-on workshop on engineering the forecasting-agent loop: building auditable, debate-driven multi-agent
  systems for financial research.

<p align="center">
  <a href="https://youtu.be/Ksxv9QVZSOo"><img src="assets/course-trailer.jpg" width="60%" alt="Watch the course overview: Machine Learning for Trading — From Research to Production"></a>
</p>

---

## What's New in the Third Edition

The whole book traces one path: from data infrastructure and strategy research, across an *evidence boundary* that
separates tuning from evaluation, to deployment and monitoring — with a feedback loop that retrains, pauses, or
retires a strategy as its edge decays.

<p align="center">
  <img src="assets/workflow.png" width="90%" alt="The ML4T workflow: data infrastructure and strategy research, an evidence boundary separating tuning from evaluation, and deployment with a retrain/pause/retire feedback loop">
</p>

Where earlier editions moved technique by technique, the third edition runs that one process end to end — and adds
substantial new material:

- **A wider model toolkit**: from gradient boosting (XGBoost, LightGBM, CatBoost) to deep time-series architectures
  (PatchTST, iTransformer, TSMixer, TCN, Mamba) and newer tabular and latent-factor models (TabPFN, TabM, conditional
  and supervised autoencoders).
- **Dedicated strategy-design chapters**: transaction costs and risk management are now full chapters, neither of
  which existed before, joining portfolio construction and strategy synthesis so a raw signal is carried through to a
  sized, cost- and risk-aware portfolio.
- **A full produc
```

---

**Machine-readable endpoints**

- JSON: [`/api/graphcanon/tools/stefan-jansen-machine-learning-for-trading`](/api/graphcanon/tools/stefan-jansen-machine-learning-for-trading)
- LLM index: [/llms.txt](/llms.txt)
- Full corpus: [/llms-full.txt](/llms-full.txt)

_GraphCanon - The knowledge graph for AI development. https://www.graphcanon.com/_
