From 2f2516749615da866e96d8d24e499b7ecbb63a3e Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 23 六月 2025 12:28:52 +0800
Subject: [PATCH] 默认交易模式变更/真实下单位置计算位置修改

---
 huaxin_client/l1_api_client.py |   75 +++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/huaxin_client/l1_api_client.py b/huaxin_client/l1_api_client.py
index c35ac8b..7aab40a 100644
--- a/huaxin_client/l1_api_client.py
+++ b/huaxin_client/l1_api_client.py
@@ -3,6 +3,7 @@
 import threading
 import time
 
+import constant
 import qcvalueaddproapi
 from log_module.log import logger_system, logger_debug
 from utils import tool
@@ -73,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):
@@ -185,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):
         """
@@ -204,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):
         """
@@ -226,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):
@@ -250,7 +262,6 @@
     while True:
         try:
             val = request_queue.get()
-            logger_debug.info(f"璇诲彇鍗庨懌澧炲�兼湇鍔¤姹傦細{val}")
             type_ = val['type']
             request_id = val['request_id']
             data = val.get('data')
@@ -267,7 +278,7 @@
                 code = data['code']
                 results = thespi.queryBars(code, start_date, end_date)
                 __set_response_data(request_id, results)
-        except:
+        except Exception as e:
             pass
 
 
@@ -283,10 +294,10 @@
     g_port = 25556
     g_userid = "388000013942"
     g_passwd = "110808"
-
-    # 鍐呯綉
-    g_address = "192.168.84.61"
-    g_port = 25557
+    if not constant.is_windows():
+        # 鍐呯綉
+        g_address = "192.168.84.61"
+        g_port = 25557
 
     #IP锛�192.168.84.61锛夈�佺鍙o紙25557
 
@@ -306,7 +317,7 @@
 
 
 def main():
-    request_queue, response_queue = multiprocessing.Queue(), multiprocessing.Queue()
+    request_queue, response_queue = multiprocessing.Queue(maxsize=1024), multiprocessing.Queue(maxsize=1024)
     run(request_queue, response_queue)
 
 

--
Gitblit v1.8.0