From 09ca670240a660b81d8dbed4c54efec96e99e811 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 12 九月 2023 11:14:41 +0800
Subject: [PATCH] 下单日志优化

---
 huaxin_client/trade_client.py |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/huaxin_client/trade_client.py b/huaxin_client/trade_client.py
index 87bfb4b..f9241d9 100644
--- a/huaxin_client/trade_client.py
+++ b/huaxin_client/trade_client.py
@@ -15,7 +15,7 @@
 # 姝e紡璐﹀彿
 from huaxin_client.trade_transform_protocol import TradeRequest, TradeResponse
 from log_module import async_log_util
-from log_module.log import logger_local_huaxin_trade_debug, logger_system
+from log_module.log import logger_local_huaxin_trade_debug, logger_system, logger_trade
 
 UserID = '388000013349'
 # 鐧婚檰瀵嗙爜
@@ -89,6 +89,7 @@
             return
         if sinfo in self.__buy_sinfo_set:
             raise Exception(f'涓嬪崟璇锋眰宸茬粡鎻愪氦锛歿sinfo}')
+        async_log_util.info(logger_trade, f"{code}鍗庨懌鏈湴鐪熷疄涓嬪崟寮�濮�")
         async_log_util.info(logger_local_huaxin_trade_debug,
                             f"杩涘叆涔板叆鏂规硶锛歝ode-{code} sinfo-{sinfo}")
         self.__buy_sinfo_set.add(sinfo)
@@ -148,6 +149,7 @@
         # 缁橪2鍙戦�佹秷鎭�
         if l2pipe is not None:
             l2pipe.send(json.dumps({"type": "listen_volume", "data": {"code": code, "volume": count}}).encode('utf-8'))
+        async_log_util.info(logger_trade, f"{code}鍗庨懌鏈湴鐪熷疄涓嬪崟缁撴潫")
         return
 
     # 鎾や拱
@@ -711,7 +713,6 @@
     def OnRspQryOrder(self, pOrderField: "CTORATstpOrderField", pRspInfoField: "CTORATstpRspInfoField",
                       nRequestID: "int", bIsLast: "bool") -> "void":
         try:
-            print('鏌ヨ鎶ュ崟鍥炶皟', bIsLast)
             if nRequestID not in self.__temp_order_list_dict:
                 self.__temp_order_list_dict[nRequestID] = []
             if not bIsLast:
@@ -820,12 +821,15 @@
             price = data["price"]
             sinfo = data["sinfo"]
             local_order_id = data.get("local_order_id")
+
             if direction == 1:
+                async_log_util.info(logger_trade, f"{code}鍗庨懌鏈湴寮�濮嬩笅鍗�")
                 # 涔�
                 try:
                     req_rid_dict[sinfo] = (client_id, request_id, sk, local_order_id)
                     threading.Thread(target=lambda: self.__tradeSimpleApi.buy(code, volume, price, sinfo),
                                      daemon=True).start()
+                    async_log_util.info(logger_trade, f"{code}鍗庨懌鏈湴涓嬪崟绾跨▼缁撴潫")
                 except Exception as e:
                     send_response(json.dumps({"code": 1, "msg": str(e)}), TYPE_ORDER, client_id,
                                   request_id)
@@ -880,7 +884,7 @@
     def OnDealList(self, client_id, request_id, sk):
         async_log_util.info(logger_local_huaxin_trade_debug, f"璇锋眰鎴愪氦鍒楄〃锛歝lient_id-{client_id} request_id-{request_id}")
         try:
-            print("寮�濮嬭姹傛垚浜ゅ垪琛�")
+            # print("寮�濮嬭姹傛垚浜ゅ垪琛�")
             req_id = self.__tradeSimpleApi.list_traded_orders()
             req_rid_dict[req_id] = (client_id, request_id, sk)
         except Exception as e:
@@ -1047,9 +1051,7 @@
     if type == TYPE_ORDER or type == TYPE_CANCEL_ORDER:
         key = data["sinfo"]
     try:
-        print("traderapi_callback", req_rid_dict)
         if req_rid_dict and key in req_rid_dict:
-            print("API鍥炶皟")
             temp_params = req_rid_dict.pop(key)
             client_id, request_id = temp_params[0], temp_params[1]
             # 鏈湴璁㈠崟鍙�-绯荤粺璁㈠崟鍙锋槧灏�
@@ -1068,10 +1070,8 @@
                  "request_id": request_id})
 
             async_log_util.info(logger_local_huaxin_trade_debug, "API鍥炶皟缁撴潫 req_id-{} request_id-{}", req_id, request_id)
-            print("API鍥炶皟缁撴潫")
         else:
             async_log_util.info(logger_local_huaxin_trade_debug, "闈濧PI鍥炶皟 req_id-{}", req_id)
-            print("闈濧PI鍥炶皟")
             trade_response.OnTradeCallback({"type": "trade_callback", "data": {"code": 0, "data": data, "type": type}})
             # # 闈濧PI鍥炶皟
             # send_response(
@@ -1079,7 +1079,6 @@
             #     type,
             #     None,
             #     req_id)
-            print("闈濧PI缁撴潫")
     except Exception as e:
         logging.exception(e)
 

--
Gitblit v1.8.0