From 89e49e197ec232fc6ae99c22b8ffb2be64108ee4 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 19 八月 2025 12:17:22 +0800 Subject: [PATCH] 接口优化 --- code_attribute/today_max_price_manager.py | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code_attribute/today_max_price_manager.py b/code_attribute/today_max_price_manager.py index b3f3deb..96b67fd 100644 --- a/code_attribute/today_max_price_manager.py +++ b/code_attribute/today_max_price_manager.py @@ -8,7 +8,7 @@ from db import redis_manager_delegate as redis_manager from db.redis_manager_delegate import RedisUtils from log_module import async_log_util -from log_module.log import logger_debug +from log_module.log import logger_debug, logger_limit_up_record from utils import global_util, tool @@ -66,7 +66,7 @@ tool.CodeDataCacheUtil.set_cache(self.__max_price_info_cache, code, price_info) RedisUtils.setex_async( self.__db, "max_price_info-{}".format(code), tool.get_expire(), json.dumps(price_info)) - async_log_util.info(logger_debug, f"鏈�澶х幇浠�:{code}-{price_info}") + # async_log_util.info(logger_debug, f"鏈�澶х幇浠�:{code}-{price_info}") if self.__is_limit_up(code, price, sell1_info): if code not in self.__limit_up_latest_info_cache: self.__limit_up_latest_info_cache[code] = time @@ -74,8 +74,10 @@ if code not in self.__limit_up_records_cache: self.__limit_up_records_cache[code] = [] if code in self.__limit_up_latest_info_cache: - self.__limit_up_records_cache[code].append((self.__limit_up_latest_info_cache.get(code), time)) + limit_up_info = (self.__limit_up_latest_info_cache.get(code), time) + self.__limit_up_records_cache[code].append(limit_up_info) self.__limit_up_latest_info_cache.pop(code) + async_log_util.info(logger_limit_up_record, f"{code}-{limit_up_info}") def get_max_limit_up_time(self, code): """ @@ -87,14 +89,14 @@ max_space_time = 0 if code in self.__limit_up_latest_info_cache: max_space_time = tool.trade_time_sub(tool.get_now_time_str(), self.__limit_up_latest_info_cache[code]) - if code in self.__limit_up_records_cache: + if self.__limit_up_records_cache.get(code): max_item = max(self.__limit_up_records_cache[code], key=lambda x: tool.trade_time_sub(x[1], x[0])) max_space_time_his = tool.trade_time_sub(max_item[1], max_item[0]) if max_space_time_his > max_space_time: max_space_time = max_space_time_his return max_space_time except Exception as e: - async_log_util.error(logger_debug, f"鑾峰彇鏈�澶ф定鍋滄椂闂村嚭閿欙細{str(e)}") + async_log_util.error(logger_debug, f"鑾峰彇鏈�澶ф定鍋滄椂闂村嚭閿欙細{code}-{str(e)}") return 0 def get_price_info_cache(self, code): -- Gitblit v1.8.0