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/

    PeriodStats

    General Code/Help
    2
    2
    588
    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.
    • PeterCHK
      PeterCHK last edited by

      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.

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

        Check Release 1.9.60.122 which addresses this issue. Community - Release 1.9.60.122

        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(); }); }