resample is not working
-

I'm tring to resmaple 1 minute bar to 10 minutes, but the line not update after resampled
-
The output
-
RESAMPLE IS WORKING. When your
1-min
gets to16:00:00
(from15:59:00
) the10-min
resampled data moves from15:50:00
to16:00:00
.And every 10 minutes, history repeats itself.
As expected.
Note: I imagine there is a world conspiracy somewhere and I missed it by virtue of age. Because pasting images it is a lot more difficult than pasting text, which can quoted.
-
class MyCSVData(bt.feeds.GenericCSVData): def _loadline(self, linetokens): itoken = iter(linetokens) dttxt = next(itoken) # Format is YYYY-MM-DD - skip char 4 and 7 dt = bt.date2num(datetimeParser.parse(dttxt)) self.lines.datetime[0] = dt self.lines.open[0] = float(next(itoken)) self.lines.high[0] = float(next(itoken)) self.lines.low[0] = float(next(itoken)) self.lines.close[0] = float(next(itoken)) self.lines.volume[0] = float(next(itoken)) self.lines.openinterest[0] = 0 return True class Test(bt.Strategy): def next(self): print(bt.num2date(self.data.datetime[0]), self.data.close[0], ' ' , bt.num2date(self.data1.datetime[0]), self.data1.close[0]) cerebro = bt.Cerebro() cerebro.broker.set_cash(15000000) csv = '20181010-1013.csv' # data0 = MyCSVData(dataname=csv, timeframe=bt.TimeFrame.Minutes) data0 = bt.feeds.GenericCSVData(dataname=csv, timeframe=bt.TimeFrame.Minutes, openinterest=-1) cerebro.adddata(data0) # cerebro.adddata(data1) cerebro.resampledata(data0, compression=10, timeframe=bt.TimeFrame.Minutes)
The
datetime
looks the same. And i had tryrightedge=False
when callingresample
, But the results have not changed.Thanks for your help!
-
The 10 minutes bar always equals to the first 1 minutes bar,
open
close
high
low
andvolume
all are not updated.I don't know where there is the problem, I have been delayed by this problem for 2 days.
-
A bar can only be resampled when the period is complete. The bar does not equal the first
1-minute
bar. The timestamp is the same until the next resample cycle is complete.It would seem you are looking for
replay
, which is something different. Take a break and try to understand the concepts.