The Honest Backtest
Companion code

Free, tested Python code for Book 2

Every listing printed in Build Your Own Algo Trading System comes from this repository, and a tool checks that the book and the code agree.

What's in it

  • A script for every chapter that reproduces its tables and examples
  • Tests for every printed listing, run automatically on each change
  • An in-memory paper broker and synthetic data, so everything runs with no broker account and no paid data
  • A template for writing the one adapter that connects your own broker

Getting started

git clone https://github.com/honest-backtest/build-your-own-algo.git
cd build-your-own-algo
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest -q
python chapters/ch01/run.py

Versions and corrections

The printed listings match the release tagged v1.0-book. Later corrections are recorded in the repository's errata file. The code is published under the MIT licence; the books' text remains under copyright.

Not a ready-to-run trading system.
The code is for learning and testing. Settings marked illustrative are not anyone's live settings, and three systems from the book are frameworks without their full rules. You are responsible for any software you run against a real account.