| | |
| | | # 计算观察索引,倒序计算 |
| | | |
| | | def __compute_watch_index(self, code, buy_single_index): |
| | | if buy_single_index is None: |
| | | return |
| | | if self.__cancel_watch_indexs_cache.get(code): |
| | | return |
| | | real_place_order_index = self.__SecondCancelBigNumComputer.get_real_place_order_index_cache(code) |
| | |
| | | # 返回监听范围与已撤单索引 |
| | | def get_watch_index_dict(self, code): |
| | | return {}, set() |
| | | |
| | | def start_compute_watch_indexes(self,code,buy_single_index): |
| | | self.__compute_watch_index(code, buy_single_index) |
| | | |
| | | |
| | | |
| | | |
| | | # ---------------------------------D撤------------------------------- |
| | |
| | | return |
| | | self.__last_trade_progress_dict[code] = index |
| | | |
| | | if not self.__is_l_down_can_cancel(code): |
| | | # L后已经不能守护 |
| | | HourCancelBigNumComputer().start_compute_watch_indexes(code, buy_single_index) |
| | | |
| | | # 重新计算成交位置临近大单撤单 |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1, |
| | | self.__real_place_order_index_dict.get(code)) |
| | |
| | | if left_count > 0: |
| | | watch_indexes.add(data["index"]) |
| | | break |
| | | # 移除当前index |
| | | watch_indexes.discard(index) |
| | | self.__set_watch_indexes(code, buy_single_index, watch_indexes) |
| | | |
| | | def __compute_need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code): |
| | |
| | | |
| | | return False, None |
| | | |
| | | # L后是否还有可能撤单 |
| | | def __is_l_down_can_cancel(self, code): |
| | | watch_indexes = self.__get_watch_indexes_cache(code) |
| | | if not watch_indexes: |
| | | return True |
| | | trade_index = self.__last_trade_progress_dict.get(code) |
| | | if trade_index is None: |
| | | return True |
| | | # 计算已经成交的比例 |
| | | total_datas = local_today_datas.get(code) |
| | | total_deal_nums=0 |
| | | total_nums = 1 |
| | | for index in watch_indexes: |
| | | data = total_datas[index] |
| | | val = data["val"] |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | index, |
| | | total_datas, |
| | | local_today_canceled_buyno_map.get( |
| | | code)) |
| | | total_nums +=val["num"] |
| | | if left_count >0 and index < trade_index: |
| | | total_deal_nums+=val["num"] |
| | | thresh_hold_rate = LCancelRateManager.get_cancel_rate(code) |
| | | if total_deal_nums/total_nums > 1 - thresh_hold_rate-0.05: |
| | | return False |
| | | return True |
| | | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index, total_data, is_first_code): |
| | | if buy_exec_index is None: |
| | | return False, "尚未找到下单位置", "" |
| | |
| | | raise e |
| | | return can_cancel, cancel_data, extra_msg |
| | | |
| | | |
| | | |
| | | |
| | | def place_order_success(self, code): |
| | | self.clear(code) |
| | | |