Open-source project

Backtrader

A Python framework for expressing, testing and visualizing rule-based trading strategies on historical data.

Provider
Open-source community
Access
Open source
Primary interface
Python backtesting framework
Open-source community
API / Skill
Research
Implementation statusGuide reviewed · 2026-07
Implementation status

Open-source project

Expected result

Model signal and order logic

Known failure mode

Include realistic fees, slippage, survivorship and execution assumptions.

Compatibility

Open source · Python backtesting framework

Best used for

Model signal and order logic
Test strategies across assets
Analyze portfolio-level results
Quick start
pip install backtrader

import backtrader as bt
cerebro = bt.Cerebro()
cerebro.broker.setcash(100000)
# Add a data feed and strategy before running
results = cerebro.run()

A practical workflow

  1. 1Confirm the source and license
  2. 2Run the smallest useful request
  3. 3Validate fields and missing values
  4. 4Cache responsibly and document assumptions

Before you build

Include realistic fees, slippage, survivorship and execution assumptions.

Open official documentation

Frequently asked questions

What can Backtrader do in a real workflow?

Model signal and order logic Test strategies across assets Analyze portfolio-level results

What access and compatibility does Backtrader require?

Open source. Python backtesting framework.

What is the main implementation risk with Backtrader?

Include realistic fees, slippage, survivorship and execution assumptions.