Can someone tell me what the difference is between vectorized backtesting and event-driven backtesting? Also, why is there a difference between the performances of both backtests?
There are many reasons why vectorized backtesting results can be different from a full-fledged event-driven simulation - including cost and fill assumptions as well as look-ahead bias. I suggest you try the following:
- Try the Blueshift version without cost and slippage to see how the results change - see here how to.
- You are using pre-adjusted price data (where past data includes adjustments for future corporate events). Depending on the size of adjustments during the backtest period, this effect can be significant or can be ignored. Check for any significant corporate actions (including dividends) and try to obtain adjustments on-the-fly to avoid lookahead bias due to pre-adjustments if required.
- Note: to realize the shifted daily returns on T, you need to enter at the close price of T-1. But to get the signal to enter at T-1, you need to wait till T-1 to compute the returns from T-2 to T-1. So, your strategy generates the signal and trades at the exact same price and time, at T-1, which is physically impossible and can be a significant source of lookahead bias (this error is especially significant for higher frequency strategies). Generate the signal at T-1 close as you are doing, but try to enter the trade at T open instead of T-1 close in your vectorized version and see how the results differ.
Hope this helps! please leave a comment if you have any more doubts on this.
Thanks for the detailed explanation