| | |
| | | data = total_data[i] |
| | | val = data['val'] |
| | | total_num += val['num'] * data['re'] |
| | | if total_num > threshold_num: |
| | | if total_num > threshold_num: |
| | | return |
| | | self.__last_trade_progress_dict[code] = index |
| | | |
| | |
| | | |
| | | # 判断当前订单是否已经撤单 |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count(code, i, total_data, |
| | | local_today_num_operate_map.get(code)) |
| | | local_today_num_operate_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | watch_indexes.add(i) |
| | | total_num += val['num'] * data['re'] |
| | | |
| | | if len(watch_indexes) >= constant.L_CANCEL_MIN_WATCH_COUNT and total_num > threshold_num: |
| | | break |
| | | l2_log.l_cancel_debug(code, f"设置监听范围,成交进度-{index} , 数据范围:{start_index}-{end_index} 监听范围-{watch_indexes} 纯买手数:{total_num}/{threshold_num}") |
| | | l2_log.l_cancel_debug(code, |
| | | f"设置监听范围,成交进度-{index} , 数据范围:{start_index}-{end_index} 监听范围-{watch_indexes} 纯买手数:{total_num}/{threshold_num}") |
| | | # 数据维护 |
| | | add_indexes = watch_indexes - old_watch_indexes |
| | | delete_indexes = old_watch_indexes - watch_indexes |
| | |
| | | self.__del_watch_indexes(code, delete_indexes) |
| | | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, |
| | | local_today_num_operate_map, is_first_code): |
| | | _local_today_num_operate_map, is_first_code): |
| | | watch_indexes = self.__get_watch_indexes_cache(code) |
| | | if not watch_indexes: |
| | | return False, None |
| | |
| | | if L2DataUtil.is_limit_up_price_buy_cancel(val): |
| | | # 查询买入位置 |
| | | buy_index = l2_data_source_util.L2DataSourceUtils.get_buy_index_with_cancel_data(code, data, |
| | | local_today_num_operate_map) |
| | | _local_today_num_operate_map) |
| | | if buy_index is not None and buy_index in watch_indexes: |
| | | need_compute = True |
| | | break |
| | |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count(code, |
| | | wi, |
| | | total_data, |
| | | local_today_num_operate_map) |
| | | _local_today_num_operate_map) |
| | | canceled_num += (total_data[wi]["re"] - left_count) * int(total_data[wi]["val"]["num"]) |
| | | rate = round(canceled_num / total_num, 3) |
| | | l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},已撤单比例:{rate}") |
| | |
| | | |
| | | return False, None |
| | | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, local_today_num_operate_map, |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, _local_today_num_operate_map, |
| | | 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.L_CANCEL_START_TIME or int(tool.get_now_time_str().replace(":", "")) > int("145000"): |
| | | return False, None |
| | | can_cancel, cancel_data = self.__compute_need_cancel(code, buy_exec_index, start_index, end_index, total_data, |
| | | local_today_num_operate_map, is_first_code) |
| | | _local_today_num_operate_map, is_first_code) |
| | | if can_cancel: |
| | | # 判断成交进度位置到当前位置的净买入 |
| | | try: |
| | |
| | | if left_count > 0: |
| | | buy_nums += left_count * data["val"]["num"] |
| | | if buy_nums > threshold_num: |
| | | l2_log.l_cancel_debug(code, f"LX阻断L撤撤单:{buy_nums}/{threshold_num}") |
| | | l2_log.l_cancel_debug(code, f"LX阻断L撤撤单:{buy_nums}/{threshold_num} 成交位置-{transaction_index} 真实下单位置-{place_order_index}") |
| | | return False, "LX阻断L撤撤单" |
| | | l2_log.l_cancel_debug(code, f"LX尚未阻断L撤撤单:{buy_nums}/{threshold_num}") |
| | | l2_log.l_cancel_debug(code, f"LX尚未阻断L撤撤单:{buy_nums}/{threshold_num} 成交位置-{transaction_index} 真实下单位置-{place_order_index}") |
| | | return can_cancel, cancel_data |
| | | except Exception as e: |
| | | l2_log.l_cancel_debug(code, f"LX撤单计算异常:{str(e)}") |