# Backtesting Libraries Compared

> Compare popular Python backtesting tools: vectorbt, Backtrader, backtesting.py, Zipline Reloaded, NautilusTrader and LEAN. Learn their styles, strengths and limits.

Source: https://learn.tradelabsai.com/programming/backtesting-libraries-compared/  
Track: Programming and Data · Level: Intermediate · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Backtesting Libraries Compared", https://learn.tradelabsai.com/programming/backtesting-libraries-compared/

You can write a simple backtest yourself in pandas, but as strategies grow, a framework saves time: it handles order simulation, position tracking, commissions and reporting. Python has many open source backtesting libraries, and they differ mainly in style. Vectorized tools run fast over whole arrays and suit research across many parameters. Event driven tools process one bar or tick at a time, which is slower but closer to how a live system behaves. Choosing the right one depends on your strategy, data and whether you plan to trade live from the same code.

## Two styles of backtesting

| | Vectorized | Event driven |
|---|---|---|
| How it works | Computes signals and returns on whole arrays at once | Steps through time, reacting to each bar or tick |
| Speed | Very fast | Slower |
| Realism | Simplified fills and path effects | Models orders, fills and state more closely |
| Best for | Research, parameter sweeps | Complex logic, live trading parity |
| Lesson | [Event-Driven vs Vectorized Backtesting](https://learn.tradelabsai.com/research/vectorized-backtesting/) | [Backtesting Methodology](https://learn.tradelabsai.com/research/backtesting-methodology/) |

## The main libraries

| Library | Style | Notes |
|---|---|---|
| vectorbt | Vectorized | Very fast parameter sweeps on NumPy and pandas; a paid PRO version adds features |
| backtesting.py | Event driven, simple | Small, easy API and interactive charts; single asset focus |
| Backtrader | Event driven | Mature and flexible with many indicators and broker integrations; development has slowed, so check maintenance status |
| Zipline Reloaded | Event driven | Community fork of Quantopian's Zipline; daily equity portfolios with a data bundle system |
| NautilusTrader | Event driven | High performance core written in Rust with a Python API; designed for research and live trading with the same code |
| LEAN (QuantConnect) | Event driven | Open source engine in C# with Python support; runs locally or on QuantConnect's cloud with bundled data |
| freqtrade | Event driven | Focused on crypto bots, with backtesting, optimisation and live trading |

Projects change over time. Before committing, check recent releases, open issues and documentation quality.

## Choosing a library

| If you want to | Consider |
|---|---|
| Test thousands of parameter combinations quickly | vectorbt or your own pandas code |
| Learn backtesting with a small, clear API | backtesting.py |
| Run multi asset daily equity portfolios | Zipline Reloaded or LEAN |
| Use the same code for backtest and live trading | NautilusTrader, LEAN, freqtrade or Backtrader |
| Trade crypto on centralised exchanges | freqtrade or NautilusTrader |

## What every framework still needs from you

A library does not make a backtest honest. You still need to supply:

- **Clean, point in time data.** See [Point-in-Time and Survivorship-Free Data](https://learn.tradelabsai.com/programming/point-in-time-data/) and [Survivorship and Selection Bias](https://learn.tradelabsai.com/research/survivorship-and-selection-bias/).
- **Realistic costs and slippage.** See [Costs and Slippage in Backtests](https://learn.tradelabsai.com/research/costs-and-slippage-in-backtests/).
- **Sensible fill assumptions,** especially for limit orders. See [Fill Models, Partial Fills and Order Queues](https://learn.tradelabsai.com/research/fill-models/).
- **Out of sample discipline.** See [In-Sample vs Out-of-Sample Testing](https://learn.tradelabsai.com/research/out-of-sample-testing/).

**Example: Same strategy, different answers**
A trader tests a limit order mean reversion strategy in two frameworks. The first fills a limit buy whenever the bar's low touches the limit price and reports a 22% annual return. The second fills only if the low trades below the limit price, a more conservative assumption, and reports 9%. Neither framework is wrong; they model fills differently. Live trading later shows about 8%, closer to the conservative model. Always read how a framework decides fills. See [Fill Probability and Queue Position](https://learn.tradelabsai.com/orders/queue-position/).

## Writing your own

Many experienced traders eventually write a small custom engine, because it fits their data and instruments exactly and has no hidden assumptions. The trade off is time and the risk of subtle bugs. A good middle path is using a framework for research and writing a thin, well tested live layer. See [Building Trading Bots](https://learn.tradelabsai.com/programming/building-trading-bots/).

## Frequently asked questions

### What is the best Python backtesting library?

There is no single best. vectorbt suits fast research, backtesting.py suits beginners, and NautilusTrader, LEAN or freqtrade suit traders who want the same code live.

### Is vectorized or event driven backtesting better?

Vectorized is faster for research; event driven is more realistic for complex order logic and live trading parity. Many traders use both.

### Do backtesting libraries include data?

Most do not. LEAN on QuantConnect's cloud includes data; with most other libraries you supply your own. See [Historical Data for Backtesting](https://learn.tradelabsai.com/research/historical-data-for-backtesting/).

Next, learn how programs talk to brokers in [Working With Exchange and Broker APIs](https://learn.tradelabsai.com/programming/trading-apis/).

## Continue learning

- Next lesson: [Working With Exchange and Broker APIs](https://learn.tradelabsai.com/programming/trading-apis/)
- Previous lesson: [Plotting Market Data with Matplotlib](https://learn.tradelabsai.com/programming/matplotlib/)
- Related: [Plotting Market Data with Matplotlib](https://learn.tradelabsai.com/programming/matplotlib/): Use matplotlib to plot prices, indicators, equity curves, drawdowns and return histograms, with clear examples and tips for honest, readable trading charts.
- Related: [Event-Driven vs Vectorized Backtesting](https://learn.tradelabsai.com/research/vectorized-backtesting/): Vectorised backtests compute signals and returns for all dates at once using arrays. Learn how they work, a pandas example, their speed advantages and their traps.
- Related: [Backtesting Methodology](https://learn.tradelabsai.com/research/backtesting-methodology/): A backtest simulates a strategy on historical data. Learn the steps, the key performance metrics, common biases and a checklist for backtests you can trust.
- Related: [Fill Models, Partial Fills and Order Queues](https://learn.tradelabsai.com/research/fill-models/): A fill model decides when and at what price backtest orders execute. Learn market, limit and stop fill assumptions, queue position and adverse selection.
- Related: [Portfolio and Multi-Asset Backtesting](https://learn.tradelabsai.com/research/portfolio-backtesting/): Portfolio backtests simulate many positions with capital limits, sizing and rebalancing. Learn the key design choices, constraints, metrics and pitfalls.
- Related: [Python for Trading](https://learn.tradelabsai.com/programming/python-for-trading/): Why Python is the most popular language for trading research and bots, which libraries matter, how to set up a project and a first script that tests a simple rule.
