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/

    Analyzers stats when datas have only trading days

    Indicators/Strategies/Analyzers
    3
    5
    501
    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.
    • exu
      exu last edited by

      Hi there,
      I'd like to know if the fact that a line has only trading days (i.e 180 days instead of 365) in a year, could affect analyzers calculations such as annualized returns, because something like that would be wrong:

      dt = st.data._dataname['open'].index
      bt_period = dt[-1] - dt[0]
      bt_period_days = bt_period.days
      annual_return_pct = (1 + total_return)**(365.25 / bt_period_days) - 100)
      
      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        I've used different sources of data for stocks and futures, but never seen weekends or holidays included in the data sets. I assume that the standard approach is to skip empty days and keep only trading days.

        bt uses standard number of days (252) for the annualization.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 1
        • exu
          exu last edited by

          @ab_trader :
          Thanks, yes of course. The example above came from this guy's performance report:
          https://github.com/Oxylo/btreport/blob/master/report.py and it relies on ALL the days of the period, just checking on how the built-in analyzers deal with that...

          A B 2 Replies Last reply Reply Quote 0
          • A
            ab_trader @exu last edited by

            @exu

            The calculations above looks correct. Doesn't matter how many trading days you have, dt[-1] - dt[0] will give you calendar number of days.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 0
            • B
              backtrader administrators @exu last edited by

              @exu said in Analyzers stats when datas have only trading days:

              just checking on how the built-in analyzers deal with that...

              I fail to understand what the built-in analyzers have to deal with. They have de-facto default values (the ones mostly used by the industry/people/call-it-X) which you can customize to your liking.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors