From fbac2e1e6ae16a4fff90a1ec8e7ac680c8bd459b Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 14 八月 2025 15:47:28 +0800
Subject: [PATCH] 昨日收盘价修改

---
 code_attribute/gpcode_manager.py |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/code_attribute/gpcode_manager.py b/code_attribute/gpcode_manager.py
index 1f20dcd..8209c38 100644
--- a/code_attribute/gpcode_manager.py
+++ b/code_attribute/gpcode_manager.py
@@ -285,7 +285,6 @@
         return code in self.__codes_cache
 
 
-
 # 鏆傚仠涓嬪崟浠g爜绠$悊
 # 涓庨粦鍚嶅崟鐨勫尯鍒槸鏆傚仠浜ゆ槗浠g爜鍙槸涓嶄氦鏄擄紝涓嶈兘绉婚櫎L2鐩戞帶浣�
 class PauseBuyCodesManager:
@@ -470,7 +469,6 @@
         """
         if code in self.__human_remove_codes:
             self.__human_remove_codes.discard(code)
-
 
 
 class BlackListCodeManager:
@@ -769,39 +767,42 @@
     return list
 
 
+@tool.singleton
 class CodePrePriceManager:
     __price_pre_cache = {}
     __redisManager = redis_manager.RedisManager(0)
 
+    def __init__(self):
+        fdatas = log_export.load_pre_close_price()
+        for code, v in fdatas.items():
+            self.__price_pre_cache[code] = round(float(v), 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)
+    def get_price_pre_cache(self, code):
+        if code in self.__price_pre_cache:
+            return float(self.__price_pre_cache[code])
+        val = self.get_price_pre(code)
         if val:
-            cls.__price_pre_cache[code] = val
+            self.__price_pre_cache[code] = val
         return val
 
     # 璁剧疆鏀剁洏浠�
-    @classmethod
-    def set_price_pre(cls, code, price, force=False):
+    def set_price_pre(self, code, price, force=False):
         if float(price) > 1000:
             async_log_util.info(logger_debug, f"鑾峰彇鏄ㄦ棩鏀剁洏浠峰紓甯革細{code}-{price}")
             return
-        if code in cls.__price_pre_cache and not force:
+        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 = {}
@@ -812,12 +813,13 @@
     # 璇诲彇鍐呭瓨涓殑鍊�
     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)))
     __limit_up_price_dict[code] = limit_up_price
     return limit_up_price
+
 
 def clear_limit_up_price_cache(code):
     if code in __limit_up_price_dict:
@@ -851,7 +853,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)}"))
@@ -978,4 +980,4 @@
         RedisUtils.delete(redis_instance, "first_code_record", auto_free=False)
         RedisUtils.delete(redis_instance, "first_code_limited_up_record", auto_free=False)
     finally:
-        RedisUtils.realse(redis_instance)
\ No newline at end of file
+        RedisUtils.realse(redis_instance)

--
Gitblit v1.8.0