Skip to content
ToolsOpen sourceGPL-3.0No push in 12 months

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.

Download the Python example with all three bars
uv run --with backtrader==1.9.78.123 backtrader-fill-example.py
Backtrader’s market order execution rules

Not 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, 2026
Stars
23,819
Stars · 7d
+55
Stars · 30d
+217
30d momentum
+0.9%
Forks
5,327
Open issues
64
Language
Python
Last push
2 years ago

No tagged releases. Repository created Jan 10, 2015.

23.4k23.6k23.8kOct 8Nov 27
Cumulative GitHub stars, Oct 8, 2026 to Nov 27, 2026. Source: InvestingStack daily snapshots.

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