WeekDaysFiller & Resample issue.
-
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,0Based 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.pyI 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.0BUT, 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.0Do you have any clue or comment about what I'm missing or doing wrong?
Thanks in advance.