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/

    possible bug in TradeAnalyzer.get_analysis

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

      Hello,

      I am using backtrader==1.9.64.122
      Below you can see the output of bt.analyzers.TradeAnalyzer, accessed by .get_analysis() of the analyzer. The field ['won']['total'] always shows boolean where an int value is expected.

      AutoOrderedDict([('total',
                        AutoOrderedDict([('total', 1), ('open', 0), ('closed', 1)])),
                       ('streak',
                        AutoOrderedDict([('won',
                                          AutoOrderedDict([('current', True),
                                                           ('longest', True)])),
                                         ('lost',
                                          AutoOrderedDict([('current', 0),
                                                           ('longest', 0)]))])),
                       ('pnl',
                        AutoOrderedDict([('gross',
                                          AutoOrderedDict([('total',
                                                            0.0007999999999999119),
                                                           ('average',
                                                            0.0007999999999999119)])),
                                         ('net',
                                          AutoOrderedDict([('total',
                                                            0.0007999999999999119),
                                                           ('average',
                                                            0.0007999999999999119)]))])),
                       ('won',
                        AutoOrderedDict([('total', True),
                                         ('pnl',
                                          AutoOrderedDict([('total',
                                                            0.0007999999999999119),
                                                           ('average',
                                                            0.0007999999999999119),
                                                           ('max',
                                                            0.0007999999999999119)]))])),
                       ('lost',
                        AutoOrderedDict([('total', 0),
                                         ('pnl',
                                          AutoOrderedDict([('total', 0.0),
                                                           ('average', 0.0),
                                                           ('max', 0.0)]))])),
                       ('long',
                        AutoOrderedDict([('total', 1),
                                         ('pnl',
                                          AutoOrderedDict([('total',
                                                            0.0007999999999999119),
                                                           ('average',
                                                            0.0007999999999999119),
                                                           ('won',
                                                            AutoOrderedDict([('total',
                                                                              0.0007999999999999119),
                                                                             ('average',
                                                                              0.0007999999999999119),
                                                                             ('max',
                                                                              0.0007999999999999119)])),
                                                           ('lost',
                                                            AutoOrderedDict([('total',
                                                                              0.0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0.0)]))])),
                                         ('won', True),
                                         ('lost', 0)])),
                       ('short',
                        AutoOrderedDict([('total', 0),
                                         ('pnl',
                                          AutoOrderedDict([('total', 0.0),
                                                           ('average', 0.0),
                                                           ('won',
                                                            AutoOrderedDict([('total',
                                                                              0.0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0.0)])),
                                                           ('lost',
                                                            AutoOrderedDict([('total',
                                                                              0.0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0.0)]))])),
                                         ('won', False),
                                         ('lost', 0)])),
                       ('len',
                        AutoOrderedDict([('total', 15),
                                         ('average', 15.0),
                                         ('max', 15),
                                         ('min', 15),
                                         ('won',
                                          AutoOrderedDict([('total', 15),
                                                           ('average', 15.0),
                                                           ('max', 15),
                                                           ('min', 15)])),
                                         ('lost',
                                          AutoOrderedDict([('total', 0),
                                                           ('average', 0.0),
                                                           ('max', 0)])),
                                         ('long',
                                          AutoOrderedDict([('total', 15),
                                                           ('average', 15.0),
                                                           ('max', 15),
                                                           ('min', 15),
                                                           ('won',
                                                            AutoOrderedDict([('total',
                                                                              15),
                                                                             ('average',
                                                                              15.0),
                                                                             ('max',
                                                                              15),
                                                                             ('min',
                                                                              15)])),
                                                           ('lost',
                                                            AutoOrderedDict([('total',
                                                                              0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0),
                                                                             ('min',
                                                                              9223372036854775807)]))])),
                                         ('short',
                                          AutoOrderedDict([('total', 0),
                                                           ('average', 0.0),
                                                           ('max', 0),
                                                           ('min',
                                                            9223372036854775807),
                                                           ('won',
                                                            AutoOrderedDict([('total',
                                                                              0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0),
                                                                             ('min',
                                                                              9223372036854775807)])),
                                                           ('lost',
                                                            AutoOrderedDict([('total',
                                                                              0),
                                                                             ('average',
                                                                              0.0),
                                                                             ('max',
                                                                              0),
                                                                             ('min',
                                                                              9223372036854775807)]))]))]))])
      AutoOrderedDict([('total', AutoOrderedDict([('total', 0)]))])
      
      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        This is an artifact, because you only have 1 trade and initial sum is done using a won/lost boolean. If you had more trades you wouldn't see True.

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