From ab662be5c523b75c1bd28fc6bfcab2872b9623b3 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期四, 12 六月 2025 15:22:06 +0800 Subject: [PATCH] bug修复 --- code_attribute/gpcode_manager.py | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) diff --git a/code_attribute/gpcode_manager.py b/code_attribute/gpcode_manager.py index 3c5b5ea..a8f8cab 100644 --- a/code_attribute/gpcode_manager.py +++ b/code_attribute/gpcode_manager.py @@ -655,36 +655,38 @@ return list +@tool.singleton class CodePrePriceManager: __price_pre_cache = {} __redisManager = redis_manager.RedisManager(0) + def __init__(self): + # 鍔犺浇鏁版嵁 + fdatas = log_export.load_pre_close_price() + if fdatas: + for code in fdatas: + self.__price_pre_cache[code] = round(float(fdatas.get(code)), 2) + # 鑾峰彇鏀剁洏浠� - @classmethod - def get_price_pre(cls, code): + def get_price_pre(self, code): fdatas = log_export.load_pre_close_price() if code in fdatas: return round(float(fdatas.get(code)), 2) return None # 鑾峰彇缂撳瓨 - @classmethod - def get_price_pre_cache(cls, code): - if code in cls.__price_pre_cache: - return float(cls.__price_pre_cache[code]) - val = cls.get_price_pre(code) - if val: - cls.__price_pre_cache[code] = val - return val + def get_price_pre_cache(self, code): + if code in self.__price_pre_cache: + return self.__price_pre_cache[code] + return None # 璁剧疆鏀剁洏浠� - @classmethod - def set_price_pre(cls, code, price, force=False): - if code in cls.__price_pre_cache and not force: + def set_price_pre(self, code, price, force=False): + if code in self.__price_pre_cache and not force: return price = round(float(price), 2) logger_pre_close_price.info(f"{code}-{price}") - cls.__price_pre_cache[code] = price + self.__price_pre_cache[code] = price __limit_up_price_dict = {} @@ -695,7 +697,7 @@ # 璇诲彇鍐呭瓨涓殑鍊� if code in __limit_up_price_dict: return __limit_up_price_dict[code] - price = CodePrePriceManager.get_price_pre_cache(code) + price = CodePrePriceManager().get_price_pre_cache(code) if price is None: return None limit_up_price = tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(tool.get_limit_up_rate(code))) @@ -730,7 +732,7 @@ # 鑾峰彇璺屽仠浠� def get_limit_down_price(code): - price = CodePrePriceManager.get_price_pre_cache(code) + price = CodePrePriceManager().get_price_pre_cache(code) if price is None: return None return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}")) -- Gitblit v1.8.0