Many Strategies as individual Modules
-
Hello everyone,
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 ?
@vladisld @run-out @ab_trader and other experienced users, I would appreciate any help in this regard.
People who trade or backtest multiple strategies how do you guys go about it.
Thanks for reading.
-
regarding the notify_order:
AFAIU the
notify_order
notification for givenorder
object 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_order
notifications for this order instance.As for
notify_data
notification - once again AFAIU - it works differently, since data objects are stored per Cerebro instance and not per strategy - sonotify_data
notification will be called for each data object on each strategy.It seems the
notify_store
works the same asnotify_data
in 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_trade
should be owned by owner as well as in the case ofnotify_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.