enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.48k stars 236 forks source link

Add an option to change the number of cores #402

Open mikeejazmines opened 2 years ago

mikeejazmines commented 2 years ago

resolves #370

Description

There is a feature in backtrader wherein you are able to change the max number of CPUs used to utilize multiprocessing. This has been included as a configurable option in the fastquant backtest wrapper. By default, it will be set to 1. Set it to None to utilize all available cores.

Documentation: https://www.backtrader.com/blog/posts/2015-07-23-multicore-optimization/multicore-optimization/ https://github.com/mementum/backtrader/blob/0fa63ef4a35dc53cc7320813f8b15480c8f85517/backtrader/cerebro.py#L80

Checklist

mikeejazmines commented 2 years ago

Testing this there is an issue of Can't pickle local object 'initalize_data.<locals>.CustomData'

This was brought up already in this thread https://community.backtrader.com/topic/2919/error-in-multi-core-optimization however i havent found a solution for this

mikeejazmines commented 2 years ago

This would not work given the current usage of multiprocessing. This does not allow the serialization of lambda, and needs to use dill for pickling.