Administrator
2025-03-20 e8ac46f7789fef8fa9a7528734c7acff7b6ef2d6
真实下单位矫正时采用严格匹配机制
1个文件已修改
17 ■■■■ 已修改文件
l2/huaxin/huaxin_delegate_postion_manager.py 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/huaxin/huaxin_delegate_postion_manager.py
@@ -128,7 +128,7 @@
        return None
    @classmethod
    def __compute_real_place_order_position(cls, code, exec_data, oredr_info_list, add_datas):
    def __compute_real_place_order_position(cls, code, exec_data, oredr_info_list, add_datas, strict_match):
        THRESHOLD_MS = 20 if tool.is_sz_code(code) else 100
        exec_time_with_ms = L2DataUtil.get_time_with_ms(exec_data["val"])
        # 获取下单的量
@@ -213,10 +213,17 @@
            max_sub_index = max(sub_index_list)
            if max_sub_time > THRESHOLD_MS:
                continue
            if strict_match:
                # 严格匹配,序号相差1,时间一致
                if max_sub_index > 1 or max_sub_time > 0:
                    continue
            # 最大的时间差,最大的索引差, 数据
            # 深证与执行位置相差时间>=10ms以上,上证与执行位置相差时间>=100ms以上
            data_ = temp_volumes_info_list[0][2]
            MIN_SPCE_MS = 30 if tool.is_sh_code(code) else 10
            if tool.trade_time_sub_with_ms(L2DataUtil.get_time_with_ms(data_["val"]), exec_time_with_ms) < MIN_SPCE_MS:
                continue
            match_list.append((max_sub_time, max_sub_index, data_))
@@ -248,11 +255,12 @@
        return real_place_order_info[2]
    @classmethod
    def compute_l2_place_order_position(cls, code, add_datas):
    def compute_l2_place_order_position(cls, code, add_datas, strict_match=False):
        """
        计算真实下单位置
        @param code: 代码
        @param add_datas: 本批次数据
        @param strict_match: 严格匹配
        @return:
        """
        order_info = cls.get_order_info(code)
@@ -263,7 +271,8 @@
        exec_data = order_info[1]
        order_time = order_info[2]
        estimate_time_space = 1 if tool.is_sz_code(code) else 2.5
        place_order_data = cls.__compute_real_place_order_position(code, exec_data, order_info_list, add_datas)
        place_order_data = cls.__compute_real_place_order_position(code, exec_data, order_info_list, add_datas,
                                                                   strict_match)
        real_place_index_info = None
        if place_order_data:
            real_place_index_info = place_order_data["index"], RELIABILITY_TYPE_REAL
@@ -323,7 +332,7 @@
        order_info_list = order_info[0]  # [(量,价格, order_ref)]
        exec_data = order_info[1]
        place_order_data = cls.__compute_real_place_order_position(code, exec_data, order_info_list,
                                                                   total_datas[trade_index + 1:end_index])
                                                                   total_datas[trade_index + 1:end_index], strict_match= True)
        if not place_order_data:
            return None
        real_place_index_info = place_order_data["index"], RELIABILITY_TYPE_REAL