| | |
| | | # 计算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][ |
| | | 1] < 1: |
| | | if code in self.__total_l_down_not_deal_num_dict and time.time() - \ |
| | | self.__total_l_down_not_deal_num_dict[code][ |
| | | 1] < 1: |
| | | # 需要间隔1s更新一次 |
| | | return |
| | | l_down_cancel_info = self.__cancel_watch_index_info_cache.get(code) |
| | |
| | | code)) |
| | | if left_count > 0: |
| | | total_left_num += val["num"] |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | total_money = limit_up_price * total_left_num |
| | | # 如果200<=金额<=1000w才会生效,否则就设为-1 |
| | | if 20000 <= total_money <= 100000: |
| | | pass |
| | | else: |
| | | total_left_num = -1 |
| | | self.__total_l_down_not_deal_num_dict[code] = (total_left_num, time.time()) |
| | | except Exception as e: |
| | | async_log_util.exception(logger_l2_l_cancel, e) |
| | |
| | | # self.compute_watch_index(code, self.__last_trade_progress_dict.get(code), |
| | | # self.__real_place_order_index_dict.get(code)) |
| | | |
| | | def add_transaction_data(self, transaction_data): |
| | | if not transaction_data: |
| | | def add_transaction_datas(self,code, transaction_datas): |
| | | if not transaction_datas: |
| | | return False, "成交数据为空" |
| | | code = transaction_data[0] |
| | | buyno_map = local_today_buyno_map.get(code) |
| | | if not buyno_map: |
| | | return False, "没找到买单字典" |
| | | buy_data = buyno_map.get(str(transaction_data[6])) |
| | | if not buy_data: |
| | | return False, f"没有找到对应买单({transaction_data[6]})" |
| | | total_datas = local_today_datas.get(code) |
| | | if not total_datas: |
| | | return False, "L2数据为空" |
| | | |
| | | l_down_cancel_info = self.__cancel_watch_index_info_cache.get(code) |
| | | if not l_down_cancel_info: |
| | | return False, "L撤为空" |
| | | l_down_indexes = l_down_cancel_info[2] |
| | | if buy_data["index"] not in l_down_indexes: |
| | | return False, "非L撤监听数据成交" |
| | | # 统计数据 |
| | | orgin_deal_data = self.__l_down_latest_deal_info_dict.get(code) |
| | | if not orgin_deal_data: |
| | | orgin_deal_data = [0, None] |
| | | time_str = l2_huaxin_util.convert_time(transaction_data[3]) |
| | | if orgin_deal_data[1] != time_str: |
| | | orgin_deal_data[0] = transaction_data[2] |
| | | orgin_deal_data[1] = time_str |
| | | else: |
| | | orgin_deal_data[0] += transaction_data[2] |
| | | self.__l_down_latest_deal_info_dict[code] = orgin_deal_data |
| | | |
| | | for transaction_data in transaction_datas: |
| | | buy_data = buyno_map.get(str(transaction_data[6])) |
| | | if not buy_data: |
| | | continue |
| | | if buy_data["index"] not in l_down_indexes: |
| | | continue |
| | | # 统计数据 |
| | | orgin_deal_data = self.__l_down_latest_deal_info_dict.get(code) |
| | | if not orgin_deal_data: |
| | | orgin_deal_data = [0, None] |
| | | time_str = l2_huaxin_util.convert_time(transaction_data[3]) |
| | | if orgin_deal_data[1] != time_str: |
| | | orgin_deal_data[0] = transaction_data[2] |
| | | orgin_deal_data[1] = time_str |
| | | else: |
| | | orgin_deal_data[0] += transaction_data[2] |
| | | self.__l_down_latest_deal_info_dict[code] = orgin_deal_data |
| | | # 计算成交比例 |
| | | total_l_down_not_deal_num = self.__total_l_down_not_deal_num_dict.get(code) |
| | | if total_l_down_not_deal_num is None: |
| | | return False, "L后撤数据为空" |
| | | return False, "L撤未成交统计为空" |
| | | orgin_deal_data = self.__l_down_latest_deal_info_dict.get(code) |
| | | if orgin_deal_data is None: |
| | | return False, "L后暂时无成交" |
| | | |
| | | threshold_rate = 0.5 |
| | | rate = orgin_deal_data[0] / (total_l_down_not_deal_num[0] * 100) |
| | | if rate > threshold_rate: |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate}" |
| | | limit_up_price = float(gpcode_manager.get_limit_up_price(code)) |
| | | deal_money = limit_up_price * orgin_deal_data[0] |
| | | if deal_money >= 100 * 10000: |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate}" |
| | | else: |
| | | return False, f"已达到撤单比例,未达到撤单金额:{deal_money}" |
| | | else: |
| | | return False, "尚未达到撤单比例" |
| | | |