| | |
| | | self.__last_trade_progress_dict[code] = index |
| | | if self.__real_place_order_index_dict.get(code): |
| | | # 触发计算 |
| | | self.compute_watch_index(code, self.__last_trade_progress_dict.get(code), self.__real_place_order_index_dict.get(code)) |
| | | self.compute_watch_index(code, self.__last_trade_progress_dict.get(code), |
| | | self.__real_place_order_index_dict.get(code)) |
| | | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, |
| | | _local_today_num_operate_map, is_first_code): |
| | |
| | | break |
| | | if need_compute: |
| | | # 计算撤单比例 |
| | | watch_indexes_list = list(watch_indexes) |
| | | watch_indexes_list.sort() |
| | | canceled_count = 0 |
| | | for wi in watch_indexes: |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count(code, |
| | |
| | | total_data, |
| | | _local_today_num_operate_map) |
| | | canceled_count += total_data[wi]["re"] - left_count |
| | | if wi == watch_indexes_list[-1] and left_count == 0: |
| | | # 离下单位置最近的一个撤单,必须触发撤单 |
| | | l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},临近撤单:{wi}") |
| | | return True, total_data[-1] |
| | | |
| | | rate = round(canceled_count / total_count, 3) |
| | | l2_log.l_cancel_debug(code, f"计算范围:{start_index}-{end_index},已撤单比例:{rate}") |
| | | if rate >= constant.L_CANCEL_RATE: |
| | |
| | | RedisUtils.expire_async(self.__db, f"huaxin_local_order_id-{code}", tool.get_expire()) |
| | | |
| | | # 删除订单ID |
| | | |
| | | def remove_local_order_id(self, code, local_order_id): |
| | | val = local_order_id |
| | | if code in self.__huaxin_local_order_id_cache: |
| | |
| | | RedisUtils.srem_async(self.__db, f"huaxin_local_order_id-{code}", val) |
| | | |
| | | # 查询所有的订单号 |
| | | |
| | | def list_local_order_ids(self, code): |
| | | return RedisUtils.smembers(self.__get_redis(), f"huaxin_local_order_id-{code}") |
| | | |