From e95ea73d04c06f4cd46a3d1497c39c80352a8cd0 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 29 八月 2025 15:16:37 +0800
Subject: [PATCH] bug修复

---
 code_attribute/code_volumn_manager.py |   62 +++++++++++++++++++++---------
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/code_attribute/code_volumn_manager.py b/code_attribute/code_volumn_manager.py
index 2af92a6..5f624de 100644
--- a/code_attribute/code_volumn_manager.py
+++ b/code_attribute/code_volumn_manager.py
@@ -53,6 +53,16 @@
                     code = k.split("-")[1]
                     val = RedisUtils.get(redis, k, auto_free=False)
                     cls.__max_volume_info_in_5days[code] = json.loads(val)
+
+            keys = RedisUtils.keys(redis, "volumn_today-*", auto_free=False)
+            if keys is not None:
+                for k in keys:
+                    code = k.split("-")[-1]
+                    val = RedisUtils.get(redis, k, auto_free=False)
+                    if val:
+                        cls.__today_volumn_cache[code] = int(val)
+                        global_util.today_volumn[code] = int(val)
+
         finally:
             RedisUtils.realse(redis)
 
@@ -96,18 +106,18 @@
         @return:
         """
         # 60涓氦鏄撴棩鏈定鍋滃彇
-        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
-        has_limit_up_in_60 = True
-        if k_format and not k_format[13]:
-            has_limit_up_in_60 = False
-        volume = self.get_max_volume_in_5days(code)
-        if volume and volume * limit_up_price >= 9e8 and has_limit_up_in_60:
-            return volume
+        # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
+        # has_limit_up_in_60 = True
+        # if k_format and not k_format[13]:
+        #     has_limit_up_in_60 = False
+        # volume = self.get_max_volume_in_5days(code)
+        # if volume and volume * limit_up_price >= 9e8 and has_limit_up_in_60:
+        #     return volume
         return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price)
 
     def get_radical_buy_refer_volume_info(self, code, limit_up_price):
         """
-        TODO 鏇存敼姝g‘
+        鑾峰彇鍙傝�冮噺淇℃伅
         鑾峰彇鎵叆鐨勫弬鑰冮噺:
         鍙傝�冮灏忎簬3.14浜垮氨鍙�90澶╁弬鑰冮噺
         鍚﹀垯灏卞彇鏈�杩�5澶╃殑鍙傝�冮噺
@@ -116,14 +126,15 @@
         @return:
         """
         # 60涓氦鏄撴棩鏈定鍋滃彇
-        k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
-        has_limit_up_in_60 = True
-        if k_format and not k_format[13]:
-            has_limit_up_in_60 = False
-        volume_info = self.__max_volume_info_in_5days.get(code, None)
-        if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60:
-            return volume_info
-        return int(self.get_reference_volume_as_money_y(code) * 1e8 / limit_up_price)
+        # k_format = code_nature_analyse.CodeNatureRecordManager().get_k_format_cache(code)
+        # has_limit_up_in_60 = True
+        # if k_format and not k_format[13]:
+        #     has_limit_up_in_60 = False
+        # (閲�, 鏃ユ湡)
+        # volume_info = self.__max_volume_info_in_5days.get(code, None)
+        # if volume_info and volume_info[0] * limit_up_price >= 9e8 and has_limit_up_in_60:
+        #     return volume_info
+        return self.get_reference_volume_info(code)
 
     def get_volume_rate_refer_in_5days(self, code, total_sell_volume=0):
         """
@@ -135,7 +146,7 @@
         max_volume = self.get_max_volume_in_5days(code)
         if not max_volume:
             return 0
-        today_volume = self.get_today_volumn(code)
+        today_volume = self.get_today_volumn_cache(code)
         return round((today_volume + total_sell_volume) / max_volume, 2)
 
     # 鑾峰彇鍘嗗彶閲�
@@ -183,16 +194,20 @@
         _volumn = global_util.today_volumn.get(code)
         if _volumn is None:
             _volumn = RedisUtils.get(self.__redis_manager.getRedis(), "volumn_today-{}".format(code))
+        if not _volumn:
+            _volumn = 0
         return int(_volumn)
 
     # 鑾峰彇浠婃棩閲�
     def get_today_volumn_cache(self, code):
-        return global_util.today_volumn.get(code)
+        if code in global_util.today_volumn:
+            return global_util.today_volumn.get(code)
+        return 0
 
     # 鑾峰彇閲忔瘮锛堜粖鏃ラ噺/max(60澶╂渶澶ч噺,鏄ㄦ棩閲�)锛�
     # 灏嗘�诲崠閲忚绠楀湪鍐�
     def get_volume_rate(self, code, total_sell_volume=0, with_info=False):
-        today = self.get_today_volumn(code)
+        today = self.get_today_volumn_cache(code)
         max60, yesterday = self.get_histry_volumn(code)
         if today is None:
             today = 0
@@ -256,6 +271,15 @@
         # 榛樿涓�5浜�
         return 5
 
+    def get_reference_volume_info(self, code):
+        """
+        鑾峰彇浼犵粺鍙傝�冮噺淇℃伅
+        @param code:
+        @return:(閲�,鏃ユ湡)
+        """
+        max60 = global_util.max60_volumn.get(code)
+        return max60
+
 
 if __name__ == "__main__":
     print(CodeVolumeManager().get_volume_rate("000059"))

--
Gitblit v1.8.0