Book Guide¶
This map connects selected Machine Learning for Trading, Third Edition companion notebooks to the library workflows that implement the corresponding backtest operations. For the library task guide, start at the User Guide. The tutorials work with bundled synthetic data, so the book and its datasets are optional. All book links below point to one checked companion revision.
Each notebook description distinguishes direct library examples from
research that supplies inputs or interprets outputs. A case study that uses a
book-specific helper is labeled as such; its helper and datasets are not part
of the installed ml4t-backtest package. Start with the linked library workflow
for a standalone example.
Chapters and workflows¶
| Book section and notebook | Role and learning task | Library workflow |
|---|---|---|
| Futures backtesting | Calls DataFeed and Engine. Prepare futures bars and contract specifications. |
Example data |
| 16.3 Vectorized and event-driven backtesting | Calls DataFeed and Engine. Run one strategy, reconcile fills and trades. |
First backtest |
| 16.3 Stateful strategies | Calls DataFeed and Engine. Carry realized state into later decisions. |
Risk and state |
| 16.3 Vectorized and event-driven backtesting | Calls Engine with controlled settings. Change one execution assumption at a time. |
Profiles and parity; Zipline migration |
| 16.5 Understanding performance metrics | Calls Engine and ml4t-diagnostic. Read returns and drawdowns. |
Result exports |
| Case-study LEAN parity | Reads retained comparison evidence. Interpret the bounded framework audit. | Profiles and parity |
| Portfolio performance analysis | Calls ml4t-diagnostic for downstream analysis. Analyze returns and drawdowns. |
Diagnostic handoff |
| 17.4 Defining Baseline Allocators | Teaches sizing from prediction uncertainty. Turn uncertainty into position sizes. | Accounts and constraints |
| 17.7 Comparing Allocator Performance | Calls Engine for allocator comparison. Compare allocators with matched inputs. |
Multi-asset rebalancing |
| Market impact scenarios | Teaches calibration from market panels. Assess size and capacity assumptions. | Market impact |
| 18.7 Transaction Cost Analysis and Model Validation | Teaches cost analysis from return series. Reconcile gross and net performance. | Costs and funding |
| 19.4 Drawdowns, Path Risk, and Time-to-Recovery | Uses library risk and trade types in a research comparison. Compare fixed and trailing exits. | Risk and state |
| 19.4 Drawdowns, Path Risk, and Time-to-Recovery | Calls ml4t.backtest.risk directly. Use library position rules and portfolio limits. |
Risk management |
The book develops research questions, statistical interpretation, and larger datasets. The library pages specify feed contracts, order timing, account behavior, executable examples, and result schemas. Follow the library reference when a notebook and the current API differ.
Case studies¶
| Companion example | Role and learning task | Library workflow |
|---|---|---|
| ETF backtest | Calls the book helper backtest_runner, which uses Engine. Weight targets from a prediction stream. |
Multi-asset rebalancing |
| CME futures backtest | Uses a book research workflow. Futures prediction selection and equal-weight baseline. | Example data |
| FX pairs backtest | Uses a book research workflow. FX prediction population and strategy grid. | Data Feed |
| Crypto perpetual funding | Uses a book research workflow. Funding and transaction-cost assumptions. | Costs and funding |
| ETF risk controls | Calls the book helper backtest_runner, which uses Engine. Position exits in a full strategy. |
Risk management |
Move from a notebook to a reusable run¶
- Start with the first backtest and the bundled price panels.
- Reproduce the notebook's decision and fill timing with the orders tutorial.
- Specify capital, share precision, and exposure limits with the account tutorial.
- Add costs or risk rules only after checking the baseline fills.
- Export the result and join it to the original timestamps with the result tutorial.
The API reference gives current signatures for each step.