Open sourceExplore the code on GitHub

Open-source Python
backtesting framework.

Run historical strategies locally. Model execution costs,
inspect trades and drawdown, and optimize parameters.
Add Studio for a visual Python backtesting workspace.

Python 3.12–3.14 Run locally. Explore freely.
OPENBACKTESTING STUDIOLocal Python. A visual workspace.
OpenBacktesting Studio in light mode showing an EMA strategy, candlestick chart, trade fills, equity curve, and backtest metrics.OpenBacktesting Studio in dark mode showing an EMA strategy, candlestick chart, trade fills, equity curve, and backtest metrics.
Studio running the bundled GOOG example. Historical results do not predict future performance.Explore Studio
At home in your Python workflow.
PythonNumPypandas
Familiar tools. Inspectable results.

YOUR LOCAL RESEARCH WORKSPACE

OpenBacktesting Studio

A local backtesting dashboard
for Python strategies.

Studio brings visual backtesting to your browser. Edit local Python strategies, configure a run, and explore charts and reports in one workspace, powered by the OpenBacktesting framework.

Install & launch Studio

One-command installation for macOS. The installer prepares everything and opens Studio. Installed separately from the framework.

Edit strategies. Configure inputs.

Work with your local Python files in the code editor. Adjust strategy inputs, execution settings, and market data; save presets for the next experiment.

See the trades behind the result.

Inspect candlesticks, indicators, signals, and fills alongside equity and performance reports. Locate trades on the chart and inspect saved strategy logs.

Compare parameter experiments.

Preview parameter combinations, run an optimization, and sort or filter saved trials. Apply a trial’s inputs to a regular backtest to inspect its chart.

Keep research you can reopen.

Reopen saved runs without executing the strategy again. Export result archives, choose whether to include source and data, and open shared results in a read-only viewer.

PYTHON STRATEGY RESEARCH

Backtest your rules.
Inspect the results.

A Python backtesting library for bar-by-bar strategies,
parameter experiments, and results you can inspect.

Write Python trading strategies.

Define strategies bar by bar. Work with built-in indicators, explicit position sizing, and execution costs on a single instrument.

Write a strategy
init()→next()→run()

Optimize strategy parameters.

Explore a grid of possibilities or use optional SAMBO optimization. Compare candidates and save experiments for later analysis.

Explore optimization
fast51020slow2040

Inspect trades, equity and risk.

Inspect orders, trades, equity, and risk. Take pandas results and Portfolio reports into your own notebooks and charting tools.

Understand the results
equitytradesrisk

Purpose-built for historical, single-asset research.

Know the model’s boundaries

AN IDEA, EXPRESSED IN CODE

Backtest a strategy
in Python.

Two moving averages. A crossover.
A simple place to start asking better questions.

Define your rules, compare parameters, then inspect the full history behind each result. The example uses bundled GOOG data, so you can get started without a data download.

Walk through your first backtest
YOU BRING THE HYPOTHESIS.

OpenBacktesting handles the historical execution, accounting, and results.

sma_cross.py
from openbacktesting import Backtest, Strategyfrom openbacktesting.test import GOOGclass SmaCross(Strategy):    fast = 10    slow = 20    def init(self):        self.fast_sma = self.ta.sma(self.close, length=self.fast)        self.slow_sma = self.ta.sma(self.close, length=self.slow)    def next(self):        if self.ta.is_crossover(self.fast_sma, self.slow_sma):            self.position.close()            self.buy(percent=95)        elif self.ta.is_crossunder(self.fast_sma, self.slow_sma):            self.position.close()            self.sell(percent=95)if __name__ == "__main__":    bt = Backtest(GOOG, SmaCross, cash=10_000, commission=0.002,                  end_policy="close_at_last_close")    result = bt.run()    print(result[["Return [%]", "# Trades", "Max. Drawdown [%]"]])
Python 3.12–3.14Built-in indicators. Plain Python.

FROM THE RESEARCH DESK

Python backtesting guides

Build your first experiment, choose your tools,
and check the assumptions behind a result.

All backtesting articles

YOUR NEXT EXPERIMENT STARTS HERE

Start backtesting
locally.

Clone the source. Run your first strategy.
Let the evidence lead from there.

Read the documentation
git clone https://github.com/lucidcog/openbacktesting.gitcd openbacktestinguv sync --lockeduv run --locked python examples/advanced/native_run.py

Source installation · Python 3.12–3.14 · Install uv ↗

No market-data download needed for the bundled example.Browse more examples

A FEW THINGS TO KNOW

Before the
first Python backtest.

Explore the documentation
What is OpenBacktesting?

OpenBacktesting is an open-source Python framework for historical backtesting, parameter optimization, and strategy research. Write strategy rules, simulate their execution on historical market data, and inspect trades, equity, and risk statistics. The optional Studio adds a local browser workspace for editing strategies and exploring visual backtest results.

When should I choose this Python backtesting framework?

Use OpenBacktesting for historical, single-asset research with bar-by-bar Python rules, explicit execution costs, and inspectable orders, trades and equity. Work with pandas results in a notebook, or add Studio for a local visual workflow. The Python backtesting library comparison explains the data, asset and execution questions to check when choosing a tool.

What is OpenBacktesting Studio, and how do I install it?

Studio is an optional local browser interface for Python strategy editing, visual backtesting, and parameter experiments. It is installed separately; the framework works without it. On macOS, one installation command prepares all dependencies and opens Studio. Follow the Studio installation guide for the command. Next time, use the double-click launcher. Studio runs on your computer.

Can I use my own market data?

Yes. Pass a pandas DataFrame with Open, High, Low, and Close columns. Volume is optional unless an indicator needs it. Each backtest models one asset in a single settlement currency. See the market data guide for requirements.

How do I install the Python framework?

Use Python 3.12–3.14, clone the GitHub repository, and run uv sync --locked. You can also install the checked-out source with python -m pip install .. Add the optimize extra for parameter searches. The commands above run a complete bundled example.

Does OpenBacktesting include charts or live trading?

Studio includes interactive charts, indicators, trade markers, equity curves, and backtest reports. The Python framework can also export results and plotting data for your own tools. OpenBacktesting focuses on historical research and does not include a live-trading engine. The interactive example on this website displays precomputed framework results. Read the current scope and limitations.