# Backtesting (/features/backtesting)

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 \[#start-here]

Begin with the [Backtesting engine](/features/backtesting/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](/features/backtesting/signal-backtesting/) for long and short positions, reversals, and adding to positions                                                                                                    |
| Order sizes or target portfolio weights                         | [Backtesting engine](/features/backtesting/backtesting-engine/#three-ways-to-simulate) for turning order arrays into a portfolio, then [Position sizing](/features/backtesting/position-sizing/) for amounts and allocation targets |
| Rules that depend on current cash, positions, or previous fills | [Event-driven backtesting](/features/backtesting/event-driven-backtesting/) for callbacks that make decisions as the simulation runs                                                                                                |
| A backtest you want to continue as new data arrives             | [Live simulation](/features/backtesting/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](/features/backtesting/event-driven-backtesting/) page
shows how to choose between extending signal simulation and writing your own order logic.

## Explore backtesting features \[#explore-backtesting-features]

*   [Backtesting engine](/features/backtesting/backtesting-engine): Simulate orders, signals, and callbacks across many assets and parameters at once
*   [Signal backtesting](/features/backtesting/signal-backtesting): Turn entry and exit signals into long, short, reversing, and pyramided positions
*   [Event-driven backtesting](/features/backtesting/event-driven-backtesting): Write compiled callbacks for cooldowns, position limits, and custom simulators
*   [Live simulation](/features/backtesting/live-simulation): Continue backtests on new bars, chain runs, and feed an external trading system
*   [Intraday and tick backtesting](/features/backtesting/intraday-and-tick-backtesting): Backtest minute bars, ticks, and sessions, and resolve stops on finer data
*   [Realistic backtests](/features/backtesting/backtest-realism): Avoid look-ahead bias, impossible fills, and survivorship bias in your backtests
*   [Orders and execution](/features/backtesting/orders-and-execution): Simulate limit and stop-entry orders, fill prices, timing, rejections, and real fills
*   [Stop loss and take profit](/features/backtesting/stop-loss-and-take-profit): Backtest stop losses, trailing stops, take profits, time stops, and exit ladders
*   [Position sizing](/features/backtesting/position-sizing): Size trades in units, cash, percent of equity, target weights, or risk per trade
*   [Fees, slippage, and leverage](/features/backtesting/fees-slippage-and-leverage): Model commissions, slippage, leverage, futures multipliers, and negative prices
*   [Portfolio accounting](/features/backtesting/portfolio-accounting): Track shared cash, deposits, dividends, positions, records, and exposure per bar

## Model the account you want to trade \[#model-the-account-you-want-to-trade]

For a multi-asset strategy, start with
[shared cash](/features/backtesting/portfolio-accounting/#shared-cash) and
[position sizing](/features/backtesting/position-sizing/) to decide how assets share the capital.
Add [fees, slippage, and leverage](/features/backtesting/fees-slippage-and-leverage/) and track
deposits, dividends, and existing holdings with
[Portfolio accounting](/features/backtesting/portfolio-accounting/).

For strategies where the fill matters, explore
[Orders and execution](/features/backtesting/orders-and-execution/),
[Stop loss and take profit](/features/backtesting/stop-loss-and-take-profit/), and
[Intraday and tick backtesting](/features/backtesting/intraday-and-tick-backtesting/).
[Realistic backtests](/features/backtesting/backtest-realism/) brings together signal timing, price
assumptions, and checks for look-ahead bias.

## Inspect results and compare strategies \[#inspect-results-and-compare-strategies]

Follow a run into [Trade analytics](/features/analytics/trade-analytics/) to inspect its trades, or
[Performance and risk metrics](/features/analytics/performance-metrics/) to compare returns and
risk. When you are ready to explore variations,
[Parameter optimization](/features/optimization/strategy-optimization/) covers testing parameter
combinations, and
[Walk-forward and cross-validation](/features/optimization/time-series-cross-validation/) covers
testing on unseen periods.

For a closer look at the code, read the [Portfolio documentation](/documentation/portfolio/) for the
simulation lifecycle, or work through the [Stop signals tutorial](/tutorials/stop-signals/) for a
signal-driven example.
