For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

analyzers erro: AttributeError: 'list' object has no attribute 'analyzers'

  • Hello! When studying this library, I ran into a problem.

    I do everything on the lesson of trade analysis. But I get an error.

    My cod:

    cerebro = bt.Cerebro(stdstats=False)
        data = PandasData(dataname=df, timeframe=bt.TimeFrame.Minutes)
        cerebro.addanalyzer(TradeAnalyzer, _name="ta")
        thestrats =
        strat = thestrats[0]


    AttributeError: 'list' object has no attribute 'analyzers'

    What is the problem?

  • IIRC if optstrategy is used, the 'run' method will return a list of lists. Quoting the docs ( 'Returning the results' section of the cerebro section

    Returning the results
    cerebro returns the instances of the strategies it created during backtesting. This allows to analyze what they did, because all elements in the strategies are accessible:
    result =**kwargs)
    The format of result returned by run will vary depending on whether optimization is used (a strategy was added with optstrategy):
        **All strategies added with addstrategy**
        result will be a list of the instances run during the backtesting
        **1 or more strategies were added with optstrategy**
        result will be a list of list. Each internal list will contain the strategies after each optimization run

  • @vladisld Thanks a lot!

Log in to reply