What Is Backtest?
Backtesting is simulating the efficiency of a trading strategy against historical data.
Backtesting is the process of analysing historical market data to see how a trading strategy would have performed statistically in the past. It is a key component of effective trading system development and can be used to test a trading hypothesis/strategy on the historical data. Backtesting results are then benchmarked against each other and indices like SP500, Bitcoin price. Backtesting results are often too promising due to overfitting. It can be always assumed that the live trading performance is worse than the strategy backtested results.
Backtesting is usually performed by specialised tool, or a backtesting framework written in some programming language. Different backtesting frameworks offer compromises between speed (how many combinations you can test and how fast), complexity (single pair. vs multi pair vs. portfolio construction strategies), supported market data and supported trading activities (volatility-based, debt-based, etc.)
Trading Strategy Framework is one of the backtesting frameworks for Python, designed for decentralised finance. TradingView’s Pine Script is the most well-known backtesting framework in the world.
Backtesters can be implemented in two ways, making a compromise with the speed of backtesting vs. how complex the strategy logic can be:
Vectorised: quickly compare thousands of grid search options using parallel computation. Popular Python-based vectorised backtesting frameworks include Moonshot, VectorBT. To speed up computation, vectorised framework sometimes need to compromise with realism of the results. Vectorised frameworks can also easily utilise machine learning.
Event-driven: support complex decision making process and logic for the trade decisions. Event-driven approach usually enables easier re-use of the strategy code between backtesting and live trade execution. One popular Python-based event-driven backtesting framework is Zipline. Read more about event-driven logic here.
Here is more about compromised between vectorised and event-driven frameworks.
See the list of Python backtesting frameworks.
See also