| | |
| | | from db import redis_manager_delegate as redis_manager |
| | | from db.redis_manager_delegate import RedisUtils |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_debug |
| | | from log_module.log import logger_debug, logger_limit_up_record |
| | | from utils import global_util, tool |
| | | |
| | | |
| | |
| | | tool.CodeDataCacheUtil.set_cache(self.__max_price_info_cache, code, price_info) |
| | | RedisUtils.setex_async( |
| | | self.__db, "max_price_info-{}".format(code), tool.get_expire(), json.dumps(price_info)) |
| | | async_log_util.info(logger_debug, f"最大现价:{code}-{price_info}") |
| | | # async_log_util.info(logger_debug, f"最大现价:{code}-{price_info}") |
| | | if self.__is_limit_up(code, price, sell1_info): |
| | | if code not in self.__limit_up_latest_info_cache: |
| | | self.__limit_up_latest_info_cache[code] = time |
| | |
| | | if code not in self.__limit_up_records_cache: |
| | | self.__limit_up_records_cache[code] = [] |
| | | if code in self.__limit_up_latest_info_cache: |
| | | self.__limit_up_records_cache[code].append((self.__limit_up_latest_info_cache.get(code), time)) |
| | | limit_up_info = (self.__limit_up_latest_info_cache.get(code), time) |
| | | self.__limit_up_records_cache[code].append(limit_up_info) |
| | | self.__limit_up_latest_info_cache.pop(code) |
| | | async_log_util.info(logger_limit_up_record, f"{code}-{limit_up_info}") |
| | | |
| | | def get_max_limit_up_time(self, code): |
| | | """ |
| | |
| | | max_space_time = 0 |
| | | if code in self.__limit_up_latest_info_cache: |
| | | max_space_time = tool.trade_time_sub(tool.get_now_time_str(), self.__limit_up_latest_info_cache[code]) |
| | | if code in self.__limit_up_records_cache: |
| | | if self.__limit_up_records_cache.get(code): |
| | | max_item = max(self.__limit_up_records_cache[code], key=lambda x: tool.trade_time_sub(x[1], x[0])) |
| | | max_space_time_his = tool.trade_time_sub(max_item[1], max_item[0]) |
| | | if max_space_time_his > max_space_time: |
| | | max_space_time = max_space_time_his |
| | | return max_space_time |
| | | except Exception as e: |
| | | async_log_util.error(logger_debug, f"获取最大涨停时间出错:{str(e)}") |
| | | async_log_util.error(logger_debug, f"获取最大涨停时间出错:{code}-{str(e)}") |
| | | return 0 |
| | | |
| | | def get_price_info_cache(self, code): |