The Companion Repository
Every code example in AI Trading Edge comes from one repository, frozen at release v1.0-book-release so the code you read matches the code you run. The printed page is for judgment. This is for running.
Quick start
git clone <your-clone-of-this-archive> ai-trading-edge
cd ai-trading-edge
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # add your data / broker / model keys
pytest -q
python examples/quickstart.pyPython 3.11 or newer. No API keys are required for the test suite — it runs on deterministic synthetic fixtures. If the suite passes, your environment reproduces the book's logic. If it fails, fix that before you write a strategy, because every result downstream depends on it.
Layout
BOOK_TO_REPO_MAP.md maps every printed example to its file path, its dependencies, the tests that cover it, and its expected output. When the text and the repository disagree, the repository is authoritative.
Loaders, corporate actions, point-in-time joins, session calendars, survivorship-free universes.
Gap metrics, session VWAP, volume profile, extension measures.
The shared signal contract and timestamp discipline.
9:20 premarket reversal, gap-up-and-fail, momentum exhaustion.
The market regime engine.
Catalyst strength scoring and the LLM adapters that feed it.
Short-squeeze probability model.
Pair and portfolio mean reversion.
Training harness, purged walk-forward validation, calibration.
Position sizing, R-multiples, portfolio heat, the risk service and kill switch.
Slippage, commissions, borrow, locates, halt handling.
Provider-neutral LLM interface — the model name is configuration, not code.
Trade journal and the Trade Failure Map.
One runner per system in Part III. They refuse survivorship-biased universes.
A LEAN port of the premarket reversal so the spec runs on another platform's data and fills.
Regenerates every figure printed in the book.
The suite that must pass before any example in the book is trusted.
Data requirements, figure list, and the validation-status record for every unaudited system.
License and warranty
The code is released under a permissive license and carries no warranty. It is research and teaching code. It has not been audited for use with live capital, and the risk service in it is a starting point, not a compliance system. Trading it as written, without your own review, would be exactly the kind of unexamined delegation the book spends twenty-five chapters arguing against.
Questions
- What is the AI Trading Edge companion repository?
- It is the runnable version of every code example in AI Trading Edge — the data layer, feature builders, strategies, validation harness, risk service, execution model, and the test suite that covers them. The printed page is for judgment; the repository is for running.
- Do I need API keys to use it?
- Not to run the tests. The suite uses deterministic synthetic fixtures. You need your own market-data, broker, and model keys to run the backtests and the live-facing adapters.
- Which Python version does it need?
- Python 3.11 or newer.
- What happens when the book and the repository disagree?
- The repository is authoritative. The printed code is frozen at publication; the repository is the maintained implementation, and BOOK_TO_REPO_MAP.md tells you where each printed example lives.
- Can I trade this code with real money as written?
- No. It is research and teaching code released with no warranty and no audit. The risk service is a starting point, not a compliance system.