| | |
| | | from huaxin_client.log import logger |
| | | |
| | | # 正式账号 |
| | | from huaxin_client.trade_transform_protocol import TradeRequest, TradeResponse |
| | | from log_module.log import logger_local_huaxin_trade_debug, logger_system |
| | | |
| | | UserID = '388000013349' |
| | |
| | | |
| | | logger_local_huaxin_trade_debug.info("API回调 request_id-{}", request_id) |
| | | # 测试 |
| | | send_response( |
| | | json.dumps({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id, |
| | | "request_id": request_id}), type, client_id, request_id, temp_params[2]) |
| | | # send_response( |
| | | # json.dumps({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id, |
| | | # "request_id": request_id}), type, client_id, request_id, temp_params[2]) |
| | | |
| | | trade_response.OnTradeResponse({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id, "request_id": request_id}) |
| | | |
| | | logger_local_huaxin_trade_debug.info("API回调结束 req_id-{} request_id-{}", req_id, request_id) |
| | | print("API回调结束") |
| | | else: |
| | | logger_local_huaxin_trade_debug.info("非API回调 req_id-{}", req_id) |
| | | print("非API回调") |
| | | # 非API回调 |
| | | send_response( |
| | | json.dumps({"type": "trade_callback", "data": {"code": 0, "data": data, "type": type}}), |
| | | type, |
| | | None, |
| | | req_id) |
| | | trade_response.OnTradeCallback({"type": "trade_callback", "data": {"code": 0, "data": data, "type": type}}) |
| | | # # 非API回调 |
| | | # send_response( |
| | | # json.dumps({"type": "trade_callback", "data": {"code": 0, "data": data, "type": type}}), |
| | | # type, |
| | | # None, |
| | | # req_id) |
| | | print("非API结束") |
| | | except Exception as e: |
| | | logging.exception(e) |
| | |
| | | addr, port = constant.SERVER_IP, constant.SERVER_PORT |
| | | |
| | | |
| | | def run(pipe_l2=None, pipe_strategy=None): |
| | | def process_cmd(tradeRequest: TradeRequest): |
| | | tradeCommandManager.process_command(tradeRequest.type_, None, tradeRequest.data) |
| | | |
| | | |
| | | def run(trade_response_: TradeResponse, pipe_l2=None, pipe_strategy=None): |
| | | logger_system.info("交易进程ID:{}", os.getpid()) |
| | | __init_trade_data_server() |
| | | global l2pipe |
| | |
| | | global strategy_pipe |
| | | strategy_pipe = pipe_strategy |
| | | |
| | | global trade_response |
| | | trade_response = trade_response_ |
| | | |
| | | t1 = threading.Thread(target=lambda: trade_client_server.run(), daemon=True) |
| | | t1.start() |
| | | |
| | |
| | | tradeCommandManager = command_manager.TradeCommandManager() |
| | | tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy) |
| | | logger_system.info("华鑫交易服务启动") |
| | | tradeCommandManager.run() |
| | | # 不需要运行命令解析 |
| | | # tradeCommandManager.run() |
| | | while True: |
| | | time.sleep(2) |
| | | |