machine-learning-for-trading
stefan-jansen/machine-learning-for-trading
Code repository for Machine Learning for Trading, focusing on developing and deploying trading strategies using ML techniques.
Overview
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.
Categories
Tags
Similar tools
ECC
affaan-m/ECC
The agent harness performance optimization system
hermes-agent
NousResearch/hermes-agent
The self-improving AI agent built by Nous Research
AutoGPT
Significant-Gravitas/AutoGPT
AutoGPT: Build, Deploy, and Run AI Agents
ollama
ollama/ollama
Get up and running with Kimi-K2.6, GLM-5.1, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
transformers
huggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models
langflow
langflow-ai/langflow
Langflow is a powerful platform for building and deploying AI-powered agents and workflows.
Install
git clone https://github.com/stefan-jansen/machine-learning-for-tradingREADME
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 by Stefan Jansen — 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 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 features 112 primers, 56 agent skills, and six production Python libraries that facilitate substantial parts of the workflow.
🎓 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 — full schedule on the courses page.
- ▶ Machine Learning for Trading: From 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 — a free lightning lesson on putting coding agents to work.
- Building Multi-Agent Forecasting Systems — a hands-on workshop on engineering the forecasting-agent loop: building auditable, debate-driven multi-agent systems for financial research.
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.
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