| | |
| | | from utils.tool import CodeDataCacheUtil |
| | | |
| | | |
| | | def set_real_place_position(code, index, buy_single_index=None): |
| | | def set_real_place_position(code, index, buy_single_index=None, is_default = True): |
| | | # DCancelBigNumComputer().set_real_order_index(code, index) |
| | | SecondCancelBigNumComputer().set_real_place_order_index(code, index) |
| | | LCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index=buy_single_index) |
| | | HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index) |
| | | GCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index, is_default) |
| | | FCancelBigNumComputer().set_real_order_index(code, index) |
| | | |
| | | |
| | |
| | | |
| | | # 计算L后还没成交的手数 |
| | | def __compute_total_l_down_not_deal_num(self, code): |
| | | # 只有真实获取到下单位置后才开始计算 |
| | | |
| | | |
| | | try: |
| | | if code in self.__total_l_down_not_deal_num_dict and time.time() - \ |
| | | self.__total_l_down_not_deal_num_dict[code][ |
| | |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | deal_money = limit_up_price * orgin_deal_data[0] |
| | | if deal_money >= constant.L_CANCEL_FAST_DEAL_MIN_MONEY: |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate} 成交详情:{ orgin_deal_data[0]}/{total_l_down_not_deal_num[0]*100}" |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate} 成交详情:{ orgin_deal_data}/{total_l_down_not_deal_num}" |
| | | else: |
| | | return False, f"已达到撤单比例,未达到撤单金额:{deal_money}" |
| | | else: |
| | |
| | | cls.__instance = super(GCancelBigNumComputer, cls).__new__(cls, *args, **kwargs) |
| | | return cls.__instance |
| | | |
| | | def set_real_place_order_index(self, code, index, buy_single_index): |
| | | self.__real_place_order_index_dict[code] = index |
| | | def set_real_place_order_index(self, code, index, buy_single_index, is_default): |
| | | self.__real_place_order_index_dict[code] = (index, is_default) |
| | | start_index = buy_single_index |
| | | if code in self.__trade_progress_index_dict: |
| | | start_index = self.__trade_progress_index_dict.get(code) |
| | | self.__commpute_watch_indexes(code, start_index, index, from_real_order_index_changed=True) |
| | | self.__commpute_watch_indexes(code, start_index, (index, is_default), from_real_order_index_changed=True) |
| | | |
| | | def clear(self, code=None): |
| | | if code: |
| | |
| | | self.__trade_progress_index_dict.clear() |
| | | self.__watch_indexes_by_dict.clear() |
| | | |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index, from_real_order_index_changed=False): |
| | | if traded_index is None or real_order_index is None: |
| | | def __commpute_watch_indexes(self, code, traded_index, real_order_index_info, from_real_order_index_changed=False): |
| | | if traded_index is None or real_order_index_info is None: |
| | | return |
| | | real_order_index, is_default = real_order_index_info[0],real_order_index_info[1] |
| | | origin_watch_index = self.__watch_indexes_dict.get(code) |
| | | if origin_watch_index is None: |
| | | origin_watch_index = set() |
| | |
| | | # 在成交位置之后 |
| | | need_find_by = False |
| | | break |
| | | if need_find_by: |
| | | if need_find_by and not is_default: |
| | | l2_log.g_cancel_debug(code, f"启动小单备用监听:{start_index}-{real_order_index}") |
| | | temp_list = [] |
| | | for i in range(start_index, real_order_index): |
| | |
| | | def need_cancel(self, code, buy_exec_index, start_index, end_index): |
| | | if code not in self.__real_place_order_index_dict: |
| | | return False, None, "没有找到真实下单位" |
| | | real_place_order_index = self.__real_place_order_index_dict.get(code) |
| | | real_place_order_index, is_default = self.__real_place_order_index_dict.get(code) |
| | | total_datas = local_today_datas.get(code) |
| | | # 30s内有效 |
| | | if tool.trade_time_sub(total_datas[end_index]["val"]["time"], total_datas[buy_exec_index]["val"]["time"]) > 15: |
| | |
| | | buy_index in watch_indexes or buy_index in watch_indexes_by): |
| | | if buy_index in watch_indexes_by: |
| | | # 备用撤单,直接撤 |
| | | return True, data, "次大单撤" |
| | | return True, data, f"次大单撤:{buy_index}" |
| | | elif buy_index in watch_indexes: |
| | | # 大单撤需要重新计算大单撤单比例 |
| | | need_compute = True |
| | | break |
| | | if need_compute: |
| | | if need_compute and watch_indexes: |
| | | canceled_indexes = set() |
| | | for index in watch_indexes: |
| | | cancel_data = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_canceled_data_v2(code, index, |