backtrader
BackTesting Engine
Decision gist · record as of 2026-08-14
Yes, if you are building or testing trading strategies and can accept GPLv3+ licensing constraints. Backtrader is a mature, feature-rich backtesting engine with low install friction and no external dependencies (except for optional plotting). However, maintenance is dormant—the last release was April 2023—so expect no new features or timely bug fixes. It remains suitable for strategy development and testing, but evaluate whether its feature set meets your needs without ongoing updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Plotting requires matplotlib (minimum version 1.4.1).
- Live trading with Interactive Brokers requires IbPy; Oanda integration requires oandapy.
- Visual Chart support requires a fork of comtypes.
License · maintenance · safety
GPLv3+ (copyleft) — GPLv3+ copyleft license requires that any derivative work or distribution must also be open-source under a compatible license. Proprietary trading systems built on this package must be released under GPLv3+ or not distributed.
last release 2023-04-19 (1213 days) · last repo commit 2024-08-19 · 22,845 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 327,865 downloads/mo, #7,564 on PyPI
Alternatives
Verify before relying
from datetime import datetime
import backtrader as bt
class SmaCross(bt.SignalStrategy):
def __init__(self):
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
crossover = bt.ind.CrossOver(sma1, sma2)
self.signal_add(bt.SIGNAL_LONG, crossover)
cerebro = bt.Cerebro()
cerebro.addstrategy(SmaCross)
data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
todate=datetime(2012, 12, 31))
cerebro.adddata(data0)
cerebro.run()
cerebro.plot()- Whether Yahoo Finance data feeds continue to work reliably given the note about API changes in 2018.
- Current compatibility with Python versions beyond 3.7, given classifiers list up to 3.7 only.
- Whether pyfolio integration (noted as deprecated) is still functional or has been removed.
What it is and what it does
Backtrader is a self-contained backtesting and live trading platform for Python that lets you design and test trading strategies against historical market data before deploying them to live brokers. It supports multiple data sources (CSV, online feeds, pandas, blaze), multiple simultaneous data feeds and timeframes, and includes a built-in library of 122 technical indicators plus support for TA-Lib. The engine simulates realistic trading conditions with configurable commission schemes, slippage, volume filling strategies, and multiple order types (Market, Limit, Stop, StopTrail, OCO, bracket orders).
You can backtest strategies step-by-step or all at once, apply data filters (like Renko bricks or intraday simulation), resample and replay data, and analyze results with integrated analyzers for metrics like Sharpe Ratio and SQN. Live trading is supported with Interactive Brokers, Visual Chart, and Oanda. The platform includes plotting via matplotlib, automated position sizing, trading calendars, and schedulers. It runs on Python 3.2+ and also works with PyPy, though plotting is not available under PyPy.
Use it for
- Backtest a moving-average crossover strategy against historical stock data before deploying it live.
- Simulate intraday trading by breaking daily bars into smaller chunks and testing order fills at different price levels.
- Compare multiple trading strategies across different timeframes and data feeds simultaneously to find the best performer.
- Analyze trading performance with built-in metrics like Sharpe Ratio, total return, and drawdown to evaluate strategy robustness.
- Live-trade a validated strategy through Interactive Brokers or Oanda with realistic commission and slippage modeling.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are building or testing trading strategies and can accept GPLv3+ licensing constraints.
Backtrader is a mature, feature-rich backtesting engine with low install friction and no external dependencies (except for optional plotting). However, maintenance is dormant—the last release was April 2023—so expect no new features or timely bug fixes. It remains suitable for strategy development and testing, but evaluate whether its feature set meets your needs without ongoing updates.
Install
backtrader on PyPI
Before you install
Low friction install with no runtime dependencies. Dormant maintenance status (last release 2023-04-19, last commit 2024-08-19) means bug fixes and feature updates are infrequent, though the repository remains active and is not archived.
Plotting requires matplotlib (minimum version 1.4.1). Live trading with Interactive Brokers requires IbPy; Oanda integration requires oandapy. Visual Chart support requires a fork of comtypes.
License in practice
GPLv3+ copyleft license requires that any derivative work or distribution must also be open-source under a compatible license. Proprietary trading systems built on this package must be released under GPLv3+ or not distributed.
Quickstart
from datetime import datetime
import backtrader as bt
class SmaCross(bt.SignalStrategy):
def __init__(self):
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
crossover = bt.ind.CrossOver(sma1, sma2)
self.signal_add(bt.SIGNAL_LONG, crossover)
cerebro = bt.Cerebro()
cerebro.addstrategy(SmaCross)
data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
todate=datetime(2012, 12, 31))
cerebro.adddata(data0)
cerebro.run()
cerebro.plot()
Verify before relying
- Whether Yahoo Finance data feeds continue to work reliably given the note about API changes in 2018.
- Current compatibility with Python versions beyond 3.7, given classifiers list up to 3.7 only.
- Whether pyfolio integration (noted as deprecated) is still functional or has been removed.
Package facts
| License | GPLv3+ copyleft |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Dormant 1,213 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 327,865 / month, #7,564 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryLicense :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Operating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Topic :: Office/Business :: FinancialTopic :: Software Development |
Evidence: backtrader-1.9.78.123-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “live trading engine”
- backtraderBacktrader is a Python backtesting and live trading engine that…
- nautilus_traderNautilusTrader is a Rust-native event-driven trading engine that runs…
- lumibotLumibot is a Python framework for building, backtesting, and running…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also backtesting · freqtrade · lumibot · vectorbt · nautilus_trader · technical · quantconnect-stubs · metatrader5 · tradingview-ta · ta