# kernc/backtesting.py

🔎 📈 🐍 💰  Backtest trading strategies in Python.

Repository: https://github.com/kernc/backtesting.py
Canonical: https://ross.abutalabs.com/products/backtestingpy
Homepage: https://kernc.github.io/backtesting.py/
Language: Python
License: AGPL-3.0
License Family: copyleft
Topics: trading, trading-strategies, trading-algorithms, trading-simulator, backtesting, backtesting-trading-strategies, backtesting-engine, backtesting-frameworks, investment, investing, investment-strategies, forex, forex-trading, stocks, algorithmic-trading, framework, financial-markets, hacktoberfest, algo-trading, finance
Last push: 2026-08-05T12:39:16+00:00

## Health v2 (maintenance only)
Score: 75/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 96, release rhythm 35, longevity 100
- inputs: {"age_days": 2800, "days_push": 28, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 8893, forks 1520 (observed 2026-08-28T04:10:26.180801+00:00)

## What it is
Backtesting.py is a lightweight Python framework for backtesting trading strategies against historical candlestick data. It provides a small, clean Strategy/Backtest API, works with any technical indicator library, and produces interactive performance plots and statistics.

## Use cases
- backtest a trading strategy on historical OHLC data
- test moving average crossover strategies in Python
- evaluate strategy performance with stats like return and volatility
- simulate forex, crypto, or stock strategies before live trading
- plot interactive equity curves and trade markers
- compare a strategy against buy-and-hold returns

## When to choose
- you want a fast, lightweight, well-documented backtesting library with a small API
- you already work in Python with Pandas/NumPy and any TA library
- you need interactive visualizations of backtest results
- you backtest single-instrument, bar-based (vectorized/event-driven) strategies

## When to avoid
- you need live trading or broker integration - this library only backtests
- you need multi-asset portfolio backtesting or complex order types
- your project cannot comply with the AGPL-3.0 license
- you need tick-level or high-frequency data simulation

## Facets
- artifact type: framework
- maturity: active
- function: trading, simulation, data-visualization, benchmarking
- domain: fintech, data-science
- platform: python, cross-platform
- tags: backtesting, algorithmic-trading, technical-analysis, finance, pandas, bokeh, trading, python

## Member repositories
- kernc/backtesting.py (main) score 75

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:26.180801+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:24:44.095265+00:00, confidence not recorded.
  - readme: https://github.com/kernc/backtesting.py (fetched 2026-08-28T04:10:26.180801+00:00, sha 22447c8450cf)
  - homepage: https://kernc.github.io/backtesting.py/ (fetched 2026-08-29T08:24:57.141034+00:00, sha b647e1dc0bf3)
- Data as of 2026-08-30T08:39:29.467469+00:00.
