| | |
| | | self.__clear_data(code) |
| | | |
| | | |
| | | # ---------------------------------RD撤------------------------------- |
| | | # 扫入下单大单撤 |
| | | class RDCancelBigNumComputer: |
| | | __db = 0 |
| | | __redis_manager = redis_manager.RedisManager(0) |
| | | |
| | | __instance = None |
| | | |
| | | # 下单位之后的封单中的大单 |
| | | __watch_indexes_cache = {} |
| | | |
| | | def __new__(cls, *args, **kwargs): |
| | | if not cls.__instance: |
| | | cls.__instance = super(RDCancelBigNumComputer, 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): |
| | | keys = RedisUtils.keys(cls.__get_redis(), "radical_big_order_watch-*") |
| | | for k in keys: |
| | | code = k.split("-")[1] |
| | | val = RedisUtils.get(cls.__get_redis(), k) |
| | | val = json.loads(val) |
| | | cls.__watch_indexes_cache[code] = set(val) |
| | | |
| | | def set_watch_indexes(self, code, indexes): |
| | | l2_log.d_cancel_debug(code, f"扫入大单监听:{indexes}") |
| | | self.__watch_indexes_cache[code] = set(indexes) |
| | | RedisUtils.setex_async(self.__db, f"radical_big_order_watch-{code}", tool.get_expire(), |
| | | json.dumps(list(indexes))) |
| | | |
| | | def need_cancel(self, code, start_index, end_index): |
| | | """ |
| | | 是否需要撤单 |
| | | @param code: |
| | | @param start_index: |
| | | @param end_index: |
| | | @return: 是否需要撤单,撤单索引, 消息 |
| | | """ |
| | | watch_indexes = self.__watch_indexes_cache.get(code) |
| | | if not watch_indexes: |
| | | return False,None, "无大单监听" |
| | | total_datas = local_today_datas.get(code) |
| | | for i in range(start_index, end_index + 1): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy_cancel(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data_v2(data, |
| | | local_today_buyno_map.get( |
| | | code)) |
| | | if buy_index is None: |
| | | continue |
| | | if buy_index in watch_indexes: |
| | | return True, data, f"大单撤单({buy_index})" |
| | | return False,None, "无大单撤单" |
| | | |
| | | |
| | | def __clear_data(self, code): |
| | | if code in self.__watch_indexes_cache: |
| | | self.__watch_indexes_cache.pop(code) |
| | | RedisUtils.delete_async(self.__db, f"radical_big_order_watch-{code}") |
| | | |
| | | def clear_data(self, code): |
| | | self.__clear_data(code) |
| | | |
| | | |
| | | # 新F撤,根据成交数据来撤 |
| | | class FCancelBigNumComputer: |
| | | __db = 0 |