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/

    Multiple strategy execution

    General Discussion
    2
    4
    881
    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.
    • P
      param.jeet last edited by

      I have 2 strategies and running over same dataset. I am running following command

      Add a strategy

      cerebro.addstrategy(FirstStrategy)
      cerebro.addstrategy(MA_CrossOver)

      cerebro.addanalyzer(bt.analyzers.PyFolio)

      Add the Data Feed to Cerebro

      cerebro.adddata(data)

      Set our desired cash start

      cerebro.broker.setcash(investment)
      cerebro.broker.setcommission(commission=0.001)

      Run over everything

      results= cerebro.run()

      When I run these 2 strategies then magic happens and traders entered by one strategy are cancelled out by other strategy. Isn't it the weird behavior?
      Logically, traders entered by strategy one should be exited by same strategy, not by the other.

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @param.jeet last edited by

        @param-jeet said in Multiple strategy execution:

        Isn't it the weird behavior?

        Single account broker. If both strategies operate on the same asset you are operating weirdly.

        1 Reply Last reply Reply Quote 0
        • P
          param.jeet last edited by

          My idea of having multiple strategies on single instrument is to control drawdown / risk. This multiple strategy concept halps to maximizze return with minimizing return to some extent. We are not going to put whole investment in one single logic rather multiple logics or strategies. Yes, I want to use single broker account and run all strategies in parallel. Any idea, How can I do that? I had enumerated over strategies but that process in sequential not parallel, How to run all strategies in parallel, is what I am interested in now?

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            It seems you have missed the meaning of the answer above.

            • A single account broker means that any action on an asset, regardless of the origin strategy will affect what the other strategies are doing

            • From a logical point of view strategies are run in parallel. The implementation executes them sequentially because Python doesn't have parallel thread execution (the thread model is valid for I/O bound threads but not for CPU bound threads which is the case here)

            What you want is clear, but it's not there.

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