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/

    Reusing cerebro object

    General Discussion
    2
    4
    1197
    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.
    • dimitar-petrov
      dimitar-petrov last edited by

      Hello,

      I am wondering is it possible to reuse cerebro object.
      The use case is following:

      1. Add the data
      2. Add strategy
      3. Run the backtest
      4. Remove strategy
      5. Add another strategy.
      6. Run backtest
        ...
        k-2. Remove the strategy
        k-1. Add another trategy
        k. Run backtest
        ...

      My point is to keep the data loaded into memory and not recreate another cerebro object and load the data in order to back test again.

      Is there an easy way to rewind the data and add different strategy.

      BR,
      Dimitar

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

        Optimization tries to keep the data preloaded and in memory.

        This post (Blog - Strategy Selection) details exactly the use case you have.

        The SUO (Strategy Under Optimization) is really a Strategy Factory. It only shows 2 strategies and a [0, 1] list to select either the 1st or the second. But you could also pass a range(len(mylistofstrategies)) and hold your strategies in that mylistofstrategies

        Actually with some metaclass programming, the strategies can register themselves in a master list, avoiding the manual addition of the new strategies to the list.

        1 Reply Last reply Reply Quote 1
        • dimitar-petrov
          dimitar-petrov last edited by

          Thanks for the prompt response.
          I will take a look @ the article.

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

            See this update for: Blog - Strategy Selection Revisited

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }