From 65afea1ba534b51f947cbe7989d7f4d650bbc9e6 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 04 十一月 2024 18:29:00 +0800
Subject: [PATCH] 代码异常保护

---
 third_data/code_plate_key_manager.py |   43 +++++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/third_data/code_plate_key_manager.py b/third_data/code_plate_key_manager.py
index 7735ff8..09a40b6 100644
--- a/third_data/code_plate_key_manager.py
+++ b/third_data/code_plate_key_manager.py
@@ -293,12 +293,6 @@
     def get_today_limit_up_reason(cls, code):
         return cls.__today_total_limit_up_reason_dict.get(code)
 
-    # 浠婃棩娑ㄥ仠鍘熷洜鍙樺寲
-    def set_today_limit_up_reason_change(self, code, from_reason, to_reason):
-        RedisUtils.sadd(self.__get_redis(), f"kpl_limit_up_reason_his-{code}", from_reason)
-        RedisUtils.expire(self.__get_redis(), f"kpl_limit_up_reason_his-{code}", tool.get_expire())
-        self.__set_total_keys(code)
-
     # 璁剧疆浠g爜鐨勪粖鏃ユ定鍋滃師鍥�
     def __set_total_keys(self, code):
         keys = set()
@@ -335,6 +329,8 @@
                 if codes:
                     fresult[k] = codes
         return fresult
+
+
 
 
 # 瀹炴椂寮�鐩樺暒甯傚満鏁版嵁
@@ -378,7 +374,8 @@
         """
         blocks = set()
         for i in range(0, len(datas)):
-            if i >= 10:
+            if i >= 10 and int(tool.get_now_time_str().replace(":", "")) < int("100000"):
+                # 10鐐瑰墠鐪嬪墠10锛屽崄鐐瑰悗涓嶇湅鍓�10
                 break
             data = datas[i]
             if data[3] > 0 - 5e7:
@@ -926,7 +923,8 @@
             current_limit_up_datas = []
 
         # 鑾峰彇鐩爣浠g爜鏉垮潡
-        keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code)
+        # keys, k1, k11, k2, k3, k4 = cls.__TargetCodePlateKeyManager.get_plate_keys(code)
+        keys, k1 = RadicalBuyBlockManager.get_code_blocks(code)
 
         # log.logger_kpl_debug.info("{}鏈�缁堝叧閿瘝锛歿}", code, keys)
 
@@ -935,10 +933,6 @@
         fresults = []
         if not keys:
             return fresults, set()
-        # 鑾峰彇绮鹃�夋祦鍑烘澘鍧�
-        jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks()
-        if jx_out_blocks:
-            keys -= jx_out_blocks
 
         code_limit_up_reasons_dict = {}
         load_code_block()
@@ -1112,7 +1106,7 @@
 
 class RadicalBuyBlockManager:
     """
-    婵�杩涗拱鏉垮潡绠$悊
+    鎵叆涔版澘鍧楃鐞�
     """
     __TargetCodePlateKeyManager = TargetCodePlateKeyManager()
     # 涓婃鐨勬定鍋滀唬鐮�
@@ -1205,6 +1199,10 @@
             limit_up_time = time.time()
         for k in LimitUpDataConstant.current_limit_up_datas:
             _code = k[0]
+            # 鍓旈櫎4鏉夸互涓婄殑鏉�
+            if kpl_util.get_high_level_count(k[4]) >= 4:
+                continue
+
             if _code in exclude_codes:
                 continue
             blocks = LimitUpDataConstant.get_blocks_with_history(_code)
@@ -1260,6 +1258,11 @@
         limit_up_space_ge_60s_codes = set()
         for k in LimitUpDataConstant.history_limit_up_datas:
             _code = k[3]
+
+            # 鍓旈櫎4鏉夸互涓婄殑鏉�
+            if kpl_util.get_high_level_count(k[12]) >= 4:
+                continue
+
             if _code in exclude_codes:
                 continue
             blocks = LimitUpDataConstant.get_blocks_with_history(_code)
@@ -1364,8 +1367,8 @@
             if RedicalBuyDataManager.can_buy(history_before_codes_info[0][0],
                                              DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]:
                 return False, f"寮�1鏁伴噺锛歿count}锛屽墠鎺掍唬鐮佸彲涔帮細{history_before_codes_info[0]}"
-            return True, f"寮�1鏁伴噺锛歿count}锛屽墠鎺掍唬鐮佷笉鍙拱锛歿history_before_codes_info[0]}"
-        return True, f"寮�1鏁伴噺锛歿count}锛屽巻鍙�-{history_index + 1} 瀹炴椂-{current_index + 1}"
+            return True, f"寮�1鏁伴噺锛歿count}锛屽墠鎺掍唬鐮佷笉鍙拱锛歿history_before_codes_info[0]}锛屽巻鍙插墠鎺�-{history_before_codes_info}锛屽紑1浠g爜-{open_limit_up_block_codes}"
+        return True, f"寮�1鏁伴噺锛歿count}锛屽巻鍙�-{history_index + 1} 瀹炴椂-{current_index + 1}锛� 鍓嶆帓浠g爜-{current_before_codes_info}, 寮�1浠g爜-{open_limit_up_block_codes}"
 
     @classmethod
     def __is_radical_buy_with_block_up(cls, code, block, yesterday_limit_up_codes):
@@ -1446,12 +1449,12 @@
             else:
                 # 璺濈涓婁釜浠g爜娑ㄥ仠5鍒嗛挓浠ュ唴
                 if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
-                                       tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 5 * 60:
-                    return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�5鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
+                                       tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
+                    return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
         else:
             if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
-                                   tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 5 * 60:
-                return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�5鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
+                                   tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
+                return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
 
         return True, f"婊¤冻涔板叆闇�姹�: 鍓嶆帓浠g爜-{current_before_codes_info}"
 
@@ -1546,7 +1549,7 @@
             fblocks |= BlockMapManager().filter_blocks(kpl_history_blocks)
         jx_out_blocks = RealTimeKplMarketData.get_top_market_jingxuan_out_blocks()
         if jx_out_blocks:
-            fblocks-=jx_out_blocks
+            fblocks -= jx_out_blocks
 
         return fblocks, match_blocks
 

--
Gitblit v1.8.0