Chapter 10. Vectorized Backtesting

Tesla’s chief executive and serial technology entrepreneur, Elon Musk, has said his company’s cars will be able to be summoned and drive autonomously across the US to pick up their owners within the next two years.

Samuel Gibbs (2016)

Big money is made in the stock market by being on the right side of the major moves.

Martin Zweig

The term vectorized backtesting refers to a technical approach to backtesting algorithmic trading strategies, such as those based on a dense neural network (DNN) for market prediction. The books by Hilpisch (2018, ch. 15; 2020, ch. 4) cover vectorized backtesting based on a number of concrete examples. Vectorized in this context refers to a programming paradigm that relies heavily or even exclusively on vectorized code (that is, code without any looping on the Python level). Vectorization of code is good practice with such packages such as Numpy or pandas in general and has been used intensively in previous chapters as well. The benefits of vectorized code are more concise and easy-to-read code, as well as faster execution in many important scenarios. On the other hand, it might not be as flexible in backtesting trading strategies as, for example, event-based backtesting, which is introduced and used in Chapter 11.

Having a good AI-powered predictor available that beats a simple baseline predictor is important but is generally not enough to generate alpha (that is, above-market returns, possibly adjusted for risk). ...

Get Artificial Intelligence in Finance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.