Administrator
2025-06-27 9949e2de0c9f0624a0698a305b5d3ad52799e906
cancel_strategy/s_l_h_cancel_strategy.py
@@ -1478,7 +1478,7 @@
            l2_log.l_cancel_debug(code, "将L2后后半段备用大单加入计算出错:{}", str(e))
        # 计算监听的总条数
        total_num = 0
        max_num = 0
        max_num, max_num_count = 0, 0
        thresh_hold_rate, must_buy = LCancelRateManager.get_cancel_rate(code)
        for wi in watch_indexes:
@@ -1497,6 +1497,9 @@
            total_num += total_data[wi]["val"]["num"] * total_data[wi]["re"]
            if total_data[wi]["val"]["num"] > max_num:
                max_num = total_data[wi]["val"]["num"]
                max_num_count = 1
            elif total_data[wi]["val"]["num"] == max_num:
                max_num_count += 1
        # 判断撤单中是否有监听中的索引
        need_compute = False
        for i in range(start_index, end_index + 1):
@@ -1548,13 +1551,13 @@
            # 除开最大单的影响权重
            if not must_buy:
                temp_thresh_hold_rate = round((total_num - max_num) * 0.9 / total_num, 2)
                temp_thresh_hold_rate = round((total_num - max_num * max_num_count) * 0.9 / total_num, 2)
                if thresh_hold_rate > temp_thresh_hold_rate:
                    # 目标撤单比例大于大单撤单比例就取比例均值
                    thresh_hold_rate = round((thresh_hold_rate + temp_thresh_hold_rate) / 2, 2)
            l2_log.l_cancel_debug(code,
                                  f"L后计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate}, 下单位之后的索引:{after_place_order_index_dict}")
                                  f"L后计算范围:{start_index}-{end_index},已撤单比例:{rate}/{thresh_hold_rate}, 下单位之后的索引:{after_place_order_index_dict}, 最大单-({max_num},{max_num_count})")
            if rate >= thresh_hold_rate:
                canceled_indexes.sort()
                l2_log.l_cancel_debug(code, f"L后撤单,撤单位置:{canceled_indexes[-1]}")