Historical Strategy Backtesting, Performance Statistics, and Parameter Optimization
Summary
This document explains the structure of a historical trading strategy backtester. It loads bar or tick records over a selected date range, initializes a strategy with a warm-up period, then replays the remaining data. The engine tracks simulated orders and trades and calculates daily mark-to-market profit and loss after accounting for commissions and slippage.
It also derives performance measures from daily returns, including drawdown, return variability, Sharpe ratio, and related totals. Parameter settings can be enumerated as a grid or evaluated through a genetic-algorithm workflow, with individual runs delegated to multiprocessing. The implementation provides a practical framework, but the excerpt reports no strategy results or validation study. Conclusions depend on data quality, fill assumptions, costs, parameter selection, and whether the simulated execution resembles live trading; optimization alone does not establish out-of-sample performance.
Key ideas
- The engine replays historical bars or ticks after using an initial segment to initialize the strategy.
- Daily results incorporate trading profit, holding profit, commission, and slippage.
- Performance statistics are calculated from the resulting daily balance and return series.
- Parameter search supports both exhaustive combinations and a genetic-algorithm approach.
- Optimization scores require independent validation because parameter fitting can overstate expected performance.
Tags
From a private course collection; the original is not published.