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/

    WeekDaysFiller & Resample issue.

    General Code/Help
    1
    1
    48
    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.
    • E
      ET28 DE10 last edited by

      Hi all, I'm facing an issue while trying to use WeekDaysFiller and after that do a resampling.
      The target is to have complete weekly information resampling not complete daily data.
      Base data can be seen here:

      date,1. open,2. high,3. low,4. close,5. volume,openint
      2021-06-30,180.0,180.0,180.0,180.0,141240,0
      2021-07-29,181.0,181.0,181.0,181.0,700,0
      2021-08-12,180.0,180.0,180.0,180.0,100,0
      2021-08-24,181.0,181.0,181.0,181.0,500,0
      2021-08-31,179.5,179.5,179.5,179.5,1156,0
      2021-09-07,179.5,179.5,179.5,179.5,0,0
      2021-09-10,179.5,179.5,179.5,179.5,0,0
      2021-10-04,180.0,180.0,180.0,180.0,225,0
      2021-10-06,181.0,181.0,181.0,181.0,1000,0

      Based on the information of the following links:
      #https://www.backtrader.com/blog/posts/2016-04-19-sync-different-markets/sync-different-markets/
      #https://github.com/mementum/backtrader/blob/master/samples/weekdays-filler/weekdaysaligner.py

      I applied the WeekDaysFiller:

      data.addfilter(WeekDaysFiller, fillclose=True)
      

      And the result was the expected one:

      date,1. open,2. high,3. low,4. close
      2021-06-30 180.0 180.0 180.0 180.0
      2021-07-01 180.0 180.0 180.0 180.0
      ........
      021-08-11 181.0 181.0 181.0 181.0
      2021-08-12 180.0 180.0 180.0 180.0
      .......
      2021-08-23 180.0 180.0 180.0 180.0
      2021-08-24 181.0 181.0 181.0 181.0
      ......
      2021-09-24 179.5 179.5 179.5 179.5
      2021-09-27 179.5 179.5 179.5 179.5
      2021-09-28 179.5 179.5 179.5 179.5
      .......
      2021-10-04 180.0 180.0 180.0 180.0
      2021-10-05 180.0 180.0 180.0 180.0
      2021-10-06 181.0 181.0 181.0 181.0

      BUT, if after this Filler I try to do the resampling it do nothing:

              data.addfilter(WeekDaysFiller, fillclose=True)
                  
              cerebro.resampledata(data,
                   timeframe=bt.TimeFrame.Weeks,
                   compression=1)
      

      Note: If I apply the resample without applying WeekDaysFiller I got the resampled data but of course I got also a lot of holes in the information:

      date,1. open,2. high,3. low,4. close
      2021-06-30 180.0 185.0 180.0 180.0
      2021-07-29 181.0 181.0 181.0 181.0
      2021-08-12 180.0 180.0 180.0 180.0
      2021-08-24 181.0 181.0 181.0 181.0
      2021-08-31 179.5 179.5 179.5 179.5
      2021-09-10 179.5 179.5 179.5 179.5
      2021-10-06 180.0 181.0 180.0 181.0

      Do you have any clue or comment about what I'm missing or doing wrong?

      Thanks in advance.

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