if self.interval == Interval.MINUTE:
# x bar
if not (bar.datetime.minute + 1) % self.window:
finished = True
elif self.last_bar and str(bar.datetime)[-8:] == '10:14:00':
finished = True
self.interval_count = 0
elif self.interval == Interval.HOUR:
if self.last_bar and bar.datetime.hour != self.last_tick.datetime.hour:
# 1-hour bar
if self.window == 1:
finished = True
# x-hour bar
else:
self.interval_count += 1
if not self.interval_count % self.window:
finished = True
self.interval_count = 0
# elif self.interval == Interval.DAILY:
# day_end = datetime.time(14, 59)
# if bar.exchange == Exchange.CFFEX and bar.symbol.startswith("T"):
# day_end = time(15, 14)
# if bar.datetime.time() == day_end:
# finished = True
# self.interval_count = 0
elif self.interval == Interval.DAILY:
if self.last_bar and str(bar.datetime)[-8:] == '14:59:00':
if self.window == 1:
finished = True
# x-hour bar
else:
self.interval_count += 1
if not self.interval_count % self.window:
finished = True
self.interval_count = 0
if finished:
self.on_window_bar(self.window_bar)
self.window_bar = None
# cache last bar object
self.last_bar = bar