Many Strategies as individual Modules
Im doing live trading with Backtrader and it works perfectly fine. I want to add more strategies to it. To make it easier to I want to keep each strategy class in different python file and use them in BT live script. Import as a module and running is working. But I have few questions.
Do we need to have notify_data, notify_store etc in each class or only in one.
How does notify_order work. Will it notify all strategies if I have them in each indiscriminately ?
People who trade or backtest multiple strategies how do you guys go about it.
Thanks for reading.
vladisld last edited by
regarding the notify_order:
notify_ordernotification for given
orderobject is only sent to the order's "owner", where the "owner" being the strategy instance which created this particular order in the first place.
So it seems that when multiple strategies are running, only the strategy that originated given order will get the
notify_ordernotifications for this order instance.
notify_datanotification - once again AFAIU - it works differently, since data objects are stored per Cerebro instance and not per strategy - so
notify_datanotification will be called for each data object on each strategy.
It seems the
notify_storeworks the same as
notify_datain this regard.
Thanks @vladisld. Appreciate it, I could wish I give 100 likes.
One more question in this regard if you dont mind. How does notify_trade work. Somehow only my first strategy works and second strategy doest not print it.
Please ignore my last question. Of course
notify_tradeshould be owned by owner as well as in the case of
notify_order. I made a simple test case and it worked perfectly fine. Something must be wrong in my production script. I will have a look. Thanks for your time and effort.