From f11cde17628781e516371cc039e98fa884b808e2 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 03 一月 2025 18:07:49 +0800
Subject: [PATCH] 新版真实下单位寻找

---
 third_data/kpl_limit_up_data_manager.py |   62 +++++++++++++------------------
 1 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/third_data/kpl_limit_up_data_manager.py b/third_data/kpl_limit_up_data_manager.py
index 56cdf97..3ffb3a1 100644
--- a/third_data/kpl_limit_up_data_manager.py
+++ b/third_data/kpl_limit_up_data_manager.py
@@ -1,6 +1,8 @@
 """
 寮�鐩樺暒娑ㄥ仠鏁版嵁绠$悊
 """
+import copy
+
 from third_data import kpl_util, kpl_data_manager
 from third_data.history_k_data_manager import HistoryKDataManager
 from third_data.history_k_data_util import HistoryKDatasUtils
@@ -34,8 +36,6 @@
     @return:
     """
     return kpl_data_manager.KPLLimitUpDataRecordManager.total_datas
-
-
 
 
 class CodeLimitUpSequenceManager:
@@ -126,8 +126,8 @@
     """
     鏈�杩戞定鍋滅殑鏉垮潡绠$悊
     """
-    # 鐪嬫渶杩�7澶�
-    __LATEST_DAY_COUNT = 7
+    # 鐪嬫渶杩�3澶╋紝涓嶅寘鍚粖澶�
+    __LATEST_DAY_COUNT = 3
 
     __days = []
     # 鐩墠娑ㄥ仠
@@ -156,16 +156,15 @@
 
     @classmethod
     def __load_datas(cls):
-        # 鍔犺浇鏈�杩�7澶╃殑鏁版嵁
-        __days = HistoryKDatasUtils.get_latest_trading_date_cache(cls.__LATEST_DAY_COUNT - 1)
-        now_day = tool.get_now_date_str()
-        if __days[0] != now_day:
-            __days.insert(0, now_day)
+        # 鍔犺浇鏈�杩戝嚑澶╃殑鏁版嵁
+        __days = HistoryKDatasUtils.get_latest_trading_date_cache(cls.__LATEST_DAY_COUNT)
+        __days = copy.deepcopy(__days)
+        # 涓嶈兘鍖呭惈浠婂ぉ
+        if __days[0] == tool.get_now_date_str():
+            __days.pop(0)
         cls.__days = __days
         # 鍔犺浇涔嬪墠6澶╃殑娑ㄥ仠锛屾浘娑ㄥ仠锛屾浘娑ㄥ仠浠g爜鐨勬渶杩�6澶╃殑K绾�
         for day in __days:
-            if day == now_day:
-                continue
             limit_up_records = get_history_limit_up_datas(day)
             cls.__history_limit_up_day_datas[day] = limit_up_records
             current_limit_up_datas = get_current_limit_up_datas(day)
@@ -179,8 +178,6 @@
             cls.__get_bars(code)
         # 缁熻鍓�6澶╃殑鏉垮潡淇℃伅
         for day in __days:
-            if day == now_day:
-                continue
             cls.__block_day_datas[day] = cls.__statistics_limit_up_block_infos_by_day(day)
 
     def set_current_limit_up_data(self, day, datas):
@@ -196,17 +193,21 @@
     def __statistics_limit_up_block_infos_by_day(cls, day):
         """
         缁熻娑ㄥ仠浠g爜淇℃伅
-        @return:
+        @return:{"鏉垮潡":(娑ㄥ仠鏁�, 鐐告澘鏁�, {鍖呭惈鐨勪唬鐮亇)}
         """
         # 缁熻鏉垮潡鐨�
         current_code_dict = {d[0]: d for d in cls.__current_limit_up_day_datas[day]}
-        # history_code_dict = {d[3]: d for d in self.__history_limit_up_day_datas[day]}
         block_codes_dict = {}
         for h in cls.__history_limit_up_day_datas[day]:
-            cls.__code_name_dict[h[3]] = h[4]
-            if h[2] not in block_codes_dict:
-                block_codes_dict[h[2]] = set()
-            block_codes_dict[h[2]].add(h[3])
+            # 灏嗘澘鍧楁墍鍖呭惈鐨勪唬鐮佸綊绫�
+            code = h[3]
+            cls.__code_name_dict[code] = h[4]
+            blocks = LimitUpCodesBlockRecordManager().get_radical_buy_blocks(code)
+            if blocks:
+                for b in blocks:
+                    if b not in block_codes_dict:
+                        block_codes_dict[b] = set()
+                    block_codes_dict[b].add(code)
         fdata = {}
         for b in block_codes_dict:
             limit_up_count = 0
@@ -225,19 +226,16 @@
         缁熻娑ㄥ仠鏉垮潡鏁版嵁
         @return:
         """
-        # 鍙粺璁′粖澶╃殑鏁版嵁
-        now_day = tool.get_now_date_str()
-        try:
-            block_dict = self.__statistics_limit_up_block_infos_by_day(now_day)
-            self.__block_day_datas[now_day] = block_dict
-        except:
-            pass
         # 鏉垮潡鍑虹幇鐨勫ぉ鏁�
         block_count_dict = {}
         # 鏉垮潡鍑虹幇鐨勪唬鐮�
         block_codes_dict = {}
         for day in self.__block_day_datas:
             for b in self.__block_day_datas[day]:
+                total_limit_up_count = self.__block_day_datas[day][b][0] + self.__block_day_datas[day][b][1]
+                if total_limit_up_count < 3:
+                    continue
+                # 鏉垮潡娑ㄥ仠涓暟
                 if b not in block_count_dict:
                     block_count_dict[b] = set()
                 if b not in block_codes_dict:
@@ -250,19 +248,15 @@
         block_count_list = block_count_list[:50]
         # [(娑ㄥ仠鍘熷洜,绱娑ㄥ仠娆℃暟,杩炵画娆℃暟)]
         fdatas = []
-        if self.__history_limit_up_day_datas.get(now_day):
-            today_records_code_dict = {d[3]: d for d in self.__history_limit_up_day_datas.get(now_day)}
-        else:
-            today_records_code_dict = {}
         for d in block_count_list:
             b = d[0]
-            fdata = [d[0], len(d[1])]
+            fdata = [b, len(d[1])]
             temp = []
             max_continue_count = 0
             for day in self.__days:
                 if day not in self.__block_day_datas:
                     continue
-                if d[0] in self.__block_day_datas[day]:
+                if b in self.__block_day_datas[day]:
                     temp.append(day)
                 else:
                     c = len(temp)
@@ -286,9 +280,6 @@
 
             # 缁熻浠婂ぉ杩欎釜鏉垮潡涓ぇ浜庝簩鏉跨殑浠g爜鏁伴噺
             limit_up_counts = 0
-            for code in block_codes_dict[d[0]]:
-                if code in today_records_code_dict and today_records_code_dict[code][12] != '棣栨澘':
-                    limit_up_counts += 1
             fdata.append(limit_up_counts)
             # 鑾峰彇姣忓ぉ鐨勬暟閲�
             days_datas = []
@@ -331,4 +322,3 @@
         rate = int((volumes_data[0]["close"] - min_price) * 100 / min_price)
         cls.__k_max_rate[code] = rate
         return cls.__k_datas.get(code)
-

--
Gitblit v1.8.0