What it does
Backtrader is a Python backtesting framework with data feeds, indicators, simulated orders, analyzers and charts. It supports several data streams and timeframes in one strategy. The project publishes its code under GPL version 3, with local installation and no service account needed for file-based simulations.
Cerebro coordinates a Backtrader simulation. Add a strategy, load a data feed with cerebro.adddata, run cerebro.run() and inspect the result with analyzers or cerebro.plot(). CSV files and pandas data provide alternatives to online feeds. The package is available through pip install backtrader; charting also needs Matplotlib.
The simulated broker is a useful place to examine assumptions. Its market orders normally execute at the next bar’s opening price. Limit and stop orders follow their own conditions, while setcommission and the slippage settings control trading-cost assumptions. Cash, current positions and portfolio value are tracked through the run.
By default, an order is filled completely in one step. A custom volume filler is needed to model partial execution. That matters for a study whose order size is large relative to available volume. Backtrader also supports resampling and replay, allowing one strategy to work with multiple timeframes.
The library itself is free to obtain and use under its GPL terms. Online data and live broker adapters have separate dependencies and access arrangements. The repository includes older connection examples, so a local file-based backtest is distinct from establishing that a particular live integration works with a current broker account.
Strengths
- Accepts local CSV and pandas data alongside other feeds
- Allows commission, slippage and volume-filling assumptions to be configured
- Supports several timeframes through resampling and replay
Watch out for
- Default simulated orders fill completely unless a volume filler is supplied
- Plotting and live integrations require additional dependencies
Best for
- Python developers building event-driven backtests
- Researchers studying order assumptions across multiple timeframes
Sources
- Backtrader installation, data feeds and feature overview (Oct 27, 2026)
- Backtrader strategy, Cerebro and plotting workflow (Oct 27, 2026)
- Backtrader simulated broker settings and execution rules (Oct 27, 2026)
- Backtrader GNU GPL version 3 licence (Oct 27, 2026)
