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



  • 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.


  • administrators

    @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.



  • 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?


  • administrators

    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.