| | |
| | | @tool.singleton |
| | | class HumanRemoveForbiddenManager: |
| | | """ |
| | | 认为移黑管理 |
| | | 人为移黑管理 |
| | | """ |
| | | __db = 0 |
| | | redisManager = redis_manager.RedisManager(0) |
| | |
| | | |
| | | def is_in_cache(self, code): |
| | | return code in self.__codes_cache |
| | | |
| | | |
| | | |
| | | # 暂停下单代码管理 |
| | |
| | | """ |
| | | if code in self.__human_remove_codes: |
| | | self.__human_remove_codes.discard(code) |
| | | |
| | | |
| | | |
| | | class BlackListCodeManager: |
| | |
| | | return list |
| | | |
| | | |
| | | @tool.singleton |
| | | class CodePrePriceManager: |
| | | __price_pre_cache = {} |
| | | __redisManager = redis_manager.RedisManager(0) |
| | | |
| | | def __init__(self): |
| | | fdatas = log_export.load_pre_close_price() |
| | | for code, v in fdatas.items(): |
| | | self.__price_pre_cache[code] = round(float(v), 2) |
| | | |
| | | # 获取收盘价 |
| | | @classmethod |
| | | def get_price_pre(cls, code): |
| | | def get_price_pre(self, code): |
| | | fdatas = log_export.load_pre_close_price() |
| | | if code in fdatas: |
| | | return round(float(fdatas.get(code)), 2) |
| | | return None |
| | | |
| | | # 获取缓存 |
| | | @classmethod |
| | | def get_price_pre_cache(cls, code): |
| | | if code in cls.__price_pre_cache: |
| | | return float(cls.__price_pre_cache[code]) |
| | | val = cls.get_price_pre(code) |
| | | def get_price_pre_cache(self, code): |
| | | if code in self.__price_pre_cache: |
| | | return float(self.__price_pre_cache[code]) |
| | | val = self.get_price_pre(code) |
| | | if val: |
| | | cls.__price_pre_cache[code] = val |
| | | self.__price_pre_cache[code] = val |
| | | return val |
| | | |
| | | # 设置收盘价 |
| | | @classmethod |
| | | def set_price_pre(cls, code, price, force=False): |
| | | def set_price_pre(self, code, price, force=False): |
| | | if float(price) > 1000: |
| | | async_log_util.info(logger_debug, f"获取昨日收盘价异常:{code}-{price}") |
| | | return |
| | | if code in cls.__price_pre_cache and not force: |
| | | if code in self.__price_pre_cache and not force: |
| | | return |
| | | price = round(float(price), 2) |
| | | logger_pre_close_price.info(f"{code}-{price}") |
| | | cls.__price_pre_cache[code] = price |
| | | self.__price_pre_cache[code] = price |
| | | |
| | | |
| | | __limit_up_price_dict = {} |
| | |
| | | # 读取内存中的值 |
| | | if code in __limit_up_price_dict: |
| | | return __limit_up_price_dict[code] |
| | | price = CodePrePriceManager.get_price_pre_cache(code) |
| | | 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(tool.get_limit_up_rate(code))) |
| | | __limit_up_price_dict[code] = limit_up_price |
| | | return limit_up_price |
| | | |
| | | |
| | | def clear_limit_up_price_cache(code): |
| | | if code in __limit_up_price_dict: |
| | | __limit_up_price_dict.pop(code) |
| | | |
| | | |
| | | def get_limit_up_price_as_num(code): |
| | |
| | | |
| | | # 获取跌停价 |
| | | def get_limit_down_price(code): |
| | | price = CodePrePriceManager.get_price_pre_cache(code) |
| | | price = CodePrePriceManager().get_price_pre_cache(code) |
| | | if price is None: |
| | | return None |
| | | return tool.to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{tool.get_limit_down_rate(code)}")) |
| | |
| | | RedisUtils.delete(redis_instance, "first_code_record", auto_free=False) |
| | | RedisUtils.delete(redis_instance, "first_code_limited_up_record", auto_free=False) |
| | | finally: |
| | | RedisUtils.realse(redis_instance) |
| | | RedisUtils.realse(redis_instance) |