| | |
| | | import threading |
| | | import time |
| | | |
| | | from huaxin_client import trade_client_server |
| | | from huaxin_client.trade_transform_protocol import TradeRequest |
| | | from log_module import async_log_util |
| | | from log_module.log import hx_logger_trade_debug, hx_logger_trade_loop, hx_logger_trade_callback, logger_trade |
| | |
| | | try: |
| | | val = pipe_trade.recv() |
| | | if val: |
| | | print("收到来自交易服务器的数据:", val) |
| | | data_json = json.loads(val) |
| | | print("收到来自交易客户端的数据:", data_json["type"]) |
| | | # 处理数据 |
| | | type_ = data_json["type"] |
| | | if type_ == "response": |
| | |
| | | timestamp = round(time.time() * 1000) |
| | | if not sinfo: |
| | | sinfo = f"b_{code}_{timestamp}" |
| | | print("客户端", ClientSocketManager.socket_client_dict) |
| | | local_order_id = f"l_{code}_{direction}_{volume}_{timestamp}_{random.randint(0, 999)}" |
| | | request_id = __request(ClientSocketManager.CLIENT_TYPE_TRADE, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_TRADE, "trade_type": 1, |