| | |
| | | __redisManager = redis_manager.RedisManager(1) |
| | | __latest_data = {} |
| | | __current_buy_1_price = {} |
| | | __buy1_price_info_cache = {} |
| | | |
| | | @classmethod |
| | | def __get_redis(cls): |
| | |
| | | # 保存买1价格信息 |
| | | @classmethod |
| | | def __save_buy1_price_info(cls, code, limit_up_time, open_limit_up_time): |
| | | tool.CodeDataCacheUtil.set_cache(cls.__buy1_price_info_cache, code, (limit_up_time, open_limit_up_time)) |
| | | RedisUtils.setex(cls.__get_redis(),f"buy1_price_limit_up_info-{code}", tool.get_expire(), |
| | | json.dumps((limit_up_time, open_limit_up_time))) |
| | | |
| | |
| | | return None, None |
| | | data = json.loads(data) |
| | | return data[0], data[1] |
| | | |
| | | @classmethod |
| | | def __get_buy1_price_info_cache(cls, code): |
| | | cache_result = tool.CodeDataCacheUtil.get_cache(cls.__buy1_price_info_cache, code) |
| | | if cache_result[0]: |
| | | return cache_result[1] |
| | | val = cls.__get_buy1_price_info(code) |
| | | tool.CodeDataCacheUtil.set_cache(cls.__buy1_price_info_cache, code, val) |
| | | return val |
| | | |
| | | @classmethod |
| | | def __save_buy1_price(cls, code, buy_1_price): |
| | |
| | | return |
| | | |
| | | is_limit_up = abs(float(limit_up_price) - float(buy_1_price)) < 0.01 |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info(code) |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info_cache(code) |
| | | if old_limit_up_time and old_open_limit_up_time: |
| | | return |
| | | if is_limit_up and old_limit_up_time is None and float(sell_1_price) < 0.1 and int(sell_1_volumn) <= 0: |
| | |
| | | # 是否可以下单 |
| | | @classmethod |
| | | def is_can_buy(cls, code): |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info(code) |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info_cache(code) |
| | | if old_limit_up_time and old_open_limit_up_time: |
| | | return True |
| | | return False |
| | |
| | | # 返回涨停时间与炸板时间 |
| | | @classmethod |
| | | def get_limit_up_info(cls, code): |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info(code) |
| | | old_limit_up_time, old_open_limit_up_time = cls.__get_buy1_price_info_cache(code) |
| | | return old_limit_up_time, old_open_limit_up_time |
| | | |
| | | # 设置涨停时间 |