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 have | Start with |
|---|---|
| Buy and sell signals from indicators or a model | Signal backtesting for long and short positions, reversals, and adding to positions |
| Order sizes or target portfolio weights | Backtesting 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 fills | Event-driven backtesting for callbacks that make decisions as the simulation runs |
| A backtest you want to continue as new data arrives | Live 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
Backtesting engine
Simulate orders, signals, and callbacks across many assets and parameters at once
Signal backtesting
Turn entry and exit signals into long, short, reversing, and pyramided positions
Event-driven backtesting
Write compiled callbacks for cooldowns, position limits, and custom simulators
Live simulation
Continue backtests on new bars, chain runs, and feed an external trading system
Intraday and tick backtesting
Backtest minute bars, ticks, and sessions, and resolve stops on finer data
Realistic backtests
Avoid look-ahead bias, impossible fills, and survivorship bias in your backtests
Orders and execution
Simulate limit and stop-entry orders, fill prices, timing, rejections, and real fills
Stop loss and take profit
Backtest stop losses, trailing stops, take profits, time stops, and exit ladders
Position sizing
Size trades in units, cash, percent of equity, target weights, or risk per trade
Fees, slippage, and leverage
Model commissions, slippage, leverage, futures multipliers, and negative prices
Portfolio accounting
Track shared cash, deposits, dividends, positions, records, and exposure per bar
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.