For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

resample is not working

  • 15f07e99-aefe-4055-9d19-8bfecc8b3a93-image.png ![alt text](image url)

    I'm tring to resmaple 1 minute bar to 10 minutes, but the line not update after resampled

  • dcebcfab-3b2b-44c0-9bd1-a8b93e2b57b4-image.png

    The output

  • administrators

    RESAMPLE IS WORKING. When your 1-min gets to 16:00:00 (from 15:59:00) the 10-min resampled data moves from 15:50:00 to 16: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.

  • @backtrader

    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
  [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([0]),[0], '      ' , bt.num2date(self.data1.datetime[0]), self.data1.close[0])
    cerebro = bt.Cerebro()
    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(data1)
    cerebro.resampledata(data0, compression=10, timeframe=bt.TimeFrame.Minutes)

    The datetime looks the same. And i had try rightedge=False when calling resample, 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 and volume all are not updated.

    I don't know where there is the problem, I have been delayed by this problem for 2 days.

  • administrators

    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.

Log in to reply