| | |
| | | class Buy1PriceManager: |
| | | __redisManager = redis_manager.RedisManager(1) |
| | | __latest_data = {} |
| | | __current_buy_1_price = {} |
| | | |
| | | @classmethod |
| | | def __get_redis(cls): |
| | |
| | | data = json.loads(data) |
| | | return data[0], data[1] |
| | | |
| | | @classmethod |
| | | def __save_buy1_price(cls, code, buy_1_price): |
| | | cls.__current_buy_1_price[code] = buy_1_price |
| | | cls.__get_redis().setex(f"buy1_price-{code}", tool.get_expire(), buy_1_price) |
| | | |
| | | @classmethod |
| | | def __get_buy1_price(cls, code): |
| | | return cls.__get_redis().get(f"buy1_price-{code}") |
| | | |
| | | @classmethod |
| | | def get_buy1_price(cls, code): |
| | | if code in cls.__current_buy_1_price: |
| | | return cls.__current_buy_1_price.get(code) |
| | | return cls.__get_buy1_price(code) |
| | | |
| | | # 处理 |
| | | @classmethod |
| | | def process(cls, code, buy_1_price, time_str, limit_up_price, sell_1_price, sell_1_volumn): |
| | |
| | | if cls.__latest_data.get(code) == data_str: |
| | | return |
| | | cls.__latest_data[code] = data_str |
| | | # 保存买1价格 |
| | | cls.__save_buy1_price(code, buy_1_price) |
| | | |
| | | # 记录日志 |
| | | logger_trade_queue_price_info.info( |
| | | f"code={code} data: time_str-{time_str}, buy_1_price-{buy_1_price},limit_up_price-{limit_up_price},sell_1_price-{sell_1_price},sell_1_volumn-{sell_1_volumn}") |