Backtesting.py
Small Python framework for backtesting strategies on candlestick data
๐งฉ Build it Free 04 in Backtesting ๐ NEW TODAY
8,949 0 copies ยท 7 days AGPL-3.0updated 5 Aug '26
Overview
Backtesting.py is a small Python framework that backtests a trading strategy against OHLC candlestick data with one Strategy class and one Backtest object.
- Fortraders who want a small backtest of one strategy on one instrument's OHLC data.
- NeedsPython and a pandas DataFrame of OHLC(V) data for the instrument being tested โ no key or account.
- Runsa Python package (pip install backtesting) with a built-in optimizer and interactive plotting.
- Limitit backtests one instrument at a time โ the Backtest object takes a single OHLC DataFrame, so a portfolio needs one run per symbol.
Vibe it
Paste this into your AI agent. Write the first line, or take a suggestion; the copy carries your words.
Source: https://github.com/kernc/backtesting.py โ clone it and read its README and examples before writing anything; its documented setup beats what you remember. Stack: a small Python framework over pandas โ a Strategy subclass with init() and next(), run through one Backtest object, with a built-in optimizer and interactive plotting. Needs: Python and a pandas DataFrame of OHLC(V) data for the instrument being tested. Start: `pip install backtesting`, then run the SmaCross example from the README against the bundled GOOG test data before swapping in my own. Limit: it backtests one instrument at a time โ the Backtest object takes a single OHLC DataFrame, so a portfolio needs one run per symbol. Done means: you show me the stats output (Return, Sharpe Ratio, Max. Drawdown) from a run against my own data, and the Strategy code you wrote. Before you start, ask me: which instrument and OHLC data file I want to test, and the entry/exit rule for the strategy.
More in Backtesting
All 6 โ 05
PyAlgoTrade ๐งฉ Build it Event-driven Python library for backtesting, paper and live trading 06
AI-Trader ๐งฉ Build it Config-driven Backtrader wrapper with 20-plus strategies and an MCP server 01
hftbacktest ๐งฉ Build it Tick-level backtester for market making on level-2 and level-3 books
4,675
1,070
4,652
3
4