Introduction
"Every great magic trick consists of three parts, or acts. The first part is called 'The Pledge.' The magician shows you something ordinary. The second act is called 'The Turn.' The magician takes the ordinary something and makes it do something extraordinary. But you wouldn't clap yet. Because making something disappear isn't enough; you have to bring it back." — The Prestige (2006)
A quantitative finance pipeline has the same three-act structure — and its third act is the one most often skipped.
The Pledge is the data: returns, prices, fundamentals, alternative sources. Cleaned, audited, in the right form. This is the act every serious team gets right; it is also the act that takes the most time to set up and the one Chapter 3 is dedicated to.
The Turn is the model: forecast, allocate, infer latent state, learn a policy. This is the act textbooks cover well, and it is what Chapters 2 and 4 through 6 develop.
The Prestige is the operationalisation: the synthetic stress test that the policy survived, the agent that wraps the pipeline in a language interface, the audit log that lets a regulator reproduce the result. Most finance textbooks stop at the Turn and leave the Prestige to folklore. This book commits to all three acts — Chapters 7 through 9 finish what the earlier chapters set up — with the same notation, the same datasets, and the same code throughout.
The cost of this breadth is real. The benefit is that by the end of the book you can build, deploy, and defend a complete financial-AI pipeline, not just one well-trained model.
The pipeline in one line
Prediction → Decision → Dynamics → Automation → Synthesis.
Forecasts (Chapter 4) feed decisions (Chapter 5); decisions live inside dynamics (Chapter 6); LLM agents (Chapters 7–8) wrap the loop in natural-language interfaces; synthetic data (Chapter 10) closes the loop by stress-testing what has been learned.
This chapter has one section for each of those five pieces. Each section is short — the goal is to give you enough framing that the later chapters land cleanly, not to substitute for them.
How to read this book
The chapters are designed to be read in order, but each chapter index is self-contained so you can drop in to any topic and still see the plan. Three reading paths cover the most common goals:
- Modelling-first (recommended for newcomers). Chapter 2 → Chapter 6 → Chapter 4 → Chapter 5, then the AI chapters last. The right path if you want to understand why a forecast moves before you act on it. Chapter 6's state-space and dynamic- factor view is the foundation everything else rests on.
- Forecasting-first. Chapter 2 → Chapter 4 → Chapter 5 → Chapter 6, then Chapters 7–10. The right path if your immediate need is a defensible predictive distribution to feed an existing decision rule.
- AI-and-agents-first. Chapter 7 → Chapter 8 → Chapter 9 → Chapter 10, with Chapters 4–6 as reference. The right path if the numerical core already exists and the question is what to wrap around it.
The Chapter 0 preface motivates the book; this chapter sketches the pipeline; Chapter 2 sets the mathematical conventions; Chapter 3 sets the computational ones. Skim Chapters 0–3 if the prerequisites are familiar; do not skip them — the conventions established here recur everywhere later.
Prerequisites
The book assumes:
- Probability and statistics at the level of a first graduate course (joint and conditional distributions, MLE, Bayes' rule).
- Linear algebra through eigenvalues and singular value decomposition.
- Python at intermediate level: NumPy, pandas / Polars, basic matplotlib. Chapter 3 covers Polars in detail; the other chapters assume working comfort with the language.
- One machine-learning course of exposure is sufficient. Chapter 3 has a PyTorch primer; Chapters 4–5 develop the model-specific machinery as needed.
Notation conventions
These symbols recur throughout the book and are introduced formally in their first chapter, then reused without redefinition:
| Symbol | Meaning |
|---|---|
| Simple return at time | |
| Log return | |
| Portfolio weight vector | |
| Return covariance matrix | |
| Information set available at time | |
| , | Value and action-value functions in RL |
| Policy (a probability distribution over actions) | |
| Latent factor vector | |
| Innovation (shock) vector | |
| Utility function |
Bold lowercase letters are vectors; bold uppercase are matrices. Hatted symbols (, ) are sample estimates of their unhatted counterparts.
Contents
- Forecasting — the conditional-distribution view of prediction and the three properties (calibration, sharpness, stability) every forecast in the book has to deliver.
- Optimal Decision — utility, constraints, and the static / dynamic / function-approximated trio that shapes the policy chapters.
- Modelling Dynamics — why explicit dynamics matter when you want to interpret, intervene, or stress-test rather than only predict.
- AI Agent — the boundary between LLM-glue tasks and the numerical core.
- Synthetic Data — what generated paths buy you beyond resampling, and how they fold back into evaluation.