Administrator
4 天以前 48fb7a00951f91bdc707e5dd2d196e5bccb752c3
huaxin_client/l1_api_client.py
@@ -3,8 +3,9 @@
import threading
import time
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
@@ -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("日K:", 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):
@@ -266,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
@@ -282,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)、端口(25557
@@ -305,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)