Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Many Strategies as individual Modules

    General Code/Help
    2
    4
    210
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rajanprabu last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        regarding the notify_order:

        AFAIU the notify_order notification for given order 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 - so notify_data notification will be called for each data object on each strategy.

        It seems the notify_store works the same as notify_data in this regard.

        R 2 Replies Last reply Reply Quote 1
        • R
          rajanprabu @vladisld last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • R
            rajanprabu @vladisld last edited by

            @vladisld

            Please ignore my last question. Of course notify_trade should 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.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors