| | |
| | | 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 |
| | |
| | | |
| | | 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"] |
| | |
| | | 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"] |
| | |
| | | |
| | | 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'))) |