1,000,000 backtest simulations in 20 seconds with vectorbt

When you have Holy Grails, you never show anything to anybody.
Good Evening Handle123,

Thank you for the comment.

I AGREE with you 100% sir.

If I had a holy grail strategy, I am sorry, I am not telling anyone anything or showing noone nothing.
 
Yeah, I already have experience in OpenCL programming, but I think even just simple multithreading would already bring nearly x-fold improvement, where x is the number of CPU threads possible (= CPU cores multiplied by CPU threads/core) as my current solution is just singlethread.
You might be able to split the data in to multiple pieces, run each piece as a separate process with your current solution, then merge the pieces together. This would take advantage of multiple cores on a single computer without the complexity of synchronizing multiple threads in the same process or making it fit into opencl to do calculation on your GPU.
 
You might be able to split the data in to multiple pieces, run each piece as a separate process with your current solution, then merge the pieces together. This would take advantage of multiple cores on a single computer without the complexity of synchronizing multiple threads in the same process or making it fit into opencl to do calculation on your GPU.
Yeah, this is indeed simply doable. Thx.
 
When you have Holy Grails, you never show anything to anybody.

I would amend that:

When you have Holy Grails, you don't use man-in-the-middle commercial black box software getting between you and your broker's API that can log all of your executions, datamine you and you're blissfully unaware for years. It's the Wild West in this kind of activity.

These days, there's plenty of open source software to start with as a basis for one's custom automated trading algorithms.
 
I would amend that:

When you have Holy Grails, you don't use man-in-the-middle commercial black box software getting between you and your broker's API that can log all of your executions, datamine you and you're blissfully unaware for years. It's the Wild West in this kind of activity.

These days, there's plenty of open source software to start with as a basis for one's custom automated trading algorithms.
Can you suggest some good solid frameworks? Quantconnect is overengineered.
 
I would amend that:

When you have Holy Grails, you don't use man-in-the-middle commercial black box software getting between you and your broker's API that can log all of your executions, datamine you and you're blissfully unaware for years. It's the Wild West in this kind of activity.

These days, there's plenty of open source software to start with as a basis for one's custom automated trading algorithms.
Good Morning SteveH,

How are you doing today sir?

Where can I find the Holy Grail algo Trading System for an Intraday ES Future Market?

Thank you
 
vectorbt is a package that combines backtesting and data science.

It takes a “vectorized” approach to backtesting using pandas and NumPy.

This means that instead of looping through every day of data, it operates on all the data at once.

This allows for testing millions of strategies in a few seconds.

I did a deep dive in how to use it here:

https://pyquantnews.com/1000000-backtest-simulations-20-seconds-vectorbt/
1,000,000 backtest simulations in 20 seconds with vectorbt
10,000,000 backtest simulations in 20 seconds with vectorbt
100,000,000 backtest simulations in 20 seconds with vectorbt
1000,000,000 backtest simulations in 20 seconds with vectorbt


Many traders thought if you backtest billions and billions of historical data,
you would be filthy rich.
Unfortunately, in the real world, it wouldn't work.

You should only back test the recent hundreds of data.


 
Last edited:
When you have Holy Grails, you never show anything to anybody.

You can show it here as nobody will ever believe you. If you show something that goes above the average knowledge on ET you are classified as fake. To be credible for the majority you should underperform the average ET "trader".

If you need to do 1 million backtests, just throw away what you have. A good system does not need 1 million backtests. And hoping to optimize a system by doing 1 million backtests will not deliver what you hope it will.
 
Also switched to polars. It's more performant than pandas 2.0 but I find the filter and select syntax on columns awkward. But from experience, there is generally a tradeoff between performance and syntax (see kx)

I'm writing my own thing that is not dissimilar. But I'm using Qt and a desktop interface, writing python code for the backtesting engine is still possible but visualizations are fixed. Some would call it a dated approach.

Pandas (including 2.0 with the Arrow backend) is very slow, memory hungry and only works for in-memory calculations, at least from what I can see for VectorBT it doesn't support lazy evaluation. For my case, I'm switching to Polars as it's about a magnitude faster and more versatile.

EDIT: Apparently Dask and Ray are supported, which is good but still slower than Polars or DuckDB.
 
Back
Top