From 6b002b4a90fd73db0daca682aec7a8b1318f1bff Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期日, 19 十一月 2023 23:23:42 +0800 Subject: [PATCH] 炸板过后的票下午买入需要看板块不是独苗 --- l2/l2_sell_manager.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-) diff --git a/l2/l2_sell_manager.py b/l2/l2_sell_manager.py index 2bf0544..2f7b1b6 100644 --- a/l2/l2_sell_manager.py +++ b/l2/l2_sell_manager.py @@ -13,6 +13,7 @@ from utils.tool import CodeDataCacheUtil +# 鍗栬鎯呬俊鎭� class L2MarketSellManager: __db = 0 __redis_manager = redis_manager.RedisManager(0) @@ -75,7 +76,6 @@ def get_current_total_sell_data(self, code): return self.__current_total_sell_data_cache.get(code) - # 鑾峰彇鍙傝�冨崠鐨勬暟鎹� def get_refer_sell_data(self, code, time_str): cuurent = self.__current_total_sell_data_cache.get(code) @@ -89,3 +89,57 @@ return None +# 鏉夸笂鍗栫粺璁� +class L2LimitUpSellManager: + __db = 0 + __redis_manager = redis_manager.RedisManager(0) + __instance = None + __limit_up_sell_cache = {} + + def __new__(cls, *args, **kwargs): + if not cls.__instance: + cls.__instance = super(L2LimitUpSellManager, cls).__new__(cls, *args, **kwargs) + cls.__load_datas() + return cls.__instance + + @classmethod + def __get_redis(cls): + return cls.__redis_manager.getRedis() + + @classmethod + def __load_datas(cls): + __redis = cls.__get_redis() + try: + keys = RedisUtils.keys(__redis, "limit_up_sell_indexes-*") + for k in keys: + code = k.split("-")[-1] + val = RedisUtils.smembers(__redis, k) + CodeDataCacheUtil.set_cache(cls.__limit_up_sell_cache, code, val) + except: + pass + finally: + RedisUtils.realse(__redis) + + def add_limit_up_sell(self, code, index): + if code not in self.__limit_up_sell_cache: + self.__limit_up_sell_cache[code] = set() + self.__limit_up_sell_cache[code].add(index) + RedisUtils.sadd_async(self.__db, f"limit_up_sell_indexes-{code}", index) + RedisUtils.expire_async(self.__db, f"limit_up_sell_indexes-{code}", tool.get_expire()) + + def remove_limit_up_sell(self, code, index): + if code in self.__limit_up_sell_cache: + self.__limit_up_sell_cache[code].discard(index) + RedisUtils.srem_async(self.__db, f"limit_up_sell_indexes-{code}", index) + + def clear(self): + self.__limit_up_sell_cache.clear() + keys = RedisUtils.keys(self.__get_redis(), "limit_up_sell_indexes-*") + for k in keys: + RedisUtils.delete_async(self.__db, k) + + # 璁剧疆褰撳墠鐨勬�诲崠 + def get_limit_up_sell_indexes(self, code): + if code in self.__limit_up_sell_cache: + return self.__limit_up_sell_cache[code] + return set() -- Gitblit v1.8.0