From be7fd23591e03d024baff417e7697085c9527bb4 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 01 九月 2023 14:48:44 +0800
Subject: [PATCH] 添加测试

---
 huaxin_client/trade_client.py |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/huaxin_client/trade_client.py b/huaxin_client/trade_client.py
index 77f35a9..645581f 100644
--- a/huaxin_client/trade_client.py
+++ b/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)

--
Gitblit v1.8.0