Backtrader
The long-standing Python backtesting and live-trading framework
By mementum
At what price does Backtrader fill a market order?
We ran Backtrader 1.9.78.123 on three synthetic daily bars with 10,000 in starting cash. The strategy submits a market order for ten shares when the first bar closes at 100. The default simulated broker buys them at the next open, 102. At the second close of 104 the strategy submits its sell order. It fills at the third open, 103.
The two fills earn 10 before fees. A 0.1% commission on each side costs 1.02 to enter and 1.03 to exit, leaving 10,007.95 in cash. Using the two signal closes as fills would have shown a gross gain of 40 for the same orders. The script prints both fills so you can check which prices went into the result.
uv run --with backtrader==1.9.78.123 backtrader-fill-example.pyNot yet reviewed
This project is listed, but we have not yet reviewed its documentation. The description is editorial and the figures come from GitHub.
Live GitHub metrics
Live GitHub data · Nov 27, 2026No tagged releases. Repository created Jan 10, 2015.
What it is
Backtrader has been the default Python backtester for a decade and still underpins many tutorials and agent prototypes. It is feature-complete but no longer actively developed, which matters when you pair it with modern data libraries.
No longer actively maintained; last push in 2024.
In the maintainers' words: “Python Backtesting library for trading strategies”
Tags
- Backtesting
- Classic
- Python
- #backtesting
- #metaclass
- #python
- #trading