From 12ed2a63a601854075886b6673bf03d1b4de75c8 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 01 十一月 2023 14:23:03 +0800
Subject: [PATCH] L撤H撤数据外部接口添加/涨幅过高代码记录

---
 code_attribute/code_nature_analyse.py |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/code_attribute/code_nature_analyse.py b/code_attribute/code_nature_analyse.py
index dca8f78..89a63b3 100644
--- a/code_attribute/code_nature_analyse.py
+++ b/code_attribute/code_nature_analyse.py
@@ -119,6 +119,51 @@
             RedisUtils.delete_async(self.__db, k)
 
 
+# 娑ㄥ箙杩囬珮鐨勭エ绠$悊
+class HighIncreaseCodeManager:
+    __db = 0
+    __instance = None
+    __redis_manager = redis_manager.RedisManager(0)
+    __high_increase_codes = set()
+
+    def __new__(cls, *args, **kwargs):
+        if not cls.__instance:
+            cls.__instance = super(HighIncreaseCodeManager, cls).__new__(cls, *args, **kwargs)
+            cls.__load_datas()
+        return cls.__instance
+
+    @classmethod
+    def __load_datas(cls):
+        __redis = cls.__get_redis()
+        try:
+            cls.__high_increase_codes = RedisUtils.smembers(__redis, "high_increase_codes")
+        finally:
+            RedisUtils.realse(__redis)
+
+    @classmethod
+    def __get_redis(cls):
+        return cls.__redis_manager.getRedis()
+
+    def add_code(self, code):
+        if self.__high_increase_codes is None:
+            self.__high_increase_codes = set()
+        self.__high_increase_codes.add(code)
+        RedisUtils.sadd_async(self.__db, "high_increase_codes", code)
+        RedisUtils.expire_async(self.__db, "high_increase_codes", tool.get_expire())
+
+    def is_in(self, code):
+        return code in self.__high_increase_codes
+
+    # 鍔犺浇鍏ㄩ儴
+    def list_all(self):
+        return self.__high_increase_codes
+
+    def clear(self):
+        if self.__high_increase_codes:
+            self.__high_increase_codes.clear()
+        RedisUtils.delete_async(self.__db, "high_increase_codes")
+
+
 # 璁剧疆鍘嗗彶K绾�
 def set_record_datas(code, limit_up_price, record_datas):
     k_format = get_k_format(float(limit_up_price), record_datas)
@@ -215,7 +260,7 @@
         for t in temp_datas:
             if t[1]:
                 t_count += 1
-        if t_count >= 3 and limit_down_rate < 0.2:
+        if t_count >= 3 and limit_down_rate < 0.15:
             # 闄嶅箙灏忎簬20%
             return True
 
@@ -493,4 +538,7 @@
 
 
 if __name__ == "__main__":
-    print(CodeNatureRecordManager.get_k_format("603717"))
+    HighIncreaseCodeManager().add_code("000333")
+    print(HighIncreaseCodeManager().is_in("000333"))
+    print(HighIncreaseCodeManager().is_in("000222"))
+

--
Gitblit v1.8.0