From 93ec042ae730c8e4cad1562d7ee579941847397c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 07 十一月 2024 18:37:44 +0800
Subject: [PATCH] 扫入整改

---
 third_data/code_plate_key_manager.py |   85 ++++++++++++++++++++++++++++--------------
 1 files changed, 56 insertions(+), 29 deletions(-)

diff --git a/third_data/code_plate_key_manager.py b/third_data/code_plate_key_manager.py
index 85db82c..be18794 100644
--- a/third_data/code_plate_key_manager.py
+++ b/third_data/code_plate_key_manager.py
@@ -16,7 +16,7 @@
 from third_data.third_blocks_manager import BlockMapManager, CodeThirdBlocksManager
 from trade.buy_money_count_setting import RadicalBuyBlockCodeCountManager
 from trade.order_statistic import DealAndDelegateWithBuyModeDataManager
-from trade.radical_buy_data_manager import RedicalBuyDataManager
+from trade.radical_buy_data_manager import RadicalBuyDataManager
 from utils import global_util, tool, buy_condition_util
 from log_module import log, async_log_util
 from db import redis_manager_delegate as redis_manager
@@ -1176,7 +1176,12 @@
             blocks -= constant.KPL_INVALID_BLOCKS
             # 杩囨护
             blocks = BlockMapManager().filter_blocks(blocks)
-            temp_dict[code] = (kpl_util.get_high_level_count(d[4]), blocks)
+            # 寮�1鍓旈櫎4鏉夸互涓婄殑
+            high_level = kpl_util.get_high_level_count(d[4])
+            if high_level >= 4:
+                continue
+            temp_dict[code] = (high_level, blocks)
+
         kpl_data_constant.open_limit_up_code_dict_for_radical_buy = temp_dict
 
     @classmethod
@@ -1264,7 +1269,6 @@
             if _code in exclude_codes:
                 continue
             blocks = LimitUpDataConstant.get_blocks_with_history(_code)
-            blocks = BlockMapManager().filter_blocks(blocks)
             if _code == code:
                 # 鑾峰彇褰撳墠浠g爜娑ㄥ仠鏃堕棿
                 limit_up_time = int(k[5])
@@ -1313,7 +1317,7 @@
         # 9:45鐐逛箣鍓嶆定鍋滅殑鎵嶈兘涔板叆
         # 鑾峰彇褰撳墠浠g爜鐨勬定鍋滄椂闂�
         limit_up_timestamp = cls.__get_limit_up_timestamp(code)
-        if int(tool.timestamp_format(limit_up_timestamp, "%H%M%S")) > 94500:
+        if tool.get_now_time_as_int() > 100000:
             return False, "瓒呰繃鐢熸晥鏃堕棿"
         # 鏍规嵁鏉垮潡鑱氬悎鏁版嵁
         open_limit_up_block_codes_dict = {}
@@ -1333,12 +1337,26 @@
         current_index, current_before_codes_info = cls.__get_current_index(code, block, yesterday_limit_up_codes,
                                                                            limit_up_time=limit_up_timestamp)
         exclude_codes = set()
-        if count >= 2 or (
-                count == 1 and kpl_data_constant.open_limit_up_code_dict_for_radical_buy[open_limit_up_block_codes[0]][
-            0] == 2):
+        # 鏄惁涓哄己鍔夸簩鏉垮紑1锛氳浠g爜鎵�鏈夌殑鎱ㄥ康蹇呴』閮戒负浜屾澘寮�1涓斿紑1鐨勫彧鑳芥湁浠栬嚜宸�
+        is_strong_2_level = count == 1 and \
+                            kpl_data_constant.open_limit_up_code_dict_for_radical_buy[open_limit_up_block_codes[0]][
+                                0] == 2
+        if is_strong_2_level:
+            _code = open_limit_up_block_codes[0]
+            blocks = LimitUpDataConstant.get_blocks_with_history(_code)
+            if blocks:
+                # 鎵�鏈夌殑鎱ㄥ康鐨勫紑1浠g爜蹇呴』鍙湁浠栬嚜宸�
+                for b in blocks:
+                    temp_codes = open_limit_up_block_codes_dict.get(b)
+                    if temp_codes and len(temp_codes) > 1:
+                        is_strong_2_level = False
+                        break
+
+        if count >= 2 or is_strong_2_level:
             # 寮�濮嬫暟閲忓ぇ浜�2涓垨鑰呭彧鏈変竴涓�2鏉垮紑1
             exclude_codes.clear()
         else:
+            # 鍙湁涓�涓紑1
             # 鑾峰彇鍖呭惈楂樹綅鏉跨殑韬綅
             # ----鑾峰彇鍘嗗彶韬綅----
             history_index, history_before_codes_info = cls.__get_history_index(code, block, set())
@@ -1347,17 +1365,19 @@
                                                                                limit_up_time=limit_up_timestamp)
             if history_before_codes_info and current_before_codes_info and history_before_codes_info[0][0] == \
                     current_before_codes_info[0][0]:
-                # 鍓嶆帓绗竴涓厓绱犳棤鐐告澘
+                # 鎺掗櫎绗竴涓潪寮�1鏁版嵁
                 exclude_codes = {history_before_codes_info[0][0]}
             else:
                 return False, f"寮�1鏁伴噺锛歿count}锛屽巻鍙�-{history_index + 1} 瀹炴椂-{current_index + 1}"
 
-        # 鑾峰彇涓绘澘鐨勮韩浣�
+        # 鑾峰彇涓绘澘鐨勮韩浣嶏紙宸茬粡鎺掗櫎浜嗗紑1鐨勪唬鐮侊級
         history_index, history_before_codes_info = cls.__get_history_index(code, block,
                                                                            yesterday_limit_up_codes,
                                                                            exclude_codes=exclude_codes)
         # 杩囨护涓嶆鐨勫師鍥�
-        history_index, history_before_codes_info = cls.__filter_before_codes(block, history_index, history_before_codes_info, yesterday_limit_up_codes)
+        history_index, history_before_codes_info = cls.__filter_before_codes(block, history_index,
+                                                                             history_before_codes_info,
+                                                                             yesterday_limit_up_codes)
 
         # 涔伴鏉胯�佸ぇ/鑰佷簩
         # 棣栨澘鑰佸ぇ涓嶈兘涔版椂鍙拱鑰佷簩
@@ -1365,8 +1385,8 @@
             return False, f"寮�1鏁伴噺锛歿count}锛岄潪寮�1棣栨澘韬綅涓嶅尮閰嶏細鍘嗗彶-{history_index + 1} 瀹炴椂-{current_index + 1}"
         if history_index == 1:
             # 褰撳墠浠g爜涓鸿��2锛岃鍒ゆ柇鑰佸ぇ鏄惁鍙拱
-            if RedicalBuyDataManager.can_buy(history_before_codes_info[0][0],
-                                             DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]:
+            if RadicalBuyDataManager.is_code_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]}锛屽巻鍙插墠鎺�-{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}"
@@ -1436,13 +1456,17 @@
                                tool.timestamp_format(current_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
             return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽current_before_codes_info[0]}锛�"
 
-        history_index, history_before_codes_info = cls.__get_history_index(code, block, set())
-        history_before_codes = [x[0] for x in history_before_codes_info]
+        # 鍖呭惈楂樹綅鏉跨殑鏁翠綋鎺掑簭
+        all_history_index, all_history_before_codes_info = cls.__get_history_index(code, block, set())
+        all_history_before_codes = [x[0] for x in all_history_before_codes_info]
         # 鍓嶄袱涓唬鐮佹槸鍚︽湁鐐告澘
-        dif_codes = set(history_before_codes[:2]) - set(current_before_codes[:2])
+        dif_codes = set(all_history_before_codes[:2]) - set(current_before_codes[:2])
         if dif_codes:
             return False, f"鍓�2浠g爜鏈夌偢鏉匡細{dif_codes}"
-        # 涓嶈绠楀墠2鐨勪唬鐮�
+        # 鍓嶆帓浠g爜鐐告澘涓嶈兘>=2涓�
+        dif_codes = set(all_history_before_codes) - set(current_before_codes)
+        if len(dif_codes) >= 2:
+            return False, f"鏉垮潡鍓嶆帓鏈墈len(dif_codes)}涓偢鏉�"
 
         exclude_codes = set()
         for x in current_before_codes_info:
@@ -1477,22 +1501,25 @@
                 # 棣栨澘鑰�2锛屽垽鏂墠闈㈢殑鑰佸ぇ鏄惁鏄睘浜庝笉鑳戒拱鐨勮寖鐣�
                 pre_code = history_before_codes_info[0][0]
                 # pre_code涓嶈兘涔帮紝鎵嶈兘涔�
-                if RedicalBuyDataManager.can_buy(pre_code, DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]:
+                if RadicalBuyDataManager.is_code_can_buy(pre_code,
+                                                         DealAndDelegateWithBuyModeDataManager().get_deal_codes())[0]:
                     return False, f"鍓嶆帓浠g爜鍙拱锛歿pre_code}"
-                # 璺濈鍓嶄竴涓槸鍚﹀湪10鍒嗛挓鍐�
-                if tool.trade_time_sub(tool.timestamp_format(limit_up_timestamp, '%H:%M:%S'),
-                                       tool.timestamp_format(history_before_codes_info[-1][1], '%H:%M:%S')) >= 10 * 60:
-                    return False, f"璺濈涓婁釜涓嶈兘涔扮殑浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽history_before_codes_info[0]}锛�"
+                # 鍓嶉潰涓�涓唬鐮佷笉鑳戒拱锛屽墠涓�涓唬鐮佸繀椤讳笌鍓嶅墠涓唬鐮佹定鍋滄椂闂寸浉宸�15鍒嗛挓鍐�
+                for i in range(len(all_history_before_codes_info) - 1, -1, -1):
+                    if all_history_before_codes_info[i][0] == pre_code:
+                        if tool.trade_time_sub(tool.timestamp_format(all_history_before_codes_info[i][1], '%H:%M:%S'),
+                                               tool.timestamp_format(all_history_before_codes_info[i - 1][1],
+                                                                     '%H:%M:%S')) >= 15 * 60:
+                            return False, f"琚『浣嶄唬鐮�({pre_code}) 涓庝笂涓唬鐮佹定鍋滄椂闂�>=15鍒嗛挓 锛坽all_history_before_codes_info[i]}##{all_history_before_codes_info[i - 1]}锛�"
+                        else:
+                            return True, f"琚『浣嶄唬鐮�({pre_code}) 涓庝笂涓唬鐮佹定鍋滄椂闂�<15鍒嗛挓 锛坽all_history_before_codes_info[i]}##{all_history_before_codes_info[i - 1]}锛�"
+                return False, f"娌℃壘鍒伴『浣嶄唬鐮侊紙{pre_code}锛夌殑鍓嶆帓浠g爜"
             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')) >= 10 * 60:
-                    return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
+                # 浠g爜涓虹洰鏍囦唬鐮�
+                pass
         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')) >= 10 * 60:
-                return False, f"璺濈涓婁釜浠g爜娑ㄥ仠宸茶繃鍘�10鍒嗛挓锛坽current_before_codes_info[-1]}锛�"
-
+            # 浠g爜涓虹洰鏍囦唬鐮�
+            pass
         return True, f"婊¤冻涔板叆闇�姹�: 鍓嶆帓浠g爜-{current_before_codes_info}"
 
     @classmethod

--
Gitblit v1.8.0