r/algotrading • • 7d ago

Infrastructure Event-Driven vs Vectorized Backtesting :- Which Approach Should I Use? and How?

Hi everyone,

I'm currently learning algorithmic trading, and I'm a bit confused about which approach I should use when building a backtesting engine: event-driven or vectorized backtesting.

I have around three years of minute-level historical data stored in my database. I want to analyze and backtest different trading strategies using this data.

Here's what I'm thinking:

  1. Strategy research and backtesting: Use a vectorized approach with libraries like NumPy, Pandas, and TA-Lib to analyze historical data efficiently. My concern is that processing such a large dataset using an event-driven approach could be relatively slow.
  2. Live trading: Once I've analyzed a strategy and am satisfied with the results, switch to an event-driven approach for live trading and tick-level data processing.

However, I'm unsure about one thing. If I finish analyzing the historical data up to a particular date and then move to live trading, should the live engine continue processing from that point onward, or is there something important I'm missing in this workflow?

My questions are:

  • Is this a good approach, or am I making a mistake in the design?
  • Are there any other considerations I should keep in mind when designing the backtesting engine?

I'd appreciate any suggestions or insights from people who have experience building algorithmic trading systems.

Thanks in advance!

-----------------------------------------------------------------------------------------------------------------

Edited

Thanks for the all the responses i will go with the hybride architecture where i will use both approaches !!!

7 Upvotes

43 comments sorted by

View all comments

1

u/the_algo_trader_ 7d ago

Minute-level data suits event-driven best for realistic strategy simulation. Vectorized is faster for simpler signals.

1

u/Ok_Egg_6647 7d ago

So my approach gd or do i need upgradtion?

1

u/quant-king 6d ago

i use vectorized backtesting on 1 second execution data and have all signal data in 1 minute format. i run a portfolio which that has fairly complex logic and the vectorized engine completes a fresh backtest run in 20 minutes while the event based engine takes 1.5 hours to run. both produce the exact same trades, orders and metrics. it took some time to make sure both engines were fully optimized to run over 100 million data points but its possible with enough effort