This guide maps ml4t-live to Machine Learning for Trading, Third Edition so you can move between
the library docs and the book materials without guessing which notebook or chapter matters.
- Start with the chapter map if you are reading the book.
- Start with the API map if you are coming from the library and want the matching notebook.
- Treat the listed code paths as the canonical references in the
ml4t/coderepository.
| Book material | What it teaches | ml4t-live connection |
|---|---|---|
| Chapter 16 strategy simulation | event-driven strategies and parity-friendly design | the strategy surface you carry into LiveEngine |
| Chapter 18 costs | execution frictions and turnover budgets | the live costs you compare against post-deployment |
| Chapter 19 risk management | kill switches, drawdowns, limits | LiveRiskConfig, SafeBroker, staged rollout |
| Chapter 25 live trading systems | brokers, feeds, operational parity, deployment | the core ml4t-live library surface |
| Chapter 26 MLOps governance | shadow mode, challenger rollout, circuit breakers | operational procedures around ml4t-live |
| Book path | Why it matters here |
|---|---|
code/16_strategy_simulation/06_framework_parity.py |
shows why keeping one strategy interface matters before live deployment |
code/25_live_trading/01_unified_framework_demo.py |
compares lifecycle traces, canonical intents, and signals across the two engines |
code/25_live_trading/03_ib_paper_trading_demo.py |
Interactive Brokers connectivity path |
code/25_live_trading/04_alpaca_paper_trading_demo.py |
Alpaca paper-trading path |
code/25_live_trading/05_alpaca_crypto_live_demo.py |
Alpaca crypto workflow |
code/25_live_trading/08_pipeline_verification.py |
parity checks between research and live workflows |
code/25_live_trading/09_crypto_funding_deployment_loop.py |
OKX funding-rate deployment loop |
code/25_live_trading/10_safety_risk_demo.py |
SafeBroker limits, shadow mode, and kill-switch behavior |
code/26_mlops_governance/03_safe_model_rollout.py |
shadow-mode and staged-promotion procedures around live deployment |
code/26_mlops_governance/04_circuit_breakers.py |
broader operational safety concepts that complement SafeBroker |
The clearest live-trading case-study bridge in the current book materials is the crypto perpetuals workflow:
| Case-study path | Library relevance |
|---|---|
code/case_studies/crypto_perps_funding/03_financial_features.py |
feature definitions that must stay consistent in live inference |
code/case_studies/crypto_perps_funding/14_backtest.py |
the validated backtest side of the strategy |
code/case_studies/crypto_perps_funding/17_risk_management.py |
portfolio and risk assumptions before deployment |
code/25_live_trading/okx_funding_rate_demo.py |
the live-style deployment bridge using exchange funding data |
| Book concept | Library API |
|---|---|
| portable decision logic | LiveEngine plus a lifecycle-v1 Strategy subclass using supported broker operations |
| sync strategy calling async infrastructure | ThreadSafeBrokerWrapper |
| explicit deployment risk policy | LiveRiskConfig |
| pre-trade enforcement and kill switch | SafeBroker |
| paper-like live validation without routing orders | execution_mode="shadow" with VirtualPortfolio |
| broker-specific execution path | IBBroker or AlpacaBroker |
| stable-supported live data source | OKXFundingFeed |
| experimental opt-in data source | AlpacaDataFeed, IBDataFeed, DataBentoFeed, CryptoFeed |
The notebooks are pedagogical and frequently expose mechanics directly. The library turns those same ideas into reusable interfaces:
- notebook orchestration becomes
LiveEngine - ad hoc risk checks become
SafeBroker - replay/live feed adapters become
DataFeedProtocolimplementations - deployment-stage bookkeeping becomes
RiskStateandVirtualPortfolio
If you are learning the stack end to end, the most efficient route is:
code/16_strategy_simulation/06_framework_parity.py- Backtest to Live
code/25_live_trading/01_unified_framework_demo.py- the broker page that matches your venue
code/25_live_trading/10_safety_risk_demo.py- Risk Controls