0

This is my code:

data15 = bt.feeds.GenericCSVData(dataname='BTCUSDT-15m-2022-01-01.csv',
dtformat=lambda x: datetime.utcfromtimestamp(int(x)/1000))

from csvgeneric.py:

dt = datetime.strptime(dtfield, dtformat)
    else:
        dt = self._dtconvert(dtfield)

    if self.p.timeframe >= TimeFrame.Days:
        # check if the expected end of session is larger than parsed
        if self._tzinput:
            dtin = self._tzinput.localize(dt)  # pytz compatible-ized
        else:
            dtin = dt

        dtnum = date2num(dtin)  # utc'ize

        dteos = datetime.combine(dt.date(), self.p.sessionend)
        dteosnum = self.date2num(dteos)  # utc'ize

        if dteosnum > dtnum:
            self.lines.datetime[0] = dteosnum

I see that for each candle, dt, dtin and dtnum are correct. dteosnum is the same all the time, and larger than dtnum, so dteosnum is the one assigned to the next candle (self.lines.datetime[0]).

So all candles get the same time.

Rony Tesler
  • 1,207
  • 15
  • 25
  • For dtnum you call date2num: `dtnum = date2num(dtin)`, as for dteosnum you call self.date2num: `dteosnum = self.date2num(dteos)`. It is supposed to be like that? – A. Herlas Oct 10 '22 at 17:46
  • @A.Herlas This is the library's code. Anyway I debugged the implementation of self.date2num and eventually it also calls date2num(). – Rony Tesler Oct 10 '22 at 22:29

0 Answers0