From 1a0be577a89727ef6b80245b6b53c8ddf43ca7d9 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 07 六月 2024 00:37:26 +0800
Subject: [PATCH] 可购买创业板

---
 code_attribute/code_data_util.py |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/code_attribute/code_data_util.py b/code_attribute/code_data_util.py
index 1378431..9d510fd 100644
--- a/code_attribute/code_data_util.py
+++ b/code_attribute/code_data_util.py
@@ -7,10 +7,11 @@
 import time
 
 from code_attribute import gpcode_manager
-from db import mysql_data, redis_manager
-from db.redis_manager import RedisUtils
+from db import mysql_data_delegate as mysql_data, redis_manager_delegate as redis_manager
+from db.redis_manager_delegate import RedisUtils
 from utils import tool
 
+__db = 0
 _redisManager = redis_manager.RedisManager(0)
 
 
@@ -19,9 +20,9 @@
     if code == '600066':
         print('杩涘叆璋冭瘯')
     # 鏄ㄦ棩鏀剁洏浠�
-    price_close = gpcode_manager.get_price_pre(code)
-    max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("1.1"))
-    min_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal("0.9"))
+    price_close = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code)
+    max_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal(tool.get_limit_up_rate(code)))
+    min_price = tool.to_price(decimal.Decimal(str(price_close)) * decimal.Decimal(tool.get_limit_down_rate(code)))
     if min_price <= decimal.Decimal(str(price)) <= max_price:
         return True
     return False
@@ -29,17 +30,23 @@
 
 # 鑷敱娴侀�氳偂鏈伐鍏风被
 class ZYLTGBUtil:
+    __db = 0
+
     @classmethod
     def save(cls, code, val, unit):
-        redis = _redisManager.getRedis()
-        RedisUtils.setex(redis,"zyltgb-{}".format(code), tool.get_expire(),
-                    round(float(val) * 100000000) if int(unit) == 0 else round(
-                        float(val) * 10000))
+        RedisUtils.setex(_redisManager.getRedis(), "zyltgb-{}".format(code), tool.get_expire(),
+                         round(float(val) * 100000000) if int(unit) == 0 else round(
+                             float(val) * 10000))
+
+    @classmethod
+    def save_async(cls, code, val, unit):
+        RedisUtils.setex_async(cls.__db, "zyltgb-{}".format(code), tool.get_expire(),
+                               round(float(val) * 100000000) if int(unit) == 0 else round(
+                                   float(val) * 10000))
 
     @classmethod
     def get(cls, code):
-        redis = _redisManager.getRedis()
-        val = RedisUtils.get(redis, "zyltgb-{}".format(code))
+        val = RedisUtils.get(_redisManager.getRedis(), "zyltgb-{}".format(code))
         if val is not None:
             return int(val)
         return None
@@ -67,7 +74,4 @@
 
 
 if __name__ == "__main__":
-    redis = _redisManager.getRedis()
-    keys = RedisUtils.keys(redis, "zyltgb-*")
-    for key in keys:
-        RedisUtils.delete(redis, key)
+    pass

--
Gitblit v1.8.0