Reusing cerebro object



  • 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


  • administrators

    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.



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


  • administrators


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.