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

PeriodStats



  • I am currently using Python 3.6, it went smooth on using most of the Analyzers classes. However, there is one incompatible with the Python 3.x.

    I am not quite sure how to deal with this.

      cerebro.addanalyzer(btanalyzers.PeriodStats, _name='PeriodStats')
      strategies = cerebro.run()
      strategy = strategies[0]
      print('periodstats:', strategy.analyzers.PeriodStats.get_analysis())
    

    In the periodstats.py, it shows, NameError: name 'itervalues' is not defined

    def stop(self):
        trets = self._tr.get_analysis()  # dict key = date, value = ret
        pos = nul = neg = 0
        trets = list(itervalues(trets))
    

    I tried to change itervalues to values, but in vain.

    def stop(self):
        trets = self._tr.get_analysis()  # dict key = date, value = ret
        pos = nul = neg = 0
        trets = list(values(trets))
    

    It returns, NameError: name 'values' is not defined.

    Please advise.


Log in to reply
 

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