Features

Backtesting

Model orders, signals, leverage, stops, limits, cash flows, and simulation callbacks

Backtest trading strategies in Python and see exactly what they would have done. This section is for traders and researchers who want to turn signals, orders, or custom logic into a portfolio, model how orders fill and what they cost, and account for every position and cash flow. Each page covers one part of that workflow: the simulation engine, signals and compiled callbacks, continuing a backtest on new data, intraday fills, exits, sizing, costs, and the checks that keep a backtest honest.

Start here

Begin with the Backtesting engine page for the three ways to simulate and how many backtests run in one call. Or choose a starting point based on what you already have:

You haveStart with
Buy and sell signals from indicators or a modelSignal backtesting for long and short positions, reversals, and adding to positions
Order sizes or target portfolio weightsBacktesting engine for turning order arrays into a portfolio, then Position sizing for amounts and allocation targets
Rules that depend on current cash, positions, or previous fillsEvent-driven backtesting for callbacks that make decisions as the simulation runs
A backtest you want to continue as new data arrivesLive simulation for carrying the portfolio state into the next run

Signals can also use callbacks, so you can keep built-in stops and limits while adding custom decisions. The Event-driven backtesting page shows how to choose between extending signal simulation and writing your own order logic.

Explore backtesting features

features/backtesting pages

Model the account you want to trade

For a multi-asset strategy, start with shared cash and position sizing to decide how assets share the capital. Add fees, slippage, and leverage and track deposits, dividends, and existing holdings with Portfolio accounting.

For strategies where the fill matters, explore Orders and execution, Stop loss and take profit, and Intraday and tick backtesting. Realistic backtests brings together signal timing, price assumptions, and checks for look-ahead bias.

Inspect results and compare strategies

Follow a run into Trade analytics to inspect its trades, or Performance and risk metrics to compare returns and risk. When you are ready to explore variations, Parameter optimization covers testing parameter combinations, and Walk-forward and cross-validation covers testing on unseen periods.

For a closer look at the code, read the Portfolio documentation for the simulation lifecycle, or work through the Stop signals tutorial for a signal-driven example.

Copyright © 2021–2026 Oleg Polakow. All rights reserved.

Site content and documentation are provided for using and evaluating VectorBT PRO and for educational purposes. Any other use, including building or supporting competing products or services, requires prior written consent.