Backtesting engine that takes your ML models for a walk
A NumPy/Numba-accelerated framework for traders who want machine learning in their backtests, not just moving-average crossovers.

What it does
PyBroker is a Python backtesting framework built around two ideas: strategies can be driven by arbitrary ML models, and those models should be validated with walk-forward analysis rather than a single train/test split. It wraps data ingestion (Yahoo Finance, Alpaca, AKShare, or roll-your-own), rule-based or model-based execution logic, and performance metrics into one pipeline.
The interesting bit
The framework treats your model as a first-class citizen: you register a train_fn, PyBroker runs walk-forward windows, and predictions surface in the execution context via ctx.preds('my_model'). The backtester itself is Numba-accelerated NumPy, and it caches data, indicators, and trained models to keep iteration times low. Bootstrap resampling for metrics is built in, not bolted on.
Key highlights
- NumPy/Numba backtesting engine with parallelized computations
- Native walk-forward analysis for model training and validation
- Pluggable data sources: Alpaca, Yahoo Finance, AKShare, or custom
- Built-in caching for data, indicators, and models
- Bootstrap-based performance metrics
- Supports rule-based and model-based strategies across multiple instruments
Caveats
- The README is light on details about execution speed benchmarks or maximum portfolio scale; “super-fast” is claimed but not quantified
- The Apache 2.0 license carries a Commons Clause, which restricts commercial resale of the software itself—worth reading if you’re building a product on top
Verdict
Worth a look for quantitative developers who already have ML models and need a backtester that won’t force them to rewrite training loops in a DSL. Less compelling if you just want to test simple technical indicators—there are lighter tools for that.
Frequently asked
- What is edtechre/pybroker?
- A NumPy/Numba-accelerated framework for traders who want machine learning in their backtests, not just moving-average crossovers.
- Is pybroker open source?
- Yes — edtechre/pybroker is an open-source project tracked on heatdrop.
- What language is pybroker written in?
- edtechre/pybroker is primarily written in Python.
- How popular is pybroker?
- edtechre/pybroker has 3.5k stars on GitHub.
- Where can I find pybroker?
- edtechre/pybroker is on GitHub at https://github.com/edtechre/pybroker.