Administrator
2025-07-23 0e642d0c27e40df326733401be6f8c8115e54911
l2/cancel_buy_strategy.py
@@ -11,6 +11,7 @@
import constant
from cancel_strategy import s_l_h_cancel_strategy
from cancel_strategy.s_l_h_cancel_strategy import CancelRateHumanSettingManager
from code_attribute import big_money_num_manager, gpcode_manager, code_volumn_manager
import l2_data_util
from db import redis_manager_delegate as redis_manager
@@ -473,6 +474,11 @@
    # 下单3分钟内距离下单位置不足3笔(包含正在成交)且不到300w就需要撤单
    def need_cancel_for_deal_fast(self, code, trade_index=None):
        # 人为改了撤单比例之后不能生效
        human_rate = CancelRateHumanSettingManager().get_l_down(code)
        if human_rate:
            return False, "人为修改了撤单比例"
        if trade_index is None:
            trade_info = TradeBuyQueue().get_traded_index(code)
            if trade_info and not trade_info[1] and trade_info[0] is not None:
@@ -495,27 +501,26 @@
        # 是否是下单1分钟内
        if tool.trade_time_sub(tool.get_now_time_str(), total_datas[real_order_index]['val']['time']) > 1 * 60:
            return False, "下单超过60s"
        try:
            if code in self.__max_buy_order_num_cache:
                max_num = self.__max_buy_order_num_cache[code]
                if max_num and tool.is_ge_code(code):
                    max_num = max_num * 6.6
                details = HuaXinSellOrderStatisticManager.get_latest_3s_continue_deal_volumes(code)
                threshold_num = int(max_num * 0.5 * 100)
                count = 0
                for d in details:
                    if d[1] > threshold_num:
                        count += 1
                if count >= 2:
                    return True, f"连续3秒有2s抛压过大:{details} 最大值:{max_num}"
        except Exception as e:
            l2_log.f_cancel_debug(code, f"大抛压撤单计算出错:{str(e)}")
        # try:
        #     if code in self.__max_buy_order_num_cache:
        #         max_num = self.__max_buy_order_num_cache[code]
        #         if max_num and tool.is_ge_code(code):
        #             max_num = max_num * 6.6
        #         details = HuaXinSellOrderStatisticManager.get_latest_3s_continue_deal_volumes(code)
        #         threshold_num = int(max_num * 0.5 * 100)
        #         count = 0
        #         for d in details:
        #             if d[1] > threshold_num:
        #                 count += 1
        #         if count >= 2:
        #             return True, f"连续3秒有2s抛压过大:{details} 最大值:{max_num}"
        # except Exception as e:
        #     l2_log.f_cancel_debug(code, f"大抛压撤单计算出错:{str(e)}")
        # 查询最近2秒成交是否超过阈值
        THRESHOLD_MONEY_W, THRESHOLD_COUNT = self.__get_fast_deal_threshold_value(code,
                                                                                  total_datas[real_order_index]['val'][
                                                                                      'time'])
        THRESHOLD_MONEY_W, THRESHOLD_COUNT = 1200, 3  # self.__get_fast_deal_threshold_value(code,
        #                                     total_datas[real_order_index]['val'][
        #                                         'time'])
        total_left_count = 0
        total_left_num = 0