def on_order_open_canceled(self, order: OrderData):
    '\n        委托开仓单撤销\n        如果是FAK模式，重新修改价格，再提交\n        FAK用于实盘，需要增加涨跌停判断\n        :param order:\n        :return:\n        '
    self.write_log(u'报单更新 => 委托开仓 => 撤销:{}'.format(order.__dict__))
    if (not self.trading):
        if (not self.backtesting):
            self.write_error(u'当前不允许交易')
        return
    if (order.vt_orderid not in self.active_orders):
        self.write_error(u'{}不在未完成的委托单中{}。'.format(order.vt_orderid, self.active_orders))
        return
    old_order = self.active_orders[order.vt_orderid]
    self.write_log(u'报单更新 => {} 未完成订单信息:{}'.format(order.vt_orderid, old_order))
    old_order['traded'] = order.traded
    order_vt_symbol = copy(old_order['vt_symbol'])
    order_volume = (old_order['volume'] - old_order['traded'])
    order_price = old_order['price']
    order_type = old_order.get('order_type', OrderType.LIMIT)
    order_retry = old_order.get('retry', 0)
    grid = old_order.get('grid', None)
    if grid:
        if (order.vt_orderid in grid.order_ids):
            grid.order_ids.remove(order.vt_orderid)
    if (order_volume <= 0):
        msg = u'{} {}{}需重新开仓数量为{}，不再开仓'.format(self.strategy_name, order.vt_orderid, order_vt_symbol, order_volume)
        self.write_error(msg)
        self.write_log(u'移除:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        return
    if (order_retry > 20):
        msg = u'{}  {}/{}手， 重试开仓次数{}>20'.format(self.strategy_name, order_vt_symbol, order_volume, order_retry)
        self.write_error(msg)
        self.send_wechat(msg)
        if (len(grid.order_ids) == 0):
            grid.order_status = False
            self.gt.save()
            self.write_log(u'网格信息更新:{}'.format(grid.__dict__))
        self.write_log(u'移除:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        return
    order_retry += 1
    if ((old_order['direction'] == Direction.LONG) and (order_type == OrderType.FAK)):
        self.write_log(u'移除旧的委托记录:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        if (order.traded > 0):
            old_traded_volume = grid.traded_volume
            grid.traded_volume += order.traded
            self.write_log((f'{grid.direction.value}单部分{order.offset}仓，' + f'网格volume:{grid.volume}, traded_volume:{old_traded_volume}=>{grid.traded_volume}'))
        self.write_log(u'FAK模式，需要重新发送buy委托.grid:{}'.format(grid.__dict__))
        buy_price = (max(self.cur_mi_tick.ask_price_1, self.cur_mi_tick.last_price, order_price) + self.price_tick)
        if ((self.cur_mi_tick.limit_up > 0) and (buy_price > self.cur_mi_tick.limit_up)):
            buy_price = self.cur_mi_tick.limit_up
        if self.is_upper_limit(self.vt_symbol):
            self.write_log(u'{}涨停，不做buy'.format(self.vt_symbol))
            return
        vt_orderids = self.buy(price=buy_price, volume=order_volume, vt_symbol=self.vt_symbol, order_type=OrderType.FAK, order_time=self.cur_datetime, grid=grid)
        if (not vt_orderids):
            self.write_error(u'重新提交{} {}手开多单,价格：{}，失败'.format(self.vt_symbol, order_volume, buy_price))
            return
        for vt_orderid in vt_orderids:
            info = self.active_orders.get(vt_orderid, None)
            info.update({'retry': order_retry})
        self.gt.save()
    elif ((old_order['direction'] == Direction.SHORT) and (order_type == OrderType.FAK)):
        self.write_log(u'移除旧的委托记录:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        if (order.traded > 0):
            old_traded_volume = grid.traded_volume
            grid.traded_volume += order.traded
            self.write_log((f'{grid.direction.value}单部分{order.offset}仓，' + f'网格volume:{grid.volume}, traded_volume:{old_traded_volume}=>{grid.traded_volume}'))
        self.write_log(u'FAK模式，需要重新发送short委托.grid:{}'.format(grid.__dict__))
        short_price = (min(self.cur_mi_tick.bid_price_1, self.cur_mi_tick.last_price, order_price) - self.price_tick)
        if ((self.cur_mi_tick.limit_down > 0) and (short_price < self.cur_mi_tick.limit_down)):
            short_price = self.cur_mi_tick.limit_down
        if self.is_lower_limit(self.vt_symbol):
            self.write_log(u'{}跌停，不做short'.format(self.vt_symbol))
            return
        vt_orderids = self.short(price=short_price, volume=order_volume, vt_symbol=self.vt_symbol, order_type=OrderType.FAK, order_time=self.cur_datetime, grid=grid)
        if (not vt_orderids):
            self.write_error(u'重新提交{} {}手开空单,价格:{}, 失败'.format(self.vt_symbol, order_volume, short_price))
            return
        for vt_orderid in vt_orderids:
            info = self.active_orders.get(vt_orderid, None)
            info.update({'retry': order_retry})
        self.gt.save()
    else:
        pre_status = old_order.get('status', Status.NOTTRADED)
        old_order.update({'status': Status.CANCELLED})
        self.write_log(u'委托单方式{},状态:{}=>{}'.format(order_type, pre_status, old_order.get('status')))
        if grid:
            if (order.vt_orderid in grid.order_ids):
                grid.order_ids.remove(order.vt_orderid)
            if (not grid.order_ids):
                grid.order_status = False
            self.gt.save()
        self.active_orders.update({order.vt_orderid: old_order})
    self.display_grids()
委托开仓单撤销
如果是FAK模式，重新修改价格，再提交
FAK用于实盘，需要增加涨跌停判断
:param order:
:return:
def on_order_open_canceled(self, order: OrderData):
    '\n        委托开仓单撤销\n        如果是FAK模式，重新修改价格，再提交\n        FAK用于实盘，需要增加涨跌停判断\n        :param order:\n        :return:\n        '
    self.write_log(u'报单更新 => 委托开仓 => 撤销:{}'.format(order.__dict__))
    if (not self.trading):
        if (not self.backtesting):
            self.write_error(u'当前不允许交易')
        return
    if (order.vt_orderid not in self.active_orders):
        self.write_error(u'{}不在未完成的委托单中{}。'.format(order.vt_orderid, self.active_orders))
        return
    old_order = self.active_orders[order.vt_orderid]
    self.write_log(u'报单更新 => {} 未完成订单信息:{}'.format(order.vt_orderid, old_order))
    old_order['traded'] = order.traded
    order_vt_symbol = copy(old_order['vt_symbol'])
    order_volume = (old_order['volume'] - old_order['traded'])
    order_price = old_order['price']
    order_type = old_order.get('order_type', OrderType.LIMIT)
    order_retry = old_order.get('retry', 0)
    grid = old_order.get('grid', None)
    if grid:
        if (order.vt_orderid in grid.order_ids):
            grid.order_ids.remove(order.vt_orderid)
    if (order_volume <= 0):
        msg = u'{} {}{}需重新开仓数量为{}，不再开仓'.format(self.strategy_name, order.vt_orderid, order_vt_symbol, order_volume)
        self.write_error(msg)
        self.write_log(u'移除:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        return
    if (order_retry > 20):
        msg = u'{}  {}/{}手， 重试开仓次数{}>20'.format(self.strategy_name, order_vt_symbol, order_volume, order_retry)
        self.write_error(msg)
        self.send_wechat(msg)
        if (len(grid.order_ids) == 0):
            grid.order_status = False
            self.gt.save()
            self.write_log(u'网格信息更新:{}'.format(grid.__dict__))
        self.write_log(u'移除:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        return
    order_retry += 1
    if ((old_order['direction'] == Direction.LONG) and (order_type == OrderType.FAK)):
        self.write_log(u'移除旧的委托记录:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        if (order.traded > 0):
            old_traded_volume = grid.traded_volume
            grid.traded_volume += order.traded
            self.write_log((f'{grid.direction.value}单部分{order.offset}仓，' + f'网格volume:{grid.volume}, traded_volume:{old_traded_volume}=>{grid.traded_volume}'))
        self.write_log(u'FAK模式，需要重新发送buy委托.grid:{}'.format(grid.__dict__))
        buy_price = (max(self.cur_mi_tick.ask_price_1, self.cur_mi_tick.last_price, order_price) + self.price_tick)
        if ((self.cur_mi_tick.limit_up > 0) and (buy_price > self.cur_mi_tick.limit_up)):
            buy_price = self.cur_mi_tick.limit_up
        if self.is_upper_limit(self.vt_symbol):
            self.write_log(u'{}涨停，不做buy'.format(self.vt_symbol))
            return
        vt_orderids = self.buy(price=buy_price, volume=order_volume, vt_symbol=self.vt_symbol, order_type=OrderType.FAK, order_time=self.cur_datetime, grid=grid)
        if (not vt_orderids):
            self.write_error(u'重新提交{} {}手开多单,价格：{}，失败'.format(self.vt_symbol, order_volume, buy_price))
            return
        for vt_orderid in vt_orderids:
            info = self.active_orders.get(vt_orderid, None)
            info.update({'retry': order_retry})
        self.gt.save()
    elif ((old_order['direction'] == Direction.SHORT) and (order_type == OrderType.FAK)):
        self.write_log(u'移除旧的委托记录:{}'.format(order.vt_orderid))
        self.active_orders.pop(order.vt_orderid, None)
        if (order.traded > 0):
            old_traded_volume = grid.traded_volume
            grid.traded_volume += order.traded
            self.write_log((f'{grid.direction.value}单部分{order.offset}仓，' + f'网格volume:{grid.volume}, traded_volume:{old_traded_volume}=>{grid.traded_volume}'))
        self.write_log(u'FAK模式，需要重新发送short委托.grid:{}'.format(grid.__dict__))
        short_price = (min(self.cur_mi_tick.bid_price_1, self.cur_mi_tick.last_price, order_price) - self.price_tick)
        if ((self.cur_mi_tick.limit_down > 0) and (short_price < self.cur_mi_tick.limit_down)):
            short_price = self.cur_mi_tick.limit_down
        if self.is_lower_limit(self.vt_symbol):
            self.write_log(u'{}跌停，不做short'.format(self.vt_symbol))
            return
        vt_orderids = self.short(price=short_price, volume=order_volume, vt_symbol=self.vt_symbol, order_type=OrderType.FAK, order_time=self.cur_datetime, grid=grid)
        if (not vt_orderids):
            self.write_error(u'重新提交{} {}手开空单,价格:{}, 失败'.format(self.vt_symbol, order_volume, short_price))
            return
        for vt_orderid in vt_orderids:
            info = self.active_orders.get(vt_orderid, None)
            info.update({'retry': order_retry})
        self.gt.save()
    else:
        pre_status = old_order.get('status', Status.NOTTRADED)
        old_order.update({'status': Status.CANCELLED})
        self.write_log(u'委托单方式{},状态:{}=>{}'.format(order_type, pre_status, old_order.get('status')))
        if grid:
            if (order.vt_orderid in grid.order_ids):
                grid.order_ids.remove(order.vt_orderid)
            if (not grid.order_ids):
                grid.order_status = False
            self.gt.save()
        self.active_orders.update({order.vt_orderid: old_order})
    self.display_grids()