Administrator
2024-10-21 bea977458173f2e60971bad2d6f1e3183070c5ca
bug修改
2个文件已修改
36 ■■■■■ 已修改文件
cancel_strategy/s_l_h_cancel_strategy.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cancel_strategy/s_l_h_cancel_strategy.py
@@ -16,7 +16,7 @@
from utils import tool
from l2.transaction_progress import TradeBuyQueue
from trade import l2_trade_factor, trade_record_log_util
from trade import l2_trade_factor, trade_record_log_util, trade_constant
from l2 import l2_log, l2_data_source_util
from l2.l2_data_util import L2DataUtil, local_today_datas, local_today_canceled_buyno_map, local_today_buyno_map
from log_module.log import logger_l2_s_cancel, logger_debug, logger_l2_l_cancel, logger_l2_h_cancel
@@ -1648,20 +1648,22 @@
    def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code):
        if buy_exec_index is None:
            return False, None, "尚未找到下单位置"
            return False, None, "尚未找到下单位置", None
        # 守护S撤以外的数据
        if int(tool.get_now_time_str().replace(":", "")) > int("145700") and not constant.TEST:
            return False, None, ""
            return False, None, "", None
        try:
            LCancelOutOfDateWatchIndexesManager().process(code, start_index, end_index)
        except Exception as e:
            l2_log.l_cancel_debug("L后稳定更新出错:{}", str(e))
        # 下单位临近撤
        can_cancel, cancel_data = False, None
        can_cancel, cancel_data, cancel_type = False, None, None
        try:
            can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index,
                                                                 total_data,
                                                                 is_first_code)
            if can_cancel:
                cancel_type = trade_constant.CANCEL_TYPE_L_DOWN
        except Exception as e:
            logger_l2_l_cancel.exception(e)
            raise e
@@ -1673,6 +1675,8 @@
                                                                                            start_index, end_index,
                                                                                            total_data,
                                                                                            is_first_code)
                if can_cancel:
                    cancel_type = trade_constant.CANCEL_TYPE_L_UP
                extra_msg = "L前"
            except Exception as e:
                logger_l2_l_cancel.exception(e)
@@ -1692,7 +1696,7 @@
        except Exception as e:
            l2_log.l_cancel_debug(code, "L后后半段计算出错:{}", str(e))
        return can_cancel, cancel_data, extra_msg
        return can_cancel, cancel_data, extra_msg, cancel_type
    def place_order_success(self, code):
        self.clear(code)
l2/l2_data_manager_new.py
@@ -600,13 +600,14 @@
        def l_cancel(_buy_single_index, _buy_exec_index):
            _start_time = round(t.time() * 1000)
            try:
                b_need_cancel, b_cancel_data, extra_msg = cls.__LCancelBigNumComputer.need_cancel(code,
                                                                                                  _buy_exec_index,
                                                                                                  start_index,
                                                                                                  end_index, total_data,
                                                                                                  is_first_code)
                b_need_cancel, b_cancel_data, extra_msg, b_cancel_type = cls.__LCancelBigNumComputer.need_cancel(code,
                                                                                                                 _buy_exec_index,
                                                                                                                 start_index,
                                                                                                                 end_index,
                                                                                                                 total_data,
                                                                                                                 is_first_code)
                if b_need_cancel and b_cancel_data:
                    return b_cancel_data, f"L撤({extra_msg})"
                    return b_cancel_data, f"L撤({extra_msg})", b_cancel_type
            except Exception as e:
                async_log_util.error(logger_l2_error,
                                     f"L撤出错 参数:buy_single_index-{_buy_single_index} buy_exec_index-{_buy_exec_index} 错误原因:{str(e)}")
@@ -615,7 +616,7 @@
            finally:
                # l2_data_log.l2_time(code, round(t.time() * 1000) - _start_time, "已下单-L撤大单计算")
                pass
            return None, ""
            return None, "", None
        # G撤
        def g_cancel(_buy_single_index, _buy_exec_index):
@@ -680,8 +681,8 @@
            cancel_type = trade_constant.CANCEL_TYPE_G
        # 依次处理
        if not cancel_data:
            cancel_data, cancel_msg = l_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
            cancel_type = trade_constant.CANCEL_TYPE_L
            cancel_data, cancel_msg, cancel_type = l_cancel(order_begin_pos.buy_single_index,
                                                            order_begin_pos.buy_exec_index)
        # B撤
        if not cancel_data:
            cancel_data, cancel_msg = b_cancel(order_begin_pos.buy_single_index, order_begin_pos.buy_exec_index)
@@ -1367,7 +1368,8 @@
        if cancel_type != trade_constant.CANCEL_TYPE_HUMAN:
            # 是否是交易队列触发
            # 扫入下单只有L撤能撤单
            if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL and cancel_type not in {trade_constant.CANCEL_TYPE_L_DOWN}:
            if order_begin_pos and order_begin_pos.mode == OrderBeginPosInfo.MODE_RADICAL and cancel_type not in {
                trade_constant.CANCEL_TYPE_L_DOWN, trade_constant.CANCEL_TYPE_L}:
                l2_log.cancel_debug(code, "撤单中断,原因:{}", "扫入下单不是L撤")
                return False
            # 加绿只有L撤/人撤生效