Administrator
2023-09-15 7c91be6468bf70bcb39748eb3120f6738f4532e4
取消交易通道测试日志
3个文件已修改
27 ■■■■ 已修改文件
huaxin_client/command_manager.py 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_api.py 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/command_manager.py
@@ -131,7 +131,6 @@
                    if val:
                        val = json.loads(val)
                        _type = val["type"]
                        logger_local_huaxin_trade_debug.debug(f"获取到策略端信息:{val}")
                        cls.process_command_thread_pool.submit(lambda:  cls.process_command(_type, None, val))
                except Exception as e:
l2/l2_data_manager_new.py
@@ -404,21 +404,7 @@
        __start_time = round(t.time() * 1000)
        # 获取阈值
        threshold_money, msg = cls.__get_threshmoney(code)
        # if round(t.time() * 1000) - __start_time > 10:
        #     __start_time = l2_data_log.l2_time(code, round(t.time() * 1000) - __start_time,
        #                                        "获取m值数据耗时")
        if True:  # end_index - start_index < 10:
            cls.__start_compute_buy(code, start_index, end_index, threshold_money, capture_time, is_first_code)
        else:
            # pass
            lp = LineProfiler()
            lp.enable()
            lp_wrap = lp(cls.__start_compute_buy)
            lp_wrap(code, start_index, end_index, threshold_money, capture_time, is_first_code)
            output = io.StringIO()
            lp.print_stats(stream=output)
            lp.disable()
            logger_profile.info(output.getvalue())
    # 测试专用
    @classmethod
trade/huaxin/huaxin_trade_api.py
@@ -240,10 +240,11 @@
# 网络请求
def __request(_type, data, request_id=None, blocking=False, is_pipe=True):
def __request(_type, data, request_id=None, blocking=False, is_pipe=True, log_enable=True):
    if not request_id:
        request_id = __get_request_id(_type)
    try:
        if log_enable:
        async_log_util.info(hx_logger_trade_loop, "请求发送开始:client_id-{} request_id-{} is_pipe-{}", 0, request_id,
                            is_pipe)
        root_data = {"type": _type,
@@ -255,6 +256,7 @@
            trade_cmd_callback(TradeRequest(_type, root_data, request_id))
        else:
            pipe_trade.send(json.dumps(root_data).encode("utf-8"))
        if log_enable:
        async_log_util.info(hx_logger_trade_loop, "请求发送成功:request_id-{}", request_id)
    except BrokenPipeError as e:
        hx_logger_trade_loop.info("请求发送异常:request_id-{} error-{}", request_id, str(e))
@@ -266,7 +268,7 @@
    return request_id
def __read_response(request_id, blocking, timeout=TIMEOUT):
def __read_response(request_id, blocking, timeout=TIMEOUT, log_enable=True):
    if blocking:
        start_time = time.time()
        try:
@@ -275,9 +277,11 @@
                if request_id in __request_response_dict:
                    # 获取到了响应内容
                    result = __request_response_dict.pop(request_id)
                    if log_enable:
                    hx_logger_trade_loop.info("请求读取成功: request_id-{}", request_id)
                    return result
                if time.time() - start_time > timeout:
                    if log_enable:
                    hx_logger_trade_loop.info("请求读取超时: request_id-{}", request_id)
                    # 读取内容超时才会释放
                    raise Exception(f"读取内容超时: request_id={request_id}")
@@ -419,8 +423,8 @@
# 设置L2订阅数据
def __test_trade_channel(sid):
    request_id = __request("test",
                           {"type": "test", "data": {"sid": sid}}, blocking=True)
    return __read_response(request_id, True)
                           {"type": "test", "data": {"sid": sid}}, blocking=True, log_enable=False)
    return __read_response(request_id, True, log_enable=False)
def parseResponse(data_str):