Administrator
2023-09-04 49ab15aca3aafe252ab47c4d2af31bcafc702ba0
交易接口日志异步
2个文件已修改
10 ■■■■■ 已修改文件
huaxin_client/command_manager.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/trade_client.py 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/command_manager.py
@@ -72,7 +72,7 @@
        return cls._instance
    @classmethod
    def init(cls, trade_action_callback, pipe_l2, pipe_strategy):
    def init(cls, trade_action_callback: TradeActionCallback, pipe_l2, pipe_strategy):
        cls.action_callback = trade_action_callback
        cls.pipe_strategy = pipe_strategy
        cls.pipe_l2 = pipe_l2
huaxin_client/trade_client.py
@@ -805,8 +805,7 @@
    def OnTrade(self, client_id, request_id, sk, type_, data):
        if type_ == 1:
            logger_local_huaxin_trade_debug.info(
                f"---------------------\n请求下单:client_id-{client_id} request_id-{request_id}")
            async_log_util.info(logger_local_huaxin_trade_debug,f"\n---------------------\n请求下单:client_id-{client_id} request_id-{request_id}")
            # 下单
            # 1-买 2-卖
            direction = data["direction"]
@@ -836,8 +835,7 @@
                                  request_id)
        elif type_ == 2:
            logger_local_huaxin_trade_debug.info(
                f"---------------------\n请求撤单:client_id-{client_id} request_id-{request_id} data-{data}")
            async_log_util.info(logger_local_huaxin_trade_debug, f"\n---------------------\n请求撤单:client_id-{client_id} request_id-{request_id} data-{data}")
            # 撤单
            direction = data["direction"]
            code = data["code"]
@@ -979,7 +977,7 @@
def send_response(data, type, _client_id, _request_id, show_log=True, sk=None):
    if show_log:
        logger_local_huaxin_trade_debug.debug(f"回调返回内容:{data}")
        async_log_util.debug(logger_local_huaxin_trade_debug, f"回调返回内容:{data}")
    if sk:
        # 采用的是socket通信
        sk.sendall(socket_util.load_header(data.encode('utf-8')))