Backtesting Methodology
How the engine works
The SDB backtesting engine operates as a simulation. Given a strategy definition and a historical dataset, it walks through time period by period, evaluating the strategy's rules at each step as if the strategy were running in real time.
At each period, the engine:
- Updates the current market state with the new data point
- Evaluates exit rules against any open positions
- Executes exits where conditions are met
- Evaluates entry rules against the current market state
- Executes entries where conditions are met and capital is available
- Updates position tracking, equity curve, and running statistics
This sequence ensures that exit evaluation happens before entry evaluation within each period — a position closed and a new position opened in the same period are handled in the correct order.
Avoiding common pitfalls
Backtesting has well-known failure modes. SDB is designed to mitigate the most dangerous ones:
Look-ahead bias occurs when a strategy uses future information that wouldn't have been available at the time of the trade. SDB enforces strict temporal ordering — the engine only sees data up to the current period. No future data leaks into entry or exit decisions.
Survivorship bias occurs when backtests only include instruments that still exist, excluding those that failed or were delisted. SDB's historical data includes delisted instruments where available, providing a more realistic test environment.
Overfitting occurs when a strategy is tuned to fit historical noise rather than genuine patterns. SDB helps detect overfitting through out-of-sample testing — you can split the historical period into training and validation windows to see if the strategy's performance holds on unseen data.
Execution assumptions
SDB simulates order execution with configurable assumptions:
- Fill price — trades execute at the period's close price by default, or at specified limit levels
- Slippage — configurable slippage model to account for the difference between expected and actual execution price
- Commission — configurable per-trade commission costs deducted from equity
These assumptions affect performance metrics. Conservative execution assumptions produce more realistic backtest results.
Data integrity
Backtest quality depends on data quality. SDB uses derived data from its historical database — not raw exchange data displayed to users (per the Kraken data rule, raw OHLCV is stored but not displayed). The derived metrics used for strategy evaluation are computed from the stored data and presented as analytical outputs.