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.