| | |
| | | base_rate = constant.L_CANCEL_RATE |
| | | if is_up: |
| | | base_rate = constant.L_CANCEL_RATE_UP |
| | | |
| | | try: |
| | | block_rate = 0 |
| | | if code in cls.__block_limit_up_count_dict: |
| | |
| | | block_rate = rates[count] |
| | | |
| | | deal_rate = 0 |
| | | if code in cls.__big_num_deal_rate_dict: |
| | | temp_rate = cls.__big_num_deal_rate_dict[code] |
| | | if temp_rate >= 1: |
| | | if temp_rate > 3: |
| | | temp_rate = 3 |
| | | deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round( |
| | | (temp_rate * 5.25 - 3.75) / 100, 4) |
| | | # if code in cls.__big_num_deal_rate_dict: |
| | | # temp_rate = cls.__big_num_deal_rate_dict[code] |
| | | # if temp_rate >= 1: |
| | | # if temp_rate > 3: |
| | | # temp_rate = 3 |
| | | # deal_rate = round((temp_rate * 3.5 - 2.5) / 100, 4) if is_up else round( |
| | | # (temp_rate * 5.25 - 3.75) / 100, 4) |
| | | |
| | | base_rate += block_rate |
| | | base_rate += deal_rate |
| | |
| | | # 重新计算成交位置临近大单撤单 |
| | | self.__compute_trade_progress_near_by_indexes(code, buy_single_index, index + 1, real_place_order_index) |
| | | |
| | | def add_transaction_datas(self, code, transaction_datas): |
| | | if not transaction_datas: |
| | | return False, "成交数据为空" |
| | | buyno_map = local_today_buyno_map.get(code) |
| | | if not buyno_map: |
| | | return False, "没找到买单字典" |
| | | 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] |
| | | |
| | | 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撤未成交统计为空" |
| | | orgin_deal_data = self.__l_down_latest_deal_info_dict.get(code) |
| | | if orgin_deal_data is None: |
| | | return False, "L后暂时无成交" |
| | | |
| | | real_place_order_index_info = self.__real_place_order_index_dict.get(code) |
| | | if real_place_order_index_info and real_place_order_index_info[1]: |
| | | return False, "没获取到真实的下单位" |
| | | |
| | | threshold_rate = LCancelRateManager.get_fast_deal_cancel_rate(code) |
| | | rate = orgin_deal_data[0] / (total_l_down_not_deal_num[0] * 100) |
| | | if 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 >= constant.L_CANCEL_FAST_DEAL_MIN_MONEY: |
| | | return True, f"达到撤单比例:{rate}/{threshold_rate} 成交详情:{orgin_deal_data}/{total_l_down_not_deal_num}" |
| | | else: |
| | | return False, f"已达到撤单比例,未达到撤单金额:{deal_money}" |
| | | else: |
| | | return False, "尚未达到撤单比例" |
| | | |
| | | # 已经成交的索引 |
| | | def add_deal_index(self, code, index, buy_single_index): |
| | | """ |
| | | L后囊括范围成交一笔重新囊括1笔 |
| | | @param code: |
| | | @param index: |
| | | @param buy_single_index: |
| | | @return: |
| | | """ |
| | | watch_indexes_info = self.__get_watch_indexes_cache(code) |
| | | if not watch_indexes_info: |
| | | return |