From 57a7a0dbc43b21256f877bb50f6dd4a35addf313 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 07 六月 2024 15:46:15 +0800
Subject: [PATCH] 运行日志添加

---
 code_attribute/gpcode_manager.py |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/code_attribute/gpcode_manager.py b/code_attribute/gpcode_manager.py
index 0bef2bf..568096e 100644
--- a/code_attribute/gpcode_manager.py
+++ b/code_attribute/gpcode_manager.py
@@ -7,6 +7,8 @@
 import constant
 from db import redis_manager_delegate as redis_manager
 from db.redis_manager_delegate import RedisUtils
+from log_module import log_export
+from log_module.log import logger_pre_close_price
 from utils import tool
 import decimal
 
@@ -294,7 +296,7 @@
         return self.__pause_buy_codes_cache
 
 
-# 蹇呬拱鍗�
+# 蹇呬拱鍗�/绾㈠悕鍗�
 class MustBuyCodesManager:
     __instance = None
     __db = 0
@@ -696,9 +698,9 @@
         data = get_gp_list()
     list = []
     for d in data:
-        if d[0:2] == '00':
+        if tool.is_sz_code(d):
             list.append("SZSE.{}".format(d))
-        elif d[0:2] == '60':
+        elif tool.is_sh_code(d):
             list.append("SHSE.{}".format(d))
     return list
 
@@ -710,9 +712,9 @@
     # 鑾峰彇鏀剁洏浠�
     @classmethod
     def get_price_pre(cls, code):
-        result = RedisUtils.get(cls.__redisManager.getRedis(), "price-pre-{}".format(code))
-        if result is not None:
-            return float(result)
+        fdatas = log_export.load_pre_close_price()
+        if code in fdatas:
+            return round(float(fdatas.get(code)), 2)
         return None
 
     # 鑾峰彇缂撳瓨
@@ -731,8 +733,9 @@
         codes = get_gp_list()
         if code not in codes and not FirstCodeManager().is_in_first_record_cache(code) and not force:
             return
-        RedisUtils.setex(cls.__redisManager.getRedis(), "price-pre-{}".format(code), tool.get_expire(), str(price))
-        cls.__price_pre_cache[code] = float(price)
+        price = round(float(price), 2)
+        logger_pre_close_price.info(f"{code}-{price}")
+        cls.__price_pre_cache[code] = price
 
 
 __limit_up_price_dict = {}
@@ -746,7 +749,7 @@
     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("1.1"))
+    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
 
@@ -757,10 +760,16 @@
     return None
 
 
-def get_limit_up_price_by_preprice(price):
+def get_limit_up_price_by_preprice(code, price):
     if price is None:
         return None
-    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("1.1"))
+    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_up_rate(code)}"))
+
+
+def get_limit_down_price_by_preprice(code, price):
+    if price is None:
+        return None
+    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
 
 
 # 鑾峰彇璺屽仠浠�
@@ -768,7 +777,7 @@
     price = CodePrePriceManager.get_price_pre_cache(code)
     if price is None:
         return None
-    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal("0.9"))
+    return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}"))
 
 
 # 鑾峰彇鐜颁环

--
Gitblit v1.8.0