From b37fe91f5eed9ac691a4ee9acaec506af1267506 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 12 三月 2025 18:51:28 +0800
Subject: [PATCH] 日志调整/L后重新囊括修改

---
 cancel_strategy/s_l_h_cancel_strategy.py |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/cancel_strategy/s_l_h_cancel_strategy.py b/cancel_strategy/s_l_h_cancel_strategy.py
index 97fc51c..53b6009 100644
--- a/cancel_strategy/s_l_h_cancel_strategy.py
+++ b/cancel_strategy/s_l_h_cancel_strategy.py
@@ -222,7 +222,8 @@
             if cancel_result[0]:
                 return True, f"S鎱㈢牳:{cancel_result[1]}"
         # 鍗栭噾棰�>=鍧囧ぇ鍗曟墠瑙﹀彂閲嶆柊鍥婃嫭
-        THRESHOLD_MONEY, is_temp_threshold_money = radical_buy_data_manager.BeforeSubDealBigOrderManager().get_big_order_threshold_info(code)
+        THRESHOLD_MONEY, is_temp_threshold_money = radical_buy_data_manager.BeforeSubDealBigOrderManager().get_big_order_threshold_info(
+            code)
         if total_deal_money >= THRESHOLD_MONEY:
             l2_log.s_cancel_debug(code, "鍑嗗鏇存柊L鍚庡泭鎷�")
             start_order_no = big_sell_order_info[1][-1][4][1]
@@ -577,7 +578,7 @@
                     # 鏍规嵁鎴愪氦棰濈殑澶у崟鎴愪氦鍗犳瘮鏉ヨ绠楁挙鍗曟瘮渚�
                     big_money_rate = radical_buy_data_manager.TotalDealBigOrderInfoManager.get_big_order_rate(code)
                     if big_money_rate is not None:
-                        threshold_rate = min(big_money_rate*3, 0.95)
+                        threshold_rate = min(big_money_rate * 3, 0.95)
                         return threshold_rate, False
                     else:
                         deal_big_order_info = radical_buy_data_manager.get_total_deal_big_order_info(code,
@@ -1548,7 +1549,7 @@
                 temp_thresh_hold_rate = round((total_num - max_num) * 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)
+                    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}")
@@ -1658,6 +1659,84 @@
 
         return False, None
 
+    # L鍚庨噸鏂板泭鎷殑鏃堕棿
+    __recompute_l_down_time_dict = {}
+
+    def set_big_sell_order_info(self, code, big_sell_order_info):
+        """
+        璁剧疆澶у崠鍗曚俊鎭�
+        @param code:
+        @param big_sell_order_info:
+        @return:
+        """
+        total_datas = local_today_datas.get(code)
+        # 鏌ヨ鏄惁鏄湡鐨勭湡瀹炰笅鍗曚綅缃�
+        trade_index, is_default = TradeBuyQueue().get_traded_index(code)
+        if trade_index is None:
+            trade_index = 0
+        real_order_index_info = self.get_real_place_order_index_info(code)
+        if real_order_index_info is None or real_order_index_info[1]:
+            return False, "娌℃壘鍒扮湡瀹炰笅鍗曚綅"
+        real_order_index = real_order_index_info[0]
+        total_deal_money = sum([x[1] * x[2] for x in big_sell_order_info[1]])
+        start_order_no = big_sell_order_info[1][0][3][1]
+        # 闃叉鍒嗘瘝浣�0
+        total_num = 1
+        # 鑾峰彇姝e湪鎴愪氦鐨勬暟鎹�
+        dealing_info = HuaXinBuyOrderManager.get_dealing_order_info(code)
+        for i in range(trade_index, real_order_index):
+            data = total_datas[i]
+            val = data['val']
+            if not L2DataUtil.is_limit_up_price_buy(val):
+                continue
+            if int(val['orderNo']) < start_order_no:
+                continue
+            if i == trade_index and dealing_info and str(total_datas[trade_index]["val"]["orderNo"]) == str(
+                    dealing_info[0]):
+                # 鍑忓幓褰撳墠姝e湪鎴愪氦鐨勬暟鎹腑宸茬粡鎴愪氦浜嗙殑鏁版嵁
+                total_num -= dealing_info[1] // 100
+            left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, i,
+                                                                                                     total_datas,
+                                                                                                     local_today_canceled_buyno_map.get(
+                                                                                                         code))
+            if left_count > 0:
+                total_num += val["num"]
+
+        # 鍗栭噾棰�>=鍧囧ぇ鍗曟墠瑙﹀彂閲嶆柊鍥婃嫭
+        THRESHOLD_MONEY, is_temp_threshold_money = radical_buy_data_manager.BeforeSubDealBigOrderManager().get_big_order_threshold_info(
+            code)
+        if total_deal_money >= THRESHOLD_MONEY:
+            l2_log.l_cancel_debug(code, "鍑嗗鏇存柊L鍚庡泭鎷�(澶у崠鍗�)")
+            start_order_no = big_sell_order_info[1][-1][4][1]
+            latest_deal_time_ms = l2_huaxin_util.convert_time(big_sell_order_info[1][-1][4][0], with_ms=True)
+            real_trade_index = None
+            for i in range(trade_index, real_order_index):
+                data = total_datas[i]
+                val = data['val']
+                if not L2DataUtil.is_limit_up_price_buy(val):
+                    continue
+                if int(val['orderNo']) < start_order_no:
+                    continue
+                real_trade_index = i
+                break
+            if real_trade_index is None:
+                l2_log.l_cancel_debug(code, f"娌℃壘鍒扮湡瀹炵殑鎴愪氦杩涘害(澶у崠鍗�)锛歴tart_order_no-{start_order_no} 鍗栧崟-{big_sell_order_info}")
+                return False, ""
+            # 闂撮殧1S浠ヤ笂鎵嶈兘閲嶆柊鍥婃嫭
+            if code in self.__recompute_l_down_time_dict and tool.trade_time_sub_with_ms(latest_deal_time_ms,
+                                                                                         self.__recompute_l_down_time_dict[
+                                                                                             code]) < 1000:
+                l2_log.s_cancel_debug(code,
+                                      f"鏇存柊L鍚庡泭鎷�(澶у崠鍗�)锛氭洿鏂伴棿闅斿湪1s鍐咃紝{latest_deal_time_ms}-{self.__recompute_l_down_time_dict[code]}")
+                return False, ""
+            self.__recompute_l_down_time_dict[code] = latest_deal_time_ms
+            # 閲嶆柊鍥婃嫭L鍚�
+            # 鎾ゅ崟鏃堕棿姣旀棭鎴愪氦鏃堕棿澶у氨闇�瑕佽绠楀湪閲岄潰
+            self.re_compute_l_down_watch_indexes(code, big_sell_info=(
+                real_trade_index, latest_deal_time_ms))
+            l2_log.l_cancel_debug(code, f"鏇存柊L鍚庡泭鎷畬鎴�(澶у崠鍗�)锛歿(real_trade_index, latest_deal_time_ms)}")
+        return False, ""
+
     # L鍚庢槸鍚﹁繕鏈夊彲鑳芥挙鍗�
     def __is_l_down_can_cancel(self, code, buy_exec_index):
         watch_indexes_info = self.__get_watch_indexes_cache(code)

--
Gitblit v1.8.0