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/

    How to process data by quarter?

    General Discussion
    2
    2
    150
    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.
    • jrothschild33
      jrothschild33 last edited by

      I want to resample or replay data by quarter, but find that bt.TimeFrame only support 'Days', 'Weeks', 'Months', 'Years',there is no 'Quarters' option.

      I know a simple way to process data quarterly is use compression, for example:

        tframes = dict( daily=bt.TimeFrame.Days,
                          weekly=bt.TimeFrame.Weeks,
                          monthly=bt.TimeFrame.Months)
      
        cerebro.replaydata(data,timeframe=tframes['monthly'],compression=3)
      
      

      You have to make sure the data is started on January,or the result will only compression by 3 continuous months, not by quarter.

      I hope someone could help me to solve this problem.

      vladisld 1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld @jrothschild33 last edited by

        @jrothschild33 said in How to process data by quarter?:

        You have to make sure the data is started on January,or the result will only compression by 3 continuous months, not by quarter.

        AFAIU this is the only option right now. Properly solving this should involve extending Backtrader to support yet another TimeFrame with all the ensuing consequences.

        Others may correct me of cause.

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