Administrator
2024-01-22 b87569e2be1361938cda9356f1b4d2d9fb909ed1
L后快速成交修改
3个文件已修改
46 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_transaction_data_manager.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -1232,7 +1232,8 @@
    # 计算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][
            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
@@ -1261,13 +1262,6 @@
                                                                                                             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)
@@ -1302,25 +1296,27 @@
        #     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]
        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:
            return False, "非L撤监听数据成交"
                continue
        # 统计数据
        orgin_deal_data = self.__l_down_latest_deal_info_dict.get(code)
        if not orgin_deal_data:
@@ -1332,16 +1328,24 @@
        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:
            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, "尚未达到撤单比例"
    # 已经成交的索引
l2/l2_data_manager_new.py
@@ -1023,7 +1023,7 @@
        # 是否是最优自由流通市值
        is_better_zylt = True if zylt_threshold_as_yi[2] <= zyltgb_as_yi <= zylt_threshold_as_yi[3] else False
        if is_in_strong_time_30 and is_best_zylt and can_buy_result[0]:
        if is_in_strong_time_30 and is_best_zylt:
            # 强势30分钟,最优市值, 有可以下单的板块,不看量
            return True, False, can_buy_result[2]
l2/l2_transaction_data_manager.py
@@ -127,11 +127,9 @@
                except Exception as e:
                    async_log_util.error(hx_logger_l2_debug, str(e))
                try:
                    for d in datas:
                        if LCancelBigNumComputer().add_transaction_data(d)[0]:
                            L2TradeDataProcessor.cancel_buy(code, f"L后成交太快撤单:{d}")
                    if LCancelBigNumComputer().add_transaction_datas(code, datas)[0]:
                        L2TradeDataProcessor.cancel_buy(code, f"L后成交太快撤单:{datas[-1]}")
                            order_begin_pos = None
                            break
                except Exception as e:
                    async_log_util.error(hx_logger_l2_debug, str(e))