From 48fb7a00951f91bdc707e5dd2d196e5bccb752c3 Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 18 六月 2025 18:41:30 +0800
Subject: [PATCH] 异常保护

---
 huaxin_client/l1_api_client.py |   63 ++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/huaxin_client/l1_api_client.py b/huaxin_client/l1_api_client.py
index 683fa13..7aab40a 100644
--- a/huaxin_client/l1_api_client.py
+++ b/huaxin_client/l1_api_client.py
@@ -5,7 +5,7 @@
 
 import constant
 import qcvalueaddproapi
-from log_module.log import logger_system
+from log_module.log import logger_system, logger_debug
 from utils import tool
 
 global g_userid, g_passwd, g_address, g_port, g_seqnum
@@ -74,7 +74,7 @@
                 page_locate += 1
             print("queryTradeCalendar:", len(fresults))
         except Exception as e:
-            logging.exception(e)
+            logger_debug.exception(e)
         return fresults
 
     def __query_bars(self, code, begin_date, end_date, page_locate=1, page_count=200):
@@ -186,12 +186,18 @@
             #     target=lambda: print("鏃锛�", self.queryBars("601298", "2024-12-15", "2024-12-31"))).start()
 
     def ReqQryGGTEODPrices(self):
-        QryField = qcvalueaddproapi.CQCVDQryGGTEODPricesField()
-        self.m_api.ReqQryGGTEODPrices(QryField, new_seqnum())
+        try:
+            QryField = qcvalueaddproapi.CQCVDQryGGTEODPricesField()
+            self.m_api.ReqQryGGTEODPrices(QryField, new_seqnum())
+        except:
+            pass
 
     def ReqQryInvestor(self):
-        QryField = qcvalueaddproapi.CQCVDQryInvestorField()
-        self.m_api.ReqQryInvestor(QryField, new_seqnum())
+        try:
+            QryField = qcvalueaddproapi.CQCVDQryInvestorField()
+            self.m_api.ReqQryInvestor(QryField, new_seqnum())
+        except:
+            pass
 
     def OnRspInquiryShareCalendar(self, pShareCalendar, pRspInfo, nRequestID, bIsPageLast, bIsTotalLast):
         """
@@ -205,13 +211,15 @@
         """
         if nRequestID not in self.__temp_cache:
             self.__temp_cache[nRequestID] = []
-
-        if pShareCalendar:
-            self.__temp_cache[nRequestID].append(pShareCalendar.TradingDay)
-        else:
-            self.__result_cache[nRequestID] = self.__temp_cache[nRequestID]
-            self.__temp_cache.pop(nRequestID)
-            print("OnRspInquiryShareCalendar:", self.__result_cache[nRequestID])
+        try:
+            if pShareCalendar:
+                self.__temp_cache[nRequestID].append(pShareCalendar.TradingDay)
+            else:
+                self.__result_cache[nRequestID] = self.__temp_cache[nRequestID]
+                self.__temp_cache.pop(nRequestID)
+                print("OnRspInquiryShareCalendar:", self.__result_cache[nRequestID])
+        except:
+            pass
 
     def OnRspInquiryStockDayQuotation(self, pStockDayQuotation, pRspInfo, nRequestID, bIsPageLast, bIsTotalLast):
         """
@@ -227,20 +235,23 @@
             self.__temp_cache[nRequestID] = []
 
         # print("鏄惁鏈〉鏌ヨ瀹屾瘯锛�", bIsPageLast)
+        try:
 
-        if not bIsPageLast:
-            self.__temp_cache[nRequestID].append({
-                "SecurityID": pStockDayQuotation.SecurityID, "TradingDay": pStockDayQuotation.TradingDay,
-                "AdjustFactor": pStockDayQuotation.AdjustFactor, "PreClosePrice": pStockDayQuotation.PreClosePrice,
-                "OpenPrice": pStockDayQuotation.OpenPrice, "HighPrice": pStockDayQuotation.HighPrice,
-                "LowPrice": pStockDayQuotation.LowPrice,
-                "ClosePrice": pStockDayQuotation.ClosePrice, "Volume": int(pStockDayQuotation.Volume * 100),
-                "Turnover": int(pStockDayQuotation.Turnover * 1000)
-            })
-        else:
-            self.__result_cache[nRequestID] = self.__temp_cache[nRequestID]
-            self.__temp_cache.pop(nRequestID)
-            print("OnRspInquiryStockDayQuotation:", len(self.__result_cache[nRequestID]))
+            if not bIsPageLast:
+                self.__temp_cache[nRequestID].append({
+                    "SecurityID": pStockDayQuotation.SecurityID, "TradingDay": pStockDayQuotation.TradingDay,
+                    "AdjustFactor": pStockDayQuotation.AdjustFactor, "PreClosePrice": pStockDayQuotation.PreClosePrice,
+                    "OpenPrice": pStockDayQuotation.OpenPrice, "HighPrice": pStockDayQuotation.HighPrice,
+                    "LowPrice": pStockDayQuotation.LowPrice,
+                    "ClosePrice": pStockDayQuotation.ClosePrice, "Volume": int(pStockDayQuotation.Volume * 100),
+                    "Turnover": int(pStockDayQuotation.Turnover * 1000)
+                })
+            else:
+                self.__result_cache[nRequestID] = self.__temp_cache[nRequestID]
+                self.__temp_cache.pop(nRequestID)
+                print("OnRspInquiryStockDayQuotation:", len(self.__result_cache[nRequestID]))
+        except:
+            pass
 
 
 def __read_request(request_queue: multiprocessing.Queue, response_queue: multiprocessing.Queue):

--
Gitblit v1.8.0