bt
Python library to backtest portfolio strategies (allocation, weighting, rebalancing) built from reusable building blocks.
The right tool for testing allocation and rebalancing ideas, not for intraday trading signals.
Who it is for
Investors testing portfolio rules such as monthly rebalancing, momentum rotation or risk-based weighting.
Strengths
- Strategies are composed from small algorithms: schedule, selection, weighting, rebalancing.
- Strategies can be nested into portfolio trees.
- Commissions and transaction cost models are configurable.
- Permissive MIT license.
Good to know
- You bring your own price data; results depend on its quality, as the README itself warns.
- Designed for portfolio-level backtests rather than order-by-order execution simulation.
Want a bot built on bt, or something similar?
We set it up, connect it to your accounts and keep it running.
Real-life uses
Portfolio rebalancing and DCA
Buys a fixed amount on schedule or rebalances to target weights across ETFs or crypto.
Sources
Every fact on this page comes from these sources, checked on 2026-10-24. If something has changed, the source wins; tell us at hello@heybotify.com.
- https://github.com/pmorissette/bt: features, example, cost models, MIT license
Alternatives in Backtesting
Backtrader
Classic Python library for backtesting strategies, widely used in tutorials.
PyBroker
Python framework for backtesting trading strategies, especially machine-learning ones, with a Numba-accelerated engine and walk-forward analysis.
Zipline Reloaded
Community-maintained version of Zipline, the event-driven Python backtester originally built and used by Quantopian.
QuantConnect (LEAN)
Cloud platform to research, backtest and trade strategies, built on the open-source LEAN engine.