| | |
| | | def __compute_left_big_num(cls, code, buy_single_index, start_index, end_index, total_data, volume_rate_index): |
| | | # 点火大单数量 |
| | | fire_count = cls.__sCancelParamsManager.get_max_exclude_count(volume_rate_index) |
| | | return cls.compute_left_big_num(code, buy_single_index, start_index, end_index, total_data, fire_count, constant.S_CANCEL_MIN_MONEY) |
| | | return cls.compute_left_big_num(code, buy_single_index, start_index, end_index, total_data, fire_count, |
| | | constant.S_CANCEL_MIN_MONEY) |
| | | |
| | | # 计算未撤的总手数 |
| | | @classmethod |
| | |
| | | val = json.loads(val) |
| | | return val[0], val[1], val[2], val[3], val[4] |
| | | |
| | | # 保存已经撤单的监听位置 |
| | | @classmethod |
| | | def __add_watch_canceled_index(cls, code, index): |
| | | key = f"h_cancel_watch_canceled_indexs-{code}" |
| | | cls.__getRedis().sadd(key, index) |
| | | cls.__getRedis().expire(key, tool.get_expire()) |
| | | |
| | | @classmethod |
| | | def __get_watch_canceled_index(cls, code): |
| | | key = f"h_cancel_watch_canceled_indexs-{code}" |
| | | return cls.__getRedis().smembers(key) |
| | | |
| | | @classmethod |
| | | def __del_watch_canceled_index(cls, code): |
| | | key = f"h_cancel_watch_canceled_indexs-{code}" |
| | | cls.__getRedis().delete(key) |
| | | |
| | | # 保存成交进度 |
| | | @classmethod |
| | | def __save_traded_progress(cls, code, origin_process_index, latest_process_index): |
| | |
| | | @classmethod |
| | | def __clear_data(cls, code): |
| | | ks = ["h_cancel_compute_data-{}".format(code), f"h_cancel_watch_indexs_exec-{code}", |
| | | f"h_cancel_watch_indexs-{code}", f"h_cancel_traded_progress-{code}"] |
| | | f"h_cancel_watch_indexs-{code}", f"h_cancel_traded_progress-{code}", |
| | | f"h_cancel_watch_canceled_indexs-{code}"] |
| | | for key in ks: |
| | | cls.__getRedis().delete(key) |
| | | |
| | | @classmethod |
| | | def need_cancel(cls, code, buy_exec_index, start_index, end_index, total_data, local_today_num_operate_map, |
| | | def need_cancel(cls, code, buy_single_index, buy_exec_index, start_index, end_index, total_data, |
| | | local_today_num_operate_map, |
| | | buy_volume_index, volume_index, |
| | | is_first_code): |
| | | time_space = tool.trade_time_sub(total_data[start_index]["val"]["time"], |
| | | total_data[buy_exec_index]["val"]["time"]) |
| | | if time_space >= constant.S_CANCEL_EXPIRE_TIME - 1: |
| | | # 开始计算需要监控的单 |
| | | cls.__compute_watch_indexs_after_exec(code, buy_exec_index, total_data, local_today_num_operate_map, |
| | | buy_volume_index) |
| | | cls.__compute_watch_indexs_after_single(code, buy_single_index, buy_exec_index, total_data, |
| | | local_today_num_operate_map, buy_volume_index) |
| | | |
| | | # 守护30s以外的数据 |
| | | if time_space <= constant.S_CANCEL_EXPIRE_TIME: |
| | |
| | | local_today_num_operate_map) |
| | | if buy_index is not None and buy_index in watch_indexs_dict: |
| | | cancel_num += data["re"] * val["num"] |
| | | # 加入 |
| | | cls.__add_watch_canceled_index(code, f"{buy_index}-{val['num']}") |
| | | rate__ = round(cancel_num / total_nums, 2) |
| | | if rate__ > cancel_rate_threshold: |
| | | indexs__ = list(watch_indexs_dict.keys()) |
| | |
| | | total_nums, cancel_rate_threshold) |
| | | logger_l2_h_cancel.info( |
| | | f"code-{code} H级撤单计算结果 范围:{start_index}-{end_index} 处理进度:{process_index} 目标比例:{cancel_rate_threshold} 取消计算结果:{cancel_num}/{total_nums}") |
| | | # H撤已撤订单 |
| | | logger_l2_h_cancel.info( f"code-{code} H撤已撤订单:{cls.__get_watch_canceled_index(code)}") |
| | | # 保存处理进度与数据 |
| | | cls.__save_compute_data(code, process_index, cancel_num) |
| | | return False, None |
| | |
| | | |
| | | # 计算执行位置之后的需要监听的数据 |
| | | @classmethod |
| | | def __compute_watch_indexs_after_exec(cls, code, buy_exec_index, total_data, local_today_num_operate_map, |
| | | buy_volume_index): |
| | | def __compute_watch_indexs_after_single(cls, code, buy_single_index, buy_exec_index, total_data, |
| | | local_today_num_operate_map, buy_volume_index): |
| | | watch_list, process_index_old, total_count_old, big_num_count_old, finish = cls.__get_watch_index_set_after_exec( |
| | | code) |
| | | if watch_list and finish: |
| | |
| | | # H撤单 |
| | | MIN_H_COUNT = cls.__hCancelParamsManager.get_max_watch_count(buy_volume_index) |
| | | |
| | | for i in range(buy_exec_index, total_data[-1]["index"] + 1): |
| | | for i in range(buy_single_index, total_data[-1]["index"] + 1): |
| | | if i <= process_index_old: |
| | | continue |
| | | process_index = i |