From bb2e450c9d0e9d42929ecd6030a1fb65b2034176 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期五, 24 一月 2025 14:33:55 +0800 Subject: [PATCH] bug修复 --- third_data/code_plate_key_manager.py | 69 ++++++++++++++++++++++++++-------- 1 files changed, 53 insertions(+), 16 deletions(-) diff --git a/third_data/code_plate_key_manager.py b/third_data/code_plate_key_manager.py index 1ba3ba9..1311472 100644 --- a/third_data/code_plate_key_manager.py +++ b/third_data/code_plate_key_manager.py @@ -222,8 +222,13 @@ # 寮�鐩樺暒绂佹浜ゆ槗鏉垮潡绠$悊 class KPLPlateForbiddenManager: - __redisManager = redis_manager.RedisManager(3) + """ + 涓嶈兘涔扮殑鏉垮潡绠$悊 + """ + __redis_manager = redis_manager.RedisManager(3) __kpl_forbidden_plates_cache = set() + # 宸茬粡鍒犻櫎浜嗙殑鏉垮潡 + __deleted_kpl_forbidden_plates_cache = set() __instance = None @@ -237,24 +242,45 @@ def __load_datas(cls): __redis = cls.__get_redis() try: - __kpl_forbidden_plates_cache = RedisUtils.smembers(__redis, "kpl_forbidden_plates") + cls.__kpl_forbidden_plates_cache = RedisUtils.smembers(__redis, "kpl_forbidden_plates") + cls.__deleted_kpl_forbidden_plates_cache = RedisUtils.smembers(__redis, "deleted_kpl_forbidden_plates") finally: RedisUtils.realse(__redis) @classmethod def __get_redis(cls): - return cls.__redisManager.getRedis() + return cls.__redis_manager.getRedis() def save_plate(self, plate): self.__kpl_forbidden_plates_cache.add(plate) RedisUtils.sadd(self.__get_redis(), "kpl_forbidden_plates", plate) RedisUtils.expire(self.__get_redis(), "kpl_forbidden_plates", tool.get_expire()) + self.__deleted_kpl_forbidden_plates_cache.discard(plate) + RedisUtils.srem(self.__get_redis(), "deleted_kpl_forbidden_plates", plate) + RedisUtils.expire(self.__get_redis(), "deleted_kpl_forbidden_plates", tool.get_expire()) + + def delete_plate(self, plate): + self.__kpl_forbidden_plates_cache.discard(plate) + RedisUtils.srem(self.__get_redis(), "kpl_forbidden_plates", plate) + RedisUtils.expire(self.__get_redis(), "kpl_forbidden_plates", tool.get_expire()) + self.__deleted_kpl_forbidden_plates_cache.add(plate) + RedisUtils.sadd(self.__get_redis(), "deleted_kpl_forbidden_plates", plate) + RedisUtils.expire(self.__get_redis(), "deleted_kpl_forbidden_plates", tool.get_expire()) + def list_all(self): return RedisUtils.smembers(self.__get_redis(), "kpl_forbidden_plates") def list_all_cache(self): return self.__kpl_forbidden_plates_cache + + def list_all_deleted_cache(self): + return self.__deleted_kpl_forbidden_plates_cache + + def is_in_cache(self, plate): + if self.__kpl_forbidden_plates_cache and plate in self.__kpl_forbidden_plates_cache: + return True + return False class LimitUpCodesPlateKeyManager: @@ -365,7 +391,7 @@ if cls.__market_strong is not None: score = int(cls.__market_strong) for info in constant.RADICAL_BUY_TOP_IN_COUNT_BY_MARKET_STRONG: - if info[0]<=score<info[1]: + if info[0] <= score < info[1]: return info[2] return 10 @@ -377,13 +403,13 @@ @return: """ # 娴佸叆闃堝�� - THRESHOLD_MONEY = 100 * (tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") // 60) + 1000 - THRESHOLD_MONEY = min(THRESHOLD_MONEY, 10000) - THRESHOLD_MONEY = max(THRESHOLD_MONEY, 1000) - THRESHOLD_MONEY = THRESHOLD_MONEY * 10000 - # THRESHOLD_MONEY = 0 + # THRESHOLD_MONEY = 50 * (tool.trade_time_sub(tool.get_now_time_str(), "09:30:00") // 60) + 1000 + # THRESHOLD_MONEY = min(THRESHOLD_MONEY, 10000) + # THRESHOLD_MONEY = max(THRESHOLD_MONEY, 1000) + # THRESHOLD_MONEY = THRESHOLD_MONEY * 10000 + THRESHOLD_MONEY = 0 # 鏈�澶ф暟閲� - MAX_COUNT = cls.get_jingxuan_in_block_threshold_count() + # MAX_COUNT = cls.get_jingxuan_in_block_threshold_count() cls.top_in_list_cache = datas blocks = set() @@ -398,7 +424,6 @@ # 杩囨护鍑烘潵涓哄悓涓�涓澘鍧楀氨鍙畻1涓暟閲� fb = BlockMapManager().filter_blocks({data[1]}) if blocks & fb: - blocks.add(data[1]) continue for b in fb: @@ -413,9 +438,17 @@ break if has_code: count += 1 - - if count >= MAX_COUNT: - break + if count == 10: + strong = cls.get_market_strong() + if strong is None: + strong = 60 + if data[3] > 3e7: + # 澶т簬3鍗冧竾 + THRESHOLD_MONEY = int((1 - strong / 200) * data[3]) + else: + THRESHOLD_MONEY = data[3] + # if count >= MAX_COUNT: + # break # 璁板綍绮鹃�夋祦鍑烘棩蹇� async_log_util.info(logger_kpl_jx_in, f"鍘熸暟鎹細{datas[:50]} 鏉垮潡锛歿blocks}") blocks = list(blocks) @@ -461,6 +494,12 @@ cls.__market_strong = strong @classmethod + def is_ignore_block_in_money(cls): + if cls.__market_strong and cls.__market_strong >= constant.IGNORE_BLOCK_IN_MONEY_MARKET_STRONG: + return True + return False + + @classmethod def get_market_strong(cls): return cls.__market_strong @@ -483,8 +522,6 @@ if cls.top_in_list_cache[i][1] == b: return b, i, cls.top_in_list_cache[i][3] return b, -1, 0 - - @classmethod def set_top_5_industry(cls, datas): -- Gitblit v1.8.0