Event-driven backtesting with backtrader
The second approach to backtesting is called event-driven backtesting. In this approach, a backtesting engine simulates the time dimension of the trading environment (you can think about it as a for
loop going through the time and executing all the actions sequentially). This imposes more structure on the backtest, including the use of historical calendars to define when trades can actually be executed, when prices are available, and so on.
Event-driven backtesting aims to simulate all the actions and constraints encountered when executing a certain strategy while allowing for much more flexibility than the vectorized approach. For example, this approach allows for simulating potential delays in orders’ execution, slippage costs, and so on. In an ideal scenario, a strategy encoded for an event-driven backtest could be easily converted into one working with live trading engines.
Nowadays, there are quite a few event-driven backtesting...