Is it possible to use multiprocessing during backtesting (not optimization)?
This backtrader article from 2015 explains the process of using multiprocessing very well but it only discusses its use for strategy optimization. I was wondering if there is support (or if it is even feasible in any way) to apply multiprocessing when running a single trading strategy across multiple assets.
The basic structure of my code is:
cerebro = bt.Cerebro(maxcpus = None) cerebro.addstrategy(TestStrategy) for csv_path in csv_file_list: if os.path.isfile(csv_path): data = GenericCSVData(dataname=csv_path) cerebro.adddata(data) cerebro.run()
maxcpusparameter's value didn't cause any change in execution speed.
vladisld last edited by
@csibi-levente14 AFAIU, currently the multiprocessing module is used only for optimization.
Unfortunately even in multiple assets scenario, where one would expect each assets historical date could be pre-loaded simultaneously - it is still done serially:
@vladisld thanks a ton, that's definitely useful to know. Then I'll focus on other aspects of the code and will leave multiprocessing aside for the time being :)
run-out last edited by