Administrator
2023-09-01 be7fd23591e03d024baff417e7697085c9527bb4
huaxin_client/trade_client.py
@@ -550,7 +550,8 @@
        try:
            if pInputOrderActionField and pRspInfoField:
                logger_local_huaxin_trade_debug.info('OnErrRtnOrderAction: Error! [%d] [%d] [%d] [%s]'
                                                     % (nRequestID, pInputOrderActionField.OrderSysID, pRspInfoField.ErrorID,
                                                     % (nRequestID, pInputOrderActionField.OrderSysID,
                                                        pRspInfoField.ErrorID,
                                                        pRspInfoField.ErrorMsg))
        except:
            pass
@@ -1003,7 +1004,9 @@
            #     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})
            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回调结束")
@@ -1035,6 +1038,21 @@
    tradeCommandManager.process_command(tradeRequest.type_, None, tradeRequest.data)
def __test():
    # 测试撤单
    for i in range(0, 10):
        code = "600190"
        orderSysID = "0190000229"
        sinfo = f"test_cancel_{i}"
        data = {"type": "trade", "trade_type": 2,
                "direction": 0,
                "code": code,
                "localOrderID": "",
                "orderSysID": orderSysID, "sinfo": sinfo}
        process_cmd(TradeRequest("trade", {"type": "trade", "data": data, "request_id": f"test-{i}"}, f"test-{i}"))
        time.sleep(2)
def run(trade_response_: TradeResponse, pipe_l2=None, pipe_strategy=None):
    try:
        logger_system.info("交易进程ID:{}", os.getpid())
@@ -1051,6 +1069,9 @@
        t1 = threading.Thread(target=lambda: trade_client_server.run(), daemon=True)
        t1.start()
        t1 = threading.Thread(target=lambda: __test(), daemon=True)
        t1.start()
        global tradeCommandManager
        tradeCommandManager = command_manager.TradeCommandManager()
        tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy)