{"data":{"slug":"stefan-jansen-machine-learning-for-trading","name":"machine-learning-for-trading","tagline":"Code for Machine Learning in Trading","github_url":"https://github.com/stefan-jansen/machine-learning-for-trading","owner":"stefan-jansen","repo":"machine-learning-for-trading","owner_avatar_url":"https://avatars.githubusercontent.com/u/4275885?v=4","primary_language":"Jupyter Notebook","stars":20480,"forks":5521,"topics":["algorithmic-trading","artificial-intelligence","backtesting","data-science","deep-learning","finance","investment","investment-strategies","large-language-models","machine-learning","ml4t-workflow","polars","quantitative-finance","reinforcement-learning","synthetic-data","trading","trading-agent","trading-strategies"],"archived":false,"github_pushed_at":"2026-08-16T12:45:53+00:00","maintenance_label":"Very active","stars_delta_30d":549,"url":"https://www.graphcanon.com/tools/stefan-jansen-machine-learning-for-trading","markdown_url":"https://www.graphcanon.com/tools/stefan-jansen-machine-learning-for-trading.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/stefan-jansen-machine-learning-for-trading","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=stefan-jansen-machine-learning-for-trading","description":"Code for Machine Learning for Trading, 3rd edition — from data sourcing to live execution.","homepage_url":"https://ml4trading.io","license":"MIT","open_issues":5,"watchers":409,"ai_summary":"Repository contains code for implementing machine learning models and strategies for financial trading, including data sourcing, backtesting, and live execution.","readme_excerpt":"## Quick Start\n\n**New here? Read these three, in order:**\n\n1. **[What this repository is, and what it is not](docs/what-this-is.md)** - what you can reproduce\n   with one command, what a configuration change buys you, what needs real compute or licensed data,\n   and what is not promised. Five minutes, and it sets expectations before you install anything.\n2. **[Installation](docs/installation.md)** - Linux, Windows WSL2, macOS, Docker, and GPU.\n3. **[Running notebooks](docs/running-notebooks.md)** - the case-study pipeline, the run log, and how\n   to experiment without disturbing the downloaded results.\n\nThese commands are typed into a terminal on your own computer, not into GitHub. New to the command\nline? Start with **[Before You Begin](docs/installation.md#before-you-begin)**.\n\nRun everything **from the repository root**. Clone and set up with Docker or a local `uv` environment:\n\n```bash\ngit clone https://github.com/stefan-jansen/machine-learning-for-trading.git\ncd machine-learning-for-trading\ncp .env.example .env\n\ndocker compose pull ml4t # Option A — Docker (recommended)\n```\n\nOption B is a local `uv` environment, on **macOS, Linux, or inside WSL2**. Install `uv` with its\nown installer rather than with `pip`, which is missing or refuses to install on most current\nsystems:\n\n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\nsource $HOME/.local/bin/env   # the installer's own line; puts uv on PATH here and now\nuv sync\n```\n\nOption B compiles several dependencies from source, `scikit-learn` among them, so it needs a\n**C/C++ compiler and the Python headers**: on Ubuntu, Debian and WSL2\n`sudo apt install build-essential python3-dev`, on macOS `xcode-select --install`. Docker\ncarries its own and needs none of this.\n\n**macOS readers:** on **Apple Silicon** take Option B. It is the path walked on real hardware\nbefore each release, and it needs only the Xcode command-line tools for the packages that build\nfrom source. Docker there is worth its disk only for the twelve `ml4t-py312` notebooks, which have no\narm64 build and ship pre-executed, and for Chapter 2's containerized database benchmarks. On an **Intel Mac** take Option A: PyTorch publishes\nno macOS x86_64 wheel, so Option B cannot work there.\n\n**Windows readers:** both options run inside WSL2, not in PowerShell. Run\n`wsl --install -d Ubuntu` from an Administrator PowerShell, restart, run it a second time\n(the first run usually installs the WSL runtime without a distribution), and then follow the\nLinux instructions in the Ubuntu terminal. Installing into Windows Python is not supported and does\nnot work — `scikit-learn` has no Windows wheel for this Python version and its source build\nfails. The [installation guide](docs/installation.md) has the full WSL2 walkthrough.\n\nBudget about **16 GB** for Option B (11 GB environment, 4 GB free datasets, 0.9 GB of git\nhistory) and about 12 minutes for the data.\n\nSee the **[installation guide](docs/installation.md)** for platform-specific setup and GPU\ninstructions. Intel Macs are Docker-only: PyTorch no longer publishes macOS x86_64 wheels, so the\nlocal `uv` path cannot resolve there.\n\n**Download data.** Most notebooks need datasets; start with the free ones (no API keys):\n\n```bash\nuv run python data/download_all.py --free-only\n```\n\nDocker readers run this in the Jupyter Lab terminal (**File → New → Terminal**) as\n`python data/download_all.py --free-only` — there is no host Python on the Docker path.\n\nThat command fetches seven datasets and takes about **4 GB** and twelve minutes, almost all of it\nthe firm-characteristics panel, first needed in Ch04. To start in about 75 MB, leave it out and\nfetch it when a chapter asks for it:\n\n```bash\nuv run python data/download_all.py --free-only --skip-firm-characteristics\n```\n\nThe **[data guide](data/README.md)** documents every dataset, API-key setup, the loaders, and\nstorage tiers.\n\n**(Optional) pre-computed results.** To explore the nine released Ch11-20 case studies without\nretraining, downlo","github_created_at":"2018-05-09T12:33:08+00:00","created_at":"2026-07-07T17:33:21.585813+00:00","updated_at":"2026-08-17T00:02:06.214931+00:00","categories":[{"slug":"ai-agents","name":"AI Agents","url":"https://www.graphcanon.com/categories/ai-agents","markdown_url":"https://www.graphcanon.com/categories/ai-agents.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/ai-agents"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"algorithmic-trading","name":"algorithmic-trading"},{"slug":"artificial-intelligence","name":"artificial-intelligence"},{"slug":"backtesting","name":"backtesting"},{"slug":"deep-learning","name":"deep-learning"},{"slug":"reinforcement-learning","name":"reinforcement-learning"},{"slug":"trading-agent","name":"trading-agent"}],"trust":{"provenance":{"is_fork":false,"github_id":132754148,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-17T00:02:05.438Z","maintenance":{"label":"Very active","score":96,"methodology":"github_public_v1","releases_90d":4,"days_since_push":0,"last_release_at":"2026-07-24T08:08:45Z","stars_delta_30d":549,"open_issues_delta_30d":3},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T11:00:44.449Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-08-17T00:02:05.879Z"},"deploy":{"source":"dockerfile:docker-compose.yml","self_host":true,"observed_at":"2026-08-17T00:02:05.879Z","managed_saas":false},"languages":{"value":["jupyter notebook","python"],"source":"github.language+pyproject.toml","observed_at":"2026-08-17T00:02:05.879Z"},"has_docker":{"value":true,"source":"dockerfile:docker-compose.yml","observed_at":"2026-08-17T00:02:05.879Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-08-17T00:02:05.879Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["- When you require a comprehensive solution, including data sourcing and live execution, all in one place.","- Ideal for users who prefer the Jupyter Notebook environment for developing trading strategies.","- Suitable if your project involves chapters where specialized Docker images (`ml4t-gpu`, `ml4t-py312`) can be leveraged for GPU acceleration or specific Python version features."],"when_not_to_use":["- Not recommended if you are not interested in integrating live execution and prefer a theoretical approach to machine learning.","- Unsuitable if your system setup does not support the use of Docker, especially on environments where setting up WSL2 before installing Docker is prohibitive or problematic.","- If your trading strategy development workflow can be executed without Python 3.12 or does not require specialized deep-learning notebooks, opting out might avoid complications from using `ml4t-py312"],"source":"enrich:decision_facts","observed_at":"2026-07-11T14:19:52.071Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"Decision-Critical Facts for 'machine-learning-for-trading':"}]}}