BarGenerator下的update_bar函数如下,举个例子,我要形成1个小时的bar,以股指期货IC为例,中午是11:29收盘,下午是13:00开盘,形成的60分钟bar,从11:00开始,下一个bar是从14:00开始,中间缺失了13:00这根Bar。
def update_bar(self, bar: BarData):
    """
    Update 1 minute bar into generator
    """
    if not self.xmin_bar:
        self.xmin_bar = BarData(
            symbol=bar.symbol,
            exchange=bar.exchange,
            datetime=bar.datetime,
            gateway_name=bar.gateway_name,
            open_price=bar.open_price,
            high_price=bar.high_price,
            low_price=bar.low_price
        )
    else:
        self.xmin_bar.high_price = max(
            self.xmin_bar.high_price, bar.high_price)
        self.xmin_bar.low_price = min(
            self.xmin_bar.low_price, bar.low_price)
    self.xmin_bar.close_price = bar.close_price
    self.xmin_bar.volume += int(bar.volume)
    if not (bar.datetime.minute + 1) % self.xmin:
        self.xmin_bar.datetime = self.xmin_bar.datetime.replace(
            second=0, microsecond=0
        )
        self.on_xmin_bar(self.xmin_bar)
        self.xmin_bar = None
是否这样修改可以?
。。。
if not (bar.datetime.minute + 1) % self.xmin or bar.datetime.hour != self.xmin_bar.datetiem.hour:
。。。
