# stefan-jansen/machine-learning-for-trading

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

Repository: https://github.com/stefan-jansen/machine-learning-for-trading
Canonical: https://ross.abutalabs.com/products/machine-learning-for-trading
Homepage: https://ml4trading.io
Language: Jupyter Notebook
License: MIT
License Family: permissive
Topics: machine-learning, trading, investment, finance, data-science, investment-strategies, artificial-intelligence, trading-strategies, deep-learning, synthetic-data, ml4t-workflow, trading-agent, algorithmic-trading, backtesting, large-language-models, polars, quantitative-finance, reinforcement-learning
Last push: 2026-08-26T03:44:31+00:00

## Health v2 (maintenance only)
Score: 86/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 99, release rhythm 62, longevity 100
- inputs: {"age_days": 3038, "days_push": 7, "days_rel": 40, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 20669, forks 5564 (observed 2026-08-28T04:11:30.311696+00:00)

## What it is
Companion code repository for the book 'Machine Learning for Trading, 3rd Edition' by Stefan Jansen, containing 446+ Jupyter notebooks across 27 chapters and 9 case studies covering the full ML-for-trading workflow from data sourcing to live execution. It is paired with six production Python libraries (ml4t-data, ml4t-engineer, ml4t-models, ml4t-diagnostic, ml4t-backtest, ml4t-live) and covers gradient boosting, deep time-series models, reinforcement learning, RAG, and autonomous trading agents.

## Use cases
- learn machine learning for algorithmic trading end to end
- backtest ML-driven trading strategies in Python
- fetch and store market data from multiple providers
- engineer financial features and triple-barrier labels without leakage
- validate trading signals with deflated Sharpe ratio
- run reinforcement learning trading agents
- apply LLMs and RAG to financial research
- deploy a strategy to a live broker like Alpaca or Interactive Brokers

## When to choose
- you are studying the ML4T book and want runnable code for every chapter
- you want a complete reference workflow from raw market data to live execution
- you need worked examples of backtesting, feature engineering, and strategy validation
- you want to learn modern additions like GenAI, RAG, and multi-agent systems applied to trading

## When to avoid
- you need a single production trading system rather than educational notebooks
- you want a no-code or GUI trading platform
- you are not comfortable with Python, notebooks, and quantitative finance concepts
- you need guaranteed profitable strategies - this teaches methodology, not signals

## Facets
- artifact type: learning-resource
- maturity: active
- function: machine-learning, deep-learning, reinforcement-learning, rag, agent-framework, data-science, etl, trading, benchmarking, data-visualization
- domain: machine-learning, fintech, data-science, artificial-intelligence, large-language-models, reinforcement-learning, tutorials
- platform: python, cross-platform, windows
- tags: quantitative-finance, algorithmic-trading, backtesting, jupyter-notebooks, book-companion, trading-strategies, synthetic-data, polars, ml4t, market-data, linux, macos

## Member repositories
- stefan-jansen/machine-learning-for-trading (main) score 86

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:11:30.311696+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:58:34.341177+00:00, confidence not recorded.
  - readme: https://github.com/stefan-jansen/machine-learning-for-trading (fetched 2026-08-28T04:11:30.311696+00:00, sha 74f7ac4ed835)
  - homepage: https://ml4trading.io (fetched 2026-08-29T07:57:28.078698+00:00, sha d15a78ae5614)
  - site_page: https://ml4trading.io/docs/data (fetched 2026-08-29T07:57:28.086939+00:00, sha 64029425c562)
  - site_page: https://ml4trading.io/docs/engineer (fetched 2026-08-29T07:57:28.089133+00:00, sha ee16805e65d7)
  - site_page: https://ml4trading.io/docs/models (fetched 2026-08-29T07:57:28.091406+00:00, sha d93352c3e5da)
  - site_page: https://ml4trading.io/docs/diagnostic (fetched 2026-08-29T07:57:28.093599+00:00, sha 6cbc73210229)
  - site_page: https://ml4trading.io/docs/backtest (fetched 2026-08-29T07:57:28.095582+00:00, sha 710609c42e37)
  - site_page: https://ml4trading.io/docs/live (fetched 2026-08-29T07:57:28.097725+00:00, sha fba557964e16)
  - site_page: https://ml4trading.io/libraries (fetched 2026-08-29T07:57:28.082008+00:00, sha 27ca4bc5b41c)
  - site_page: https://ml4trading.io/chapters (fetched 2026-08-29T07:57:28.084548+00:00, sha fbe262933ff8)
- Data as of 2026-08-30T08:39:29.467469+00:00.
