def tns_cancel_logic(self, dt, force=False):
    '撤单逻辑'
    if (len(self.active_orders) < 1):
        self.entrust = 0
        return
    for vt_orderid in list(self.active_orders.keys()):
        order_info = self.active_orders.get(vt_orderid)
        order_grid = order_info.get('grid', None)
        if (order_info.get('status', None) in [Status.CANCELLED, Status.REJECTED]):
            self.active_orders.pop(vt_orderid, None)
            continue
        order_time = order_info.get('order_time')
        over_ms = (dt - order_time).total_seconds()
        if (f'{dt.hour}:{dt.minute}' in ['10:30', '13:30']):
            continue
        if ((over_ms > self.cancel_seconds) or force):
            self.write_log(f'{dt}, 超时{over_ms}秒未成交，取消委托单：{order_info}')
            if self.cancel_order(vt_orderid):
                order_info.update({'status': Status.CANCELLING})
            else:
                order_info.update({'status': Status.CANCELLED})
                if order_grid:
                    if (vt_orderid in order_grid.order_ids):
                        order_grid.order_ids.remove(vt_orderid)
                    if (len(order_grid.order_ids) == 0):
                        order_grid.order_status = False
    if (len(self.active_orders) < 1):
        self.entrust = 0
撤单逻辑
def tns_cancel_logic(self, dt, force=False):
    
    if (len(self.active_orders) < 1):
        self.entrust = 0
        return
    for vt_orderid in list(self.active_orders.keys()):
        order_info = self.active_orders.get(vt_orderid)
        order_grid = order_info.get('grid', None)
        if (order_info.get('status', None) in [Status.CANCELLED, Status.REJECTED]):
            self.active_orders.pop(vt_orderid, None)
            continue
        order_time = order_info.get('order_time')
        over_ms = (dt - order_time).total_seconds()
        if (f'{dt.hour}:{dt.minute}' in ['10:30', '13:30']):
            continue
        if ((over_ms > self.cancel_seconds) or force):
            self.write_log(f'{dt}, 超时{over_ms}秒未成交，取消委托单：{order_info}')
            if self.cancel_order(vt_orderid):
                order_info.update({'status': Status.CANCELLING})
            else:
                order_info.update({'status': Status.CANCELLED})
                if order_grid:
                    if (vt_orderid in order_grid.order_ids):
                        order_grid.order_ids.remove(vt_orderid)
                    if (len(order_grid.order_ids) == 0):
                        order_grid.order_status = False
    if (len(self.active_orders) < 1):
        self.entrust = 0