Backtest – Mangrove

GlossaryPerformance and testing

Backtest

Definition: A backtest is a simulation that applies a trading strategy's rules to past market data to see how the strategy would have performed.

A backtest steps through historical prices in time order, applies the strategy’s rules at each step and records the trades it would have made. David Bailey, Jonathan Borwein, Marcos Lopez de Prado and Qiji Jim Zhu call it “a historical simulation of how an algorithmic strategy would have performed in the past” (Bailey et al.). Its results depend on the data, and two common errors come from the data itself. Look-ahead bias comes from using information that was not yet available at the simulated moment, such as a company’s financial statements before their release date. Survivorship bias comes from testing only on assets that still exist, such as the current members of a stock index, which leaves out those that were removed from the exchange, went bankrupt or were acquired during the test period (Palomar).

A third error, overfitting, comes from the search for a strategy. When a researcher tunes a strategy’s settings on past data, Bailey and his coauthors write, the settings are often “chosen to profit from past noise rather than future signal”, meaning they fit random moves in the past data. They describe an online tool from Lawrence Berkeley National Laboratory that fits a simple monthly strategy to randomly generated returns. After a few hundred tries it finds “highly profitable strategies in-sample”, that is, on the data used to choose them, and these do poorly on data held back from the search, called out-of-sample data. Campbell Harvey and Yan Liu wrote that a common practice is to cut a backtest’s reported Sharpe ratio, a separate entry that measures return relative to how much returns vary, by 50% to allow for data mining, meaning testing many strategies on the same data. They proposed instead a cut that depends on how many strategies were tested (Harvey and Liu, 2015). For example, an agent that tries a thousand combinations of indicator settings, such as how many past days of prices an average uses, on the same two years of prices and reports only the best one may report a result that later prices do not repeat.

Mangrove describes its backtests as historical simulations, which are not forecasts of future results.

The word has a second meaning in bank risk management. In January 1996 the Basel Committee on Banking Supervision published a framework for “backtesting” the value at risk (VaR) models that banks use to set capital for market risk. The framework compares each day’s VaR figure with the profit or loss that followed (Basel Committee, 1996). Value at risk is a separate entry.