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/kpl_limit_up_data_manager.py | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/third_data/kpl_limit_up_data_manager.py b/third_data/kpl_limit_up_data_manager.py index 4b4a138..85a3413 100644 --- a/third_data/kpl_limit_up_data_manager.py +++ b/third_data/kpl_limit_up_data_manager.py @@ -42,7 +42,8 @@ # 棣栨澘韬綅 __first_block_sequence_dict = {} - def set_current_limit_up_datas(self, current_limit_up_datas): + @classmethod + def set_current_limit_up_datas(cls, current_limit_up_datas): """ 璁剧疆鐩墠鐨勬定鍋滀唬鐮� @param current_limit_up_datas: @@ -51,7 +52,7 @@ records = get_today_history_limit_up_datas_cache() # 鎸変唬鐮佹帓搴� # {"浠g爜":锛堜唬鐮侊紝娑ㄥ仠鍘熷洜, 娑ㄥ仠鏃堕棿, 鍑犵増锛墋 - current_code_block_dict = {x[0]: (x[0], x[2], x[5], x[4]) for x in current_limit_up_datas} + current_code_block_dict = {x[0]: (x[0], x[5], x[2], x[4]) for x in current_limit_up_datas} record_code_block_dict = {x[3]: (x[3], x[2], x[5], x[12]) for x in records} # 鏍规嵁娑ㄥ仠鍘熷洜缁熻 # {"鏉垮潡":{浠g爜}} @@ -68,6 +69,10 @@ if b not in block_codes: block_codes[b] = set() block_codes[b].add(code) + # 鑾峰彇涓婁釜浜ゆ槗鏃ユ定鍋滅殑浠g爜 + yesterday_codes = kpl_data_manager.get_yesterday_limit_up_codes() + if yesterday_codes is None: + yesterday_codes = set() for code in limit_up_codes: # 璁$畻韬綅 @@ -76,12 +81,29 @@ total_count = len(codes) # 缁熻鐪熸娑ㄥ仠鏁� limit_up_count = 0 + limit_up_codes_list = [] for c in codes: if c in limit_up_codes: limit_up_count += 1 - # TODO 鑾峰彇棣栨澘浠g爜鐨勬帓浣� + if c not in yesterday_codes: + limit_up_codes_list.append((c, current_code_block_dict[c][2])) + # 鑾峰彇棣栨澘浠g爜鐨勬帓浣� + limit_up_codes_list.sort(key=lambda x: x[1]) + index = 1 + for i in range(0, len(limit_up_codes_list)): + if limit_up_codes_list[i][0] == code: + index = i + 1 + break + cls.__first_block_sequence_dict[code] = (b, index, total_count, limit_up_count) - + @classmethod + def get_current_limit_up_sequence(cls, code): + """ + 鑾峰彇浠g爜褰撳墠鐨勬澘鍧楄韩浣� + @param code: + @return:锛堟澘鍧楀悕绉�,韬綅,鎬绘定鍋滄暟閲忥紝鐩墠娑ㄥ仠鏁伴噺锛� + """ + return cls.__first_block_sequence_dict.get(code) class LatestLimitUpBlockManager: @@ -206,7 +228,7 @@ block_count_list = [(k, block_count_dict[k]) for k in block_count_dict] block_count_list.sort(key=lambda x: x[1], reverse=True) - block_count_list = block_count_list[:20] + block_count_list = block_count_list[:50] # [(娑ㄥ仠鍘熷洜,绱娑ㄥ仠娆℃暟,杩炵画娆℃暟)] fdatas = [] today_records_code_dict = {d[3]: d for d in self.__history_limit_up_day_datas.get(now_day)} -- Gitblit v1.8.0