For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Backtrader with a lot of datafeed - trick to reduce data loading time

  • Dear All,

    I'm currently backtesting a strategy that needs a lot of datafeeds. If I understand correctly how backtrader works, one of the first step cerebro will perform (when doing is to pre-load the data (assuming preload = True which is the default setting). This step takes quite a bit of time in my case (maybe 3/4 minutes) but running through the bars afterwards is relatively fast (as fast as python can be:)); is there a way I could cache/store things so that i don't need to wait that time (3/4 minutes) everytime i run a backtest? I was thinking about pickling the cerebro object (i know cerebro can be pickled) but i do not know which cerebro's method to launch to load the data without launching or would you any other suggestion to shorten this annoying waiting time?

    thanks and regards

  • Probably not directly related to multiple data feeds speedup - but the following post discussed some ways of speeding up the feed's loading times (including some caching):

    How to speed up backtest


  • thanks, I'll take a look. Profiling the backtest is any case probably a good start

  • administrators

    Pickling cerebro won't help.

    The way to achieve what you want is to develop your own data feed which would use pre-loaded data already residing in RAM.

Log in to reply