diff --git a/.gitignore b/.gitignore index 549c1cb..1be6991 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ __pycache__/ *.py[cod] *$py.class +*.cpp +*.con +ctpwrapper/*.so # Distribution / packaging diff --git a/.travis.yml b/.travis.yml index cded803..e4b04b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python matrix: include: # others still work and don't install python3.7 - - python: pypy3 + - python: pypy3.6-7.3.1 sudo: required - python: 3.5 sudo: required diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e8703cd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM python:3.8 +RUN pip3 install cython pip setuptools --upgrade +WORKDIR /code diff --git a/README.md b/README.md index 867f769..9983ffb 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ [![implementation](https://img.shields.io/pypi/implementation/ctpwrapper.svg)](https://pypi.python.org/pypi/ctpwrapper) [![Downloads](https://pepy.tech/badge/ctpwrapper)](https://pepy.tech/project/ctpwrapper) -[CTP Website](http://www.sfit.com.cn/5_2_DocumentDown.htm) +[CTP Website](http://www.sfit.com.cn/5_2_DocumentDown_1.htm) -Version: v6.3.19 P1 +Version: v6.3.19 P1(v6.3.19_P1_20200106) Platform: Linux 64bit, Windows 64bit @@ -34,196 +34,16 @@ already install cython package. +## ⚠️⚠️ notice ⚠️⚠️ + sometimes quote the market futures data, but there is no trading data from the API stream, + better just add `time.sleep(2)` func call after `Init()` method invoked, this could help to solve no data response issue. + +## Demo +sample code [samples](samples/) -# Usage - - MdApi Class Wrapper - -```python -import sys - -from ctpwrapper import ApiStructure -from ctpwrapper import MdApiPy - - -class Md(MdApiPy): - """ - """ - - def __init__(self, broker_id, investor_id, password, request_id=1): - - self.broker_id = broker_id - self.investor_id = investor_id - self.password = password - self.request_id = request_id - - def OnRspError(self, pRspInfo, nRequestID, bIsLast): - - self.ErrorRspInfo(pRspInfo, nRequestID) - - def ErrorRspInfo(self, info, request_id): - """ - :param info: - :return: - """ - if info.ErrorID != 0: - print('request_id=%s ErrorID=%d, ErrorMsg=%s', - request_id, info.ErrorID, info.ErrorMsg.decode('gbk')) - return info.ErrorID != 0 - - def OnFrontConnected(self): - """ - :return: - """ - - user_login = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, - UserID=self.investor_id, - Password=self.password) - self.ReqUserLogin(user_login, self.request_id) - - def OnFrontDisconnected(self, nReason): - - print("Md OnFrontDisconnected %s", nReason) - sys.exit() - - def OnHeartBeatWarning(self, nTimeLapse): - """心跳超时警告。当长时间未收到报文时,该方法被调用。 - @param nTimeLapse 距离上次接收报文的时间 - """ - print('Md OnHeartBeatWarning, time = %s', nTimeLapse) - - def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): - """ - 用户登录应答 - :param pRspUserLogin: - :param pRspInfo: - :param nRequestID: - :param bIsLast: - :return: - """ - if pRspInfo.ErrorID != 0: - print("Md OnRspUserLogin failed error_id=%s msg:%s", - pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')) - else: - print("Md user login successfully") - print(pRspUserLogin) - print(pRspInfo) - - -BORDKER_ID = "" -INVESTOR_ID = "" -PASSWORD = "" -SERVER = "" - -md = Md(BORDKER_ID, INVESTOR_ID, PASSWORD) -md.Create() -md.RegisterFront(SERVER) -md.Init() -day = md.GetTradingDay() - -print(day) -print("api worker!") -``` - -Trader Class Wrapper - -```python - -from ctpwrapper import ApiStructure -from ctpwrapper import TraderApiPy - -class Trader(TraderApiPy): - - def __init__(self, broker_id, investor_id, password, request_id=1): - self.request_id = request_id - self.broker_id = broker_id.encode() - self.investor_id = investor_id.encode() - self.password = password.encode() - - def OnRspError(self, pRspInfo, nRequestID, bIsLast): - - self.ErrorRspInfo(pRspInfo, nRequestID) - - def ErrorRspInfo(self, info, request_id): - """ - :param info: - :return: - """ - if info.ErrorID != 0: - print('request_id=%s ErrorID=%d, ErrorMsg=%s', - request_id, info.ErrorID, info.ErrorMsg.decode('gbk')) - return info.ErrorID != 0 - - def OnHeartBeatWarning(self, nTimeLapse): - """心跳超时警告。当长时间未收到报文时,该方法被调用。 - @param nTimeLapse 距离上次接收报文的时间 - """ - print("on OnHeartBeatWarning time: ", nTimeLapse) - - def OnFrontDisconnected(self, nReason): - print("on FrontDisConnected disconnected", nReason) - - def OnFrontConnected(self): - - req = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, - UserID=self.investor_id, - Password=self.password) - self.ReqUserLogin(req, self.request_id) - print("trader on front connection") - - def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): - - if pRspInfo.ErrorID != 0: - print("Md OnRspUserLogin failed error_id=%s msg:%s", - pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')) - else: - print("Md user login successfully") - - inv = ApiStructure.QryInvestorField(BrokerID=self.broker_id, InvestorID=self.investor_id) - - self.ReqQryInvestor(inv, self.inc_request_id()) - req = ApiStructure.SettlementInfoConfirmField.from_dict({"BrokerID": self.broker_id, - "InvestorID": self.investor_id}) - - self.ReqSettlementInfoConfirm(req, self.inc_request_id()) - - def OnRspSettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast): - print(pSettlementInfoConfirm, pRspInfo) - print(pRspInfo.ErrorMsg.decode("GBK")) - - def inc_request_id(self): - self.request_id += 1 - return self.request_id - - def OnRspQryInvestor(self, pInvestor, pRspInfo, nRequestID, bIsLast): - print(pInvestor, pRspInfo) - -if __name__ == "__main__": - investor_id = "" - broker_id = "" - password = "" - server = "" - - user_trader = Trader(broker_id=broker_id, investor_id=investor_id, password=password) - - user_trader.Create() - user_trader.RegisterFront(server) - user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 - user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 - - user_trader.Init() - - print("trader started") - print(user_trader.GetTradingDay()) - - user_trader.Join() - -``` # Documentation - CTP's documentation can be found in the [docs](doc/ctp/) - - + CTP documentation can be found in the [docs](doc/ctp/) # Contact diff --git a/ctpwrapper/ApiStructure.py b/ctpwrapper/ApiStructure.py index 5ce2412..a1724a6 100644 --- a/ctpwrapper/ApiStructure.py +++ b/ctpwrapper/ApiStructure.py @@ -162,11 +162,11 @@ class AuthenticationInfoField(Base): ('IsResult', ctypes.c_int), # 是否为认证结果 ('AppID', ctypes.c_char * 33), # App代码 ('AppType', ctypes.c_char), # App类型 - ('ClientIPAddress', ctypes.c_char * 16) # 终端IP地址 + ('ClientIPAddress', ctypes.c_char * 16), # 终端IP地址 ] - def __init__(self, BrokerID='', UserID='', UserProductInfo='', AuthInfo='', - IsResult=0, AppID='', AppType='', ClientIPAddress=''): + def __init__(self, BrokerID='', UserID='', UserProductInfo='', AuthInfo='', IsResult=0, AppID='', AppType='', + ClientIPAddress=''): super(AuthenticationInfoField, self).__init__() self.BrokerID = self._to_bytes(BrokerID) self.UserID = self._to_bytes(UserID) @@ -911,7 +911,7 @@ class InvestorPositionField(Base): ('InvestUnitID', ctypes.c_char * 17), # 投资单元代码 ('PositionCostOffset', ctypes.c_double), # 大商所持仓成本差值,只有大商所使用 ('TasPosition', ctypes.c_int), # tas持仓手数 - ("TasPositionCost", ctypes.c_double) # tas持仓成本 + ('TasPositionCost', ctypes.c_double), # tas持仓成本 ] def __init__(self, InstrumentID='', BrokerID='', InvestorID='', PosiDirection='', HedgeFlag='', PositionDate='', @@ -990,7 +990,6 @@ class InstrumentMarginRateField(Base): ('IsRelative', ctypes.c_int), # 是否相对交易所收取 ('ExchangeID', ctypes.c_char * 9), # 交易所代码 ('InvestUnitID', ctypes.c_char * 17), # 投资单元代码 - ] def __init__(self, InstrumentID='', InvestorRange='', BrokerID='', InvestorID='', HedgeFlag='', @@ -2629,8 +2628,7 @@ class SyncingInvestorPositionField(Base): ('InvestUnitID', ctypes.c_char * 17), # 投资单元代码 ('PositionCostOffset', ctypes.c_double), # 大商所持仓成本差值,只有大商所使用 ('TasPosition', ctypes.c_int), # tas持仓手数 - ("TasPositionCost", ctypes.c_double) # tas持仓成本 - + ('TasPositionCost', ctypes.c_double), # tas持仓成本 ] def __init__(self, InstrumentID='', BrokerID='', InvestorID='', PosiDirection='', HedgeFlag='', PositionDate='', @@ -2852,11 +2850,11 @@ class QryTradingAccountField(Base): ('BrokerID', ctypes.c_char * 11), # 经纪公司代码 ('InvestorID', ctypes.c_char * 13), # 投资者代码 ('CurrencyID', ctypes.c_char * 4), # 币种代码 - ('BizType', ctypes.c_char), # 业务类型 + ('BizType', ctypes.c_char), # 业务类型 1 期货 2 证券 ('AccountID', ctypes.c_char * 13), # 投资者帐号 ] - def __init__(self, BrokerID='', InvestorID='', CurrencyID='', BizType='', AccountID=''): + def __init__(self, BrokerID='', InvestorID='', CurrencyID='', BizType='1', AccountID=''): super(QryTradingAccountField, self).__init__() self.BrokerID = self._to_bytes(BrokerID) self.InvestorID = self._to_bytes(InvestorID) @@ -6495,7 +6493,7 @@ class InvestorPositionDetailField(Base): ('CloseAmount', ctypes.c_double), # 平仓金额 ('TimeFirstVolume', ctypes.c_int), # 先开先平剩余数量(DCE) ('InvestUnitID', ctypes.c_char * 17), # 投资单元代码 - ('SpecPosiType', ctypes.c_char) # 特殊持仓标志 + ('SpecPosiType', ctypes.c_char), # 特殊持仓标志 ] def __init__(self, InstrumentID='', BrokerID='', InvestorID='', HedgeFlag='', Direction='', OpenDate='', TradeID='', @@ -8293,19 +8291,17 @@ def __init__(self, ExchangeID='', BulletinID=0, SequenceNo=0, NewsType='', NewsU class MulticastInstrumentField(Base): - """ - """ + """MulticastInstrument""" _fields_ = [ - ("TopicID", ctypes.c_int), # 主题号 - ("InstrumentID", ctypes.c_char * 31), # 合约代码 - ("InstrumentNo", ctypes.c_int), # 合约编号 - ("CodePrice", ctypes.c_double), # 基准价 - ("VolumeMultiple", ctypes.c_int), # 合约数量乘数 - ("PriceTick", ctypes.c_double), # 最小变动价位 + ('TopicID', ctypes.c_int), # 主题号 + ('InstrumentID', ctypes.c_char * 31), # 合约代码 + ('InstrumentNo', ctypes.c_int), # 合约编号 + ('CodePrice', ctypes.c_double), # 基准价 + ('VolumeMultiple', ctypes.c_int), # 合约数量乘数 + ('PriceTick', ctypes.c_double), # 最小变动价位 ] - def __init__(self, TopicID=0, InstrumentID='', InstrumentNo=0, - CodePrice=0.0, VolumeMultiple=0, PriceTick=0.0): + def __init__(self, TopicID=0, InstrumentID='', InstrumentNo=0, CodePrice=0.0, VolumeMultiple=0, PriceTick=0.0): super(MulticastInstrumentField, self).__init__() self.TopicID = int(TopicID) self.InstrumentID = self._to_bytes(InstrumentID) @@ -8316,11 +8312,10 @@ def __init__(self, TopicID=0, InstrumentID='', InstrumentNo=0, class QryMulticastInstrumentField(Base): - """ - """ + """QryMulticastInstrument""" _fields_ = [ - ("TopicID", ctypes.c_int), # 主题号 - ("InstrumentID", ctypes.c_char * 31), # 合约代码 + ('TopicID', ctypes.c_int), # 主题号 + ('InstrumentID', ctypes.c_char * 31), # 合约代码 ] def __init__(self, TopicID=0, InstrumentID=''): @@ -8330,13 +8325,11 @@ def __init__(self, TopicID=0, InstrumentID=''): class AppIDAuthAssignField(Base): - """ - App客户端权限分配 - """ + """App客户端权限分配""" _fields_ = [ - ("BrokerID", ctypes.c_char * 11), # 经纪公司代码 - ("AppID", ctypes.c_char * 33), # App代码 - ("DRIdentityID", ctypes.c_int) # 交易中心代码 + ('BrokerID', ctypes.c_char * 11), # 经纪公司代码 + ('AppID', ctypes.c_char * 33), # App代码 + ('DRIdentityID', ctypes.c_int), # 交易中心代码 ] def __init__(self, BrokerID='', AppID='', DRIdentityID=0): @@ -11427,9 +11420,7 @@ def __init__(self, QueryFreq=0): class AuthForbiddenIPField(Base): - """ - 禁止认证IP - """ + """禁止认证IP""" _fields_ = [ ('IPAddress', ctypes.c_char * 16), # IP地址 ] @@ -11440,9 +11431,7 @@ def __init__(self, IPAddress=''): class QryAuthForbiddenIPField(Base): - """ - 查询禁止认证IP - """ + """查询禁止认证IP""" _fields_ = [ ('IPAddress', ctypes.c_char * 16), # IP地址 ] @@ -11453,20 +11442,18 @@ def __init__(self, IPAddress=''): class SyncDelaySwapFrozenField(Base): - """ - 换汇可提冻结 - """ + """换汇可提冻结""" _fields_ = [ - ('DelaySwapSeqNo', ctypes.c_char * 11), # 换汇流水号 - ('BrokerID', ctypes.c_char * 16), # 经纪公司代码 + ('DelaySwapSeqNo', ctypes.c_char * 15), # 换汇流水号 + ('BrokerID', ctypes.c_char * 11), # 经纪公司代码 ('InvestorID', ctypes.c_char * 13), # 投资者代码 - ('FromCurrencyID', ctypes.c_char * 13), # 源币种 + ('FromCurrencyID', ctypes.c_char * 4), # 源币种 ('FromRemainSwap', ctypes.c_double), # 源剩余换汇额度(可提冻结) - ('IsManualSwap', ctypes.c_int) # 是否手工换汇 + ('IsManualSwap', ctypes.c_int), # 是否手工换汇 ] - def __init__(self, DelaySwapSeqNo='', BrokerID='', InvestorID='', - FromCurrencyID='', FromRemainSwap=0.0, IsManualSwap=0): + def __init__(self, DelaySwapSeqNo='', BrokerID='', InvestorID='', FromCurrencyID='', FromRemainSwap=0.0, + IsManualSwap=0): super(SyncDelaySwapFrozenField, self).__init__() self.DelaySwapSeqNo = self._to_bytes(DelaySwapSeqNo) self.BrokerID = self._to_bytes(BrokerID) diff --git a/ctpwrapper/Md.py b/ctpwrapper/Md.py index d34b76c..c6547c0 100644 --- a/ctpwrapper/Md.py +++ b/ctpwrapper/Md.py @@ -17,7 +17,6 @@ """ import time - from ctpwrapper.MdApi import MdApiWrapper @@ -36,7 +35,7 @@ def Init(self): 初始化运行环境,只有调用后,接口才开始工作 """ super(MdApiPy, self).Init() - time.sleep(0.1) # wait for c++ init + time.sleep(1) # wait for c++ init def Join(self) -> int: """ @@ -145,7 +144,6 @@ def UnSubscribeForQuoteRsp(self, pInstrumentID: list) -> int: return super(MdApiPy, self).UnSubscribeForQuoteRsp(ids) # for receive message - def OnFrontConnected(self): """ 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 diff --git a/ctpwrapper/MdApi.pyx b/ctpwrapper/MdApi.pyx index 1059fc1..6d486f1 100644 --- a/ctpwrapper/MdApi.pyx +++ b/ctpwrapper/MdApi.pyx @@ -19,13 +19,12 @@ along with ctpwrapper. If not, see . """ - from cpython cimport PyObject from libc.stdlib cimport malloc, free from libc.string cimport const_char from libcpp cimport bool as cbool -from .headers.ThostFtdcUserApiStruct cimport ( +from ctpwrapper.headers.ThostFtdcUserApiStruct cimport ( CThostFtdcRspUserLoginField, CThostFtdcRspInfoField, CThostFtdcUserLogoutField, @@ -37,11 +36,12 @@ CThostFtdcForQuoteRspField, CThostFtdcQryMulticastInstrumentField, CThostFtdcMulticastInstrumentField ) -from .headers.cMdAPI cimport CMdSpi, CMdApi, CreateFtdcMdApi +from ctpwrapper.headers.cMdAPI cimport CMdSpi, CMdApi, CreateFtdcMdApi import ctypes from . import ApiStructure + # from libcpp.memory cimport shared_ptr,make_shared @@ -67,7 +67,8 @@ cdef class MdApiWrapper: def Create(self, const_char *pszFlowPath, cbool bIsUsingUdp, cbool bIsMulticast): - self._api = CreateFtdcMdApi(pszFlowPath, bIsUsingUdp, bIsMulticast) + with nogil: + self._api = CreateFtdcMdApi(pszFlowPath, bIsUsingUdp, bIsMulticast) if not self._api: raise MemoryError() @@ -82,8 +83,9 @@ cdef class MdApiWrapper: self._spi = new CMdSpi( self) if self._spi is not NULL: - self._api.RegisterSpi(self._spi) - self._api.Init() + with nogil: + self._api.RegisterSpi(self._spi) + self._api.Init() else: raise MemoryError() @@ -118,7 +120,6 @@ cdef class MdApiWrapper: cdef size_t address if self._spi is not NULL: address = ctypes.addressof(pUserLogout) - with nogil: result = self._api.ReqUserLogout( address, nRequestID) @@ -162,8 +163,8 @@ cdef class MdApiWrapper: :return: """ if self._api is not NULL: - - self._api.RegisterFront(pszFrontAddress) + with nogil: + self._api.RegisterFront(pszFrontAddress) def RegisterNameServer(self, char *pszNsAddress): """ @@ -175,8 +176,8 @@ cdef class MdApiWrapper: :return: """ if self._api is not NULL: - - self._api.RegisterNameServer(pszNsAddress) + with nogil: + self._api.RegisterNameServer(pszNsAddress) def RegisterFensUserInfo(self, pFensUserInfo): """ @@ -187,16 +188,16 @@ cdef class MdApiWrapper: cdef size_t address if self._api is not NULL: address = ctypes.addressof(pFensUserInfo) - - self._api.RegisterFensUserInfo( address) + with nogil: + self._api.RegisterFensUserInfo( address) def SubscribeMarketData(self, pInstrumentID): """ - 订阅行情。 + 订阅行情。 @param ppInstrumentID 合约ID @param nCount 要订阅/退订行情的合约个数 - # https://www.quora.com/How-do-char-array-pointers-work-in-C++ + # https://www.quora.com/How-do-char-array-pointers-work-in-C++ # http://docs.cython.org/en/latest/src/userguide/language_basics.html#integer-for-loops # https://stackoverflow.com/questions/15686890/how-to-allocate-array-of-pointers-for-strings-by-malloc-in-c @@ -204,7 +205,7 @@ cdef class MdApiWrapper: """ cdef Py_ssize_t count, i cdef int result - cdef char **InstrumentIDs + cdef char ** InstrumentIDs if self._spi is not NULL: @@ -215,7 +216,7 @@ cdef class MdApiWrapper: for i from 0 <= i < count: InstrumentIDs[i] = pInstrumentID[i] with nogil: - result = self._api.SubscribeMarketData(InstrumentIDs, count) + result = self._api.SubscribeMarketData(InstrumentIDs, count) finally: free(InstrumentIDs) return result @@ -229,7 +230,7 @@ cdef class MdApiWrapper: """ cdef Py_ssize_t count, i cdef int result - cdef char **InstrumentIDs + cdef char ** InstrumentIDs if self._spi is not NULL: count = len(pInstrumentID) @@ -239,7 +240,7 @@ cdef class MdApiWrapper: for i from 0 <= i < count: InstrumentIDs[i] = pInstrumentID[i] with nogil: - result = self._api.UnSubscribeMarketData(InstrumentIDs, count) + result = self._api.UnSubscribeMarketData(InstrumentIDs, count) finally: free(InstrumentIDs) return result @@ -252,7 +253,7 @@ cdef class MdApiWrapper: """ cdef Py_ssize_t count, i cdef int result - cdef char **InstrumentIDs + cdef char ** InstrumentIDs if self._spi is not NULL: @@ -263,7 +264,7 @@ cdef class MdApiWrapper: for i from 0 <= i < count: InstrumentIDs[i] = pInstrumentID[i] with nogil: - result = self._api.SubscribeForQuoteRsp(InstrumentIDs, count) + result = self._api.SubscribeForQuoteRsp(InstrumentIDs, count) finally: free(InstrumentIDs) return result @@ -276,7 +277,7 @@ cdef class MdApiWrapper: """ cdef Py_ssize_t count, i cdef int result - cdef char **InstrumentIDs + cdef char ** InstrumentIDs if self._spi is not NULL: @@ -286,7 +287,7 @@ cdef class MdApiWrapper: for i from 0 <= i < count: InstrumentIDs[i] = pInstrumentID[i] with nogil: - result = self._api.UnSubscribeForQuoteRsp(InstrumentIDs, count) + result = self._api.UnSubscribeForQuoteRsp(InstrumentIDs, count) finally: free(InstrumentIDs) return result @@ -303,7 +304,8 @@ cdef extern int MdSpi_OnHeartBeatWarning(self, int nTimeLapse) except -1: self.OnHeartBeatWarning(nTimeLapse) return 0 -cdef extern int MdSpi_OnRspUserLogin(self, CThostFtdcRspUserLoginField *pRspUserLogin, +cdef extern int MdSpi_OnRspUserLogin(self, + CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: @@ -319,7 +321,8 @@ cdef extern int MdSpi_OnRspUserLogin(self, CThostFtdcRspUserLoginField *pRspUser self.OnRspUserLogin(user_login, rsp_info, nRequestID, bIsLast) return 0 -cdef extern int MdSpi_OnRspUserLogout(self, CThostFtdcUserLogoutField *pUserLogout, +cdef extern int MdSpi_OnRspUserLogout(self, + CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: @@ -335,7 +338,8 @@ cdef extern int MdSpi_OnRspUserLogout(self, CThostFtdcUserLogoutField *pUserLogo self.OnRspUserLogout(user_logout, rsp_info, nRequestID, bIsLast) return 0 -cdef extern int MdSpi_OnRspError(self, CThostFtdcRspInfoField *pRspInfo, +cdef extern int MdSpi_OnRspError(self, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: if pRspInfo is NULL: @@ -345,7 +349,8 @@ cdef extern int MdSpi_OnRspError(self, CThostFtdcRspInfoField *pRspInfo, self.OnRspError(rsp_info, nRequestID, bIsLast) return 0 -cdef extern int MdSpi_OnRspSubMarketData(self, CThostFtdcSpecificInstrumentField *pSpecificInstrument, +cdef extern int MdSpi_OnRspSubMarketData(self, + CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: @@ -361,7 +366,8 @@ cdef extern int MdSpi_OnRspSubMarketData(self, CThostFtdcSpecificInstrumentField self.OnRspSubMarketData(instrument, rsp_info, nRequestID, bIsLast) return 0 -cdef extern int MdSpi_OnRspUnSubMarketData(self, CThostFtdcSpecificInstrumentField *pSpecificInstrument, +cdef extern int MdSpi_OnRspUnSubMarketData(self, + CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: @@ -395,7 +401,11 @@ cdef extern int MdSpi_OnRspSubForQuoteRsp(self, self.OnRspSubForQuoteRsp(instrument, rsp_info, nRequestID, bIsLast) return 0 -cdef extern int MdSpi_OnRspUnSubForQuoteRsp(self, CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: +cdef extern int MdSpi_OnRspUnSubForQuoteRsp(self, + CThostFtdcSpecificInstrumentField *pSpecificInstrument, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: if pSpecificInstrument is NULL: instrument = None else: @@ -425,7 +435,11 @@ cdef extern int MdSpi_OnRtnForQuoteRsp(self, CThostFtdcForQuoteRspField *pForQuo self.OnRtnForQuoteRsp(quote) return 0 -cdef extern int MdSpi_OnRspQryMulticastInstrument(self, CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: +cdef extern int MdSpi_OnRspQryMulticastInstrument(self, + CThostFtdcMulticastInstrumentField *pMulticastInstrument, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: if pMulticastInstrument is NULL: MulticastInstrument = None else: @@ -437,4 +451,4 @@ cdef extern int MdSpi_OnRspQryMulticastInstrument(self, CThostFtdcMulticastInstr rsp_info = ApiStructure.RspInfoField.from_address( pRspInfo) self.OnRspQryMulticastInstrument(MulticastInstrument, rsp_info, nRequestID, bIsLast) - return 0 \ No newline at end of file + return 0 diff --git a/ctpwrapper/Trader.py b/ctpwrapper/Trader.py index c254ac2..8fc46c7 100644 --- a/ctpwrapper/Trader.py +++ b/ctpwrapper/Trader.py @@ -31,7 +31,7 @@ def Release(self): def Init(self): super(TraderApiPy, self).Init() - time.sleep(0.1) # wait for c++ init + time.sleep(1) # wait for c++ init def Join(self): return super(TraderApiPy, self).Join() diff --git a/ctpwrapper/TraderApi.pyx b/ctpwrapper/TraderApi.pyx index f80682c..82b8ae9 100644 --- a/ctpwrapper/TraderApi.pyx +++ b/ctpwrapper/TraderApi.pyx @@ -21,13 +21,13 @@ from cpython cimport PyObject from libc.string cimport const_char from libcpp cimport bool as cbool -from .headers.ThostFtdcUserApiStruct cimport * -from .headers.cTraderApi cimport CTraderSpi, CTraderApi, CreateFtdcTraderApi +from ctpwrapper.headers.ThostFtdcUserApiStruct cimport * +from ctpwrapper.headers.cTraderApi cimport CTraderSpi, CTraderApi, CreateFtdcTraderApi # from libcpp.memory cimport shared_ptr,make_shared import ctypes -from . import ApiStructure +from ctpwrapper import ApiStructure cdef class TraderApiWrapper: cdef CTraderApi *_api @@ -63,8 +63,9 @@ cdef class TraderApiWrapper: self._spi = new CTraderSpi( self) if self._spi is not NULL: - self._api.RegisterSpi(self._spi) - self._api.Init() + with nogil: + self._api.RegisterSpi(self._spi) + self._api.Init() else: raise MemoryError() @@ -88,22 +89,25 @@ cdef class TraderApiWrapper: def RegisterFront(self, char *pszFrontAddress): if self._api is not NULL: - self._api.RegisterFront(pszFrontAddress) + with nogil: + self._api.RegisterFront(pszFrontAddress) def RegisterNameServer(self, char *pszNsAddress): if self._api is not NULL: - self._api.RegisterNameServer(pszNsAddress) + with nogil: + self._api.RegisterNameServer(pszNsAddress) def RegisterFensUserInfo(self, pFensUserInfo): cdef size_t address if self._api is not NULL: address = ctypes.addressof(pFensUserInfo) - - self._api.RegisterFensUserInfo( address) + with nogil: + self._api.RegisterFensUserInfo( address) def SubscribePrivateTopic(self, THOST_TE_RESUME_TYPE nResumeType): if self._api is not NULL: - self._api.SubscribePrivateTopic(nResumeType) + with nogil: + self._api.SubscribePrivateTopic(nResumeType) #订阅公共流。 #@param nResumeType 公共流重传方式 # THOST_TERT_RESTART:从本交易日开始重传 @@ -112,7 +116,8 @@ cdef class TraderApiWrapper: #@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。 def SubscribePublicTopic(self, THOST_TE_RESUME_TYPE nResumeType): if self._api is not NULL: - self._api.SubscribePublicTopic(nResumeType) + with nogil: + self._api.SubscribePublicTopic(nResumeType) #客户端认证请求 def ReqAuthenticate(self, pReqAuthenticateField, int nRequestID): @@ -186,7 +191,7 @@ cdef class TraderApiWrapper: return result # 查询用户当前支持的认证模式 - def ReqUserAuthMethod(self,pReqUserAuthMethod, int nRequestID): + def ReqUserAuthMethod(self, pReqUserAuthMethod, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -196,7 +201,7 @@ cdef class TraderApiWrapper: return result # 用户发出获取图形验证码请求 - def ReqGenUserCaptcha(self,pReqGenUserCaptcha, int nRequestID): + def ReqGenUserCaptcha(self, pReqGenUserCaptcha, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -205,7 +210,7 @@ cdef class TraderApiWrapper: result = self._api.ReqGenUserCaptcha( address, nRequestID) return result # 用户发出获取短信验证码请求 - def ReqGenUserText(self,pReqGenUserText, int nRequestID): + def ReqGenUserText(self, pReqGenUserText, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -214,7 +219,7 @@ cdef class TraderApiWrapper: result = self._api.ReqGenUserText( address, nRequestID) return result # 用户发出带有图片验证码的登陆请求 - def ReqUserLoginWithCaptcha(self,pReqUserLoginWithCaptcha, int nRequestID): + def ReqUserLoginWithCaptcha(self, pReqUserLoginWithCaptcha, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -223,7 +228,7 @@ cdef class TraderApiWrapper: result = self._api.ReqUserLoginWithCaptcha( address, nRequestID) return result # 用户发出带有短信验证码的登陆请求 - def ReqUserLoginWithText(self,pReqUserLoginWithText, int nRequestID): + def ReqUserLoginWithText(self, pReqUserLoginWithText, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -232,7 +237,7 @@ cdef class TraderApiWrapper: result = self._api.ReqUserLoginWithText( address, nRequestID) return result # 用户发出带有动态口令的登陆请求 - def ReqUserLoginWithOTP(self,pReqUserLoginWithOTP, int nRequestID): + def ReqUserLoginWithOTP(self, pReqUserLoginWithOTP, int nRequestID): cdef int result cdef size_t address if self._api is not NULL: @@ -294,8 +299,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pSettlementInfoConfirm) with nogil: - result = self._api.ReqSettlementInfoConfirm( address, - nRequestID) + result = self._api.ReqSettlementInfoConfirm( address, nRequestID) return result #请求删除预埋单 def ReqRemoveParkedOrder(self, pRemoveParkedOrder, int nRequestID): @@ -313,8 +317,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pRemoveParkedOrderAction) with nogil: - result = self._api.ReqRemoveParkedOrderAction( address, - nRequestID) + result = self._api.ReqRemoveParkedOrderAction( address, nRequestID) return result #执行宣告录入请求 def ReqExecOrderInsert(self, pInputExecOrder, int nRequestID): @@ -382,15 +385,13 @@ cdef class TraderApiWrapper: result = self._api.ReqOptionSelfCloseInsert( address, nRequestID) return result #期权自对冲操作请求 - def ReqOptionSelfCloseAction(self, pInputOptionSelfCloseAction, - int nRequestID): + def ReqOptionSelfCloseAction(self, pInputOptionSelfCloseAction, int nRequestID): cdef int result cdef size_t address if self._spi is not NULL: address = ctypes.addressof(pInputOptionSelfCloseAction) with nogil: - result = self._api.ReqOptionSelfCloseAction( address, - nRequestID) + result = self._api.ReqOptionSelfCloseAction( address, nRequestID) return result #申请组合录入请求 @@ -463,8 +464,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInstrumentMarginRate) with nogil: - result = self._api.ReqQryInstrumentMarginRate( address, - nRequestID) + result = self._api.ReqQryInstrumentMarginRate( address, nRequestID) return result #请求查询合约手续费率 def ReqQryInstrumentCommissionRate(self, pQryInstrumentCommissionRate, int nRequestID): @@ -473,8 +473,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInstrumentCommissionRate) with nogil: - result = self._api.ReqQryInstrumentCommissionRate( - address, nRequestID) + result = self._api.ReqQryInstrumentCommissionRate( address, nRequestID) return result #请求查询交易所 def ReqQryExchange(self, pQryExchange, int nRequestID): @@ -538,8 +537,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInvestorPositionDetail) with nogil: - result = self._api.ReqQryInvestorPositionDetail( address, - nRequestID) + result = self._api.ReqQryInvestorPositionDetail( address, nRequestID) return result #请求查询客户通知 def ReqQryNotice(self, pQryNotice, int nRequestID): @@ -547,7 +545,6 @@ cdef class TraderApiWrapper: cdef size_t address if self._spi is not NULL: address = ctypes.addressof(pQryNotice) - with nogil: result = self._api.ReqQryNotice( address, nRequestID) return result @@ -558,8 +555,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQrySettlementInfoConfirm) with nogil: - result = self._api.ReqQrySettlementInfoConfirm( address, - nRequestID) + result = self._api.ReqQrySettlementInfoConfirm( address, nRequestID) return result #请求查询投资者持仓明细 def ReqQryInvestorPositionCombineDetail(self, pQryInvestorPositionCombineDetail, int nRequestID): @@ -568,8 +564,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInvestorPositionCombineDetail) with nogil: - result = self._api.ReqQryInvestorPositionCombineDetail( - address, nRequestID) + result = self._api.ReqQryInvestorPositionCombineDetail( address, nRequestID) return result #请求查询保证金监管系统经纪公司资金账户密钥 def ReqQryCFMMCTradingAccountKey(self, pQryCFMMCTradingAccountKey, int nRequestID): @@ -578,8 +573,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryCFMMCTradingAccountKey) with nogil: - result = self._api.ReqQryCFMMCTradingAccountKey( address, - nRequestID) + result = self._api.ReqQryCFMMCTradingAccountKey( address, nRequestID) return result #请求查询仓单折抵信息 def ReqQryEWarrantOffset(self, pQryEWarrantOffset, int nRequestID): @@ -597,8 +591,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInvestorProductGroupMargin) with nogil: - result = self._api.ReqQryInvestorProductGroupMargin( - address, nRequestID) + result = self._api.ReqQryInvestorProductGroupMargin( address, nRequestID) return result #请求查询交易所保证金率 def ReqQryExchangeMarginRate(self, pQryExchangeMarginRate, int nRequestID): @@ -608,8 +601,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryExchangeMarginRate) with nogil: - result = self._api.ReqQryExchangeMarginRate( address, - nRequestID) + result = self._api.ReqQryExchangeMarginRate( address, nRequestID) return result #请求查询交易所调整保证金率 def ReqQryExchangeMarginRateAdjust(self, pQryExchangeMarginRateAdjust, int nRequestID): @@ -618,8 +610,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryExchangeMarginRateAdjust) with nogil: - result = self._api.ReqQryExchangeMarginRateAdjust( - address, nRequestID) + result = self._api.ReqQryExchangeMarginRateAdjust( address, nRequestID) return result #请求查询汇率 def ReqQryExchangeRate(self, pQryExchangeRate, int nRequestID): @@ -640,7 +631,6 @@ cdef class TraderApiWrapper: with nogil: result = self._api.ReqQrySecAgentACIDMap( address, nRequestID) return result - #请求查询产品报价汇率 def ReqQryProductExchRate(self, pQryProductExchRate, int nRequestID): @@ -669,8 +659,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryMMInstrumentCommissionRate) with nogil: - result = self._api.ReqQryMMInstrumentCommissionRate( - address, nRequestID) + result = self._api.ReqQryMMInstrumentCommissionRate( address, nRequestID) return result #请求查询做市商期权合约手续费 @@ -680,8 +669,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryMMOptionInstrCommRate) with nogil: - result = self._api.ReqQryMMOptionInstrCommRate( address, - nRequestID) + result = self._api.ReqQryMMOptionInstrCommRate( address, nRequestID) return result #请求查询报单手续费 @@ -691,8 +679,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryInstrumentOrderCommRate) with nogil: - result = self._api.ReqQryInstrumentOrderCommRate( address, - nRequestID) + result = self._api.ReqQryInstrumentOrderCommRate( address, nRequestID) return result #请求查询资金账户 @@ -703,8 +690,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryTradingAccount) with nogil: - result = self._api.ReqQrySecAgentTradingAccount( address, - nRequestID) + result = self._api.ReqQrySecAgentTradingAccount( address, nRequestID) return result #请求查询二级代理商资金校验模式 @@ -725,8 +711,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryOptionInstrTradeCost) with nogil: - result = self._api.ReqQryOptionInstrTradeCost( address, - nRequestID) + result = self._api.ReqQryOptionInstrTradeCost( address, nRequestID) return result #请求查询期权合约手续费 def ReqQryOptionInstrCommRate(self, pQryOptionInstrCommRate, int nRequestID): @@ -735,8 +720,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryOptionInstrCommRate) with nogil: - result = self._api.ReqQryOptionInstrCommRate( address, - nRequestID) + result = self._api.ReqQryOptionInstrCommRate( address, nRequestID) return result #请求查询执行宣告 def ReqQryExecOrder(self, pQryExecOrder, int nRequestID): @@ -791,8 +775,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryCombInstrumentGuard) with nogil: - result = self._api.ReqQryCombInstrumentGuard( address, - nRequestID) + result = self._api.ReqQryCombInstrumentGuard( address, nRequestID) return result #请求查询申请组合 def ReqQryCombAction(self, pQryCombAction, int nRequestID): @@ -864,8 +847,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryBrokerTradingParams) with nogil: - result = self._api.ReqQryBrokerTradingParams( address, - nRequestID) + result = self._api.ReqQryBrokerTradingParams( address, nRequestID) return result #请求查询经纪公司交易算法 def ReqQryBrokerTradingAlgos(self, pQryBrokerTradingAlgos, int nRequestID): @@ -874,8 +856,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQryBrokerTradingAlgos) with nogil: - result = self._api.ReqQryBrokerTradingAlgos( address, - nRequestID) + result = self._api.ReqQryBrokerTradingAlgos( address, nRequestID) return result #请求查询监控中心用户令牌 def ReqQueryCFMMCTradingAccountToken(self, pQueryCFMMCTradingAccountToken, int nRequestID): @@ -884,8 +865,7 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pQueryCFMMCTradingAccountToken) with nogil: - result = self._api.ReqQueryCFMMCTradingAccountToken( - address, nRequestID) + result = self._api.ReqQueryCFMMCTradingAccountToken( address, nRequestID) return result #期货发起银行资金转期货请求 def ReqFromBankToFutureByFuture(self, pReqTransfer, int nRequestID): @@ -913,20 +893,17 @@ cdef class TraderApiWrapper: if self._spi is not NULL: address = ctypes.addressof(pReqQueryAccount) with nogil: - result = self._api.ReqQueryBankAccountMoneyByFuture( address, - nRequestID) + result = self._api.ReqQueryBankAccountMoneyByFuture( address, nRequestID) return result - + # 请求查询二级代理商信息 - def ReqQrySecAgentTradeInfo(self,pQrySecAgentTradeInfo, int nRequestID): + def ReqQrySecAgentTradeInfo(self, pQrySecAgentTradeInfo, int nRequestID): cdef size_t address if self._spi is not NULL: address = ctypes.addressof(pQrySecAgentTradeInfo) with nogil: - result = self._api.ReqQrySecAgentTradeInfo( address, - nRequestID) + result = self._api.ReqQrySecAgentTradeInfo( address, nRequestID) return result - cdef extern int TraderSpi_OnFrontConnected(self) except -1: self.OnFrontConnected() @@ -940,851 +917,1133 @@ cdef extern int TraderSpi_OnHeartBeatWarning(self, int nTimeLapse) except -1: self.OnHeartBeatWarning(nTimeLapse) return 0 -cdef extern int TraderSpi_OnRspAuthenticate(self, CThostFtdcRspAuthenticateField *pRspAuthenticate, +cdef extern int TraderSpi_OnRspAuthenticate(self, + CThostFtdcRspAuthenticateField *pRspAuthenticate, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspAuthenticate( None if pRspAuthenticate is NULL else ApiStructure.RspAuthenticateField.from_address( pRspAuthenticate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspUserLogin(self, CThostFtdcRspUserLoginField *pRspUserLogin, +cdef extern int TraderSpi_OnRspUserLogin(self, + CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspUserLogin( None if pRspUserLogin is NULL else ApiStructure.RspUserLoginField.from_address( pRspUserLogin), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspUserLogout(self, CThostFtdcUserLogoutField *pUserLogout, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspUserLogout(self, + CThostFtdcUserLogoutField *pUserLogout, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspUserLogout( None if pUserLogout is NULL else ApiStructure.UserLogoutField.from_address( pUserLogout), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspUserPasswordUpdate(self, CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspUserPasswordUpdate(self, + CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspUserPasswordUpdate( - None if pUserPasswordUpdate is NULL else ApiStructure.UserPasswordUpdateField.from_address( - pUserPasswordUpdate), + None if pUserPasswordUpdate is NULL else ApiStructure.UserPasswordUpdateField.from_address( pUserPasswordUpdate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspTradingAccountPasswordUpdate(self, CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspTradingAccountPasswordUpdate( - None if pTradingAccountPasswordUpdate is NULL else ApiStructure.TradingAccountPasswordUpdateField.from_address( - pTradingAccountPasswordUpdate), + None if pTradingAccountPasswordUpdate is NULL else ApiStructure.TradingAccountPasswordUpdateField.from_address( pTradingAccountPasswordUpdate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspOrderInsert(self, CThostFtdcInputOrderField *pInputOrder, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspOrderInsert(self, + CThostFtdcInputOrderField *pInputOrder, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspOrderInsert( None if pInputOrder is NULL else ApiStructure.InputOrderField.from_address( pInputOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspParkedOrderInsert(self, CThostFtdcParkedOrderField *pParkedOrder, +cdef extern int TraderSpi_OnRspParkedOrderInsert(self, + CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspParkedOrderInsert( None if pParkedOrder is NULL else ApiStructure.ParkedOrderField.from_address( pParkedOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspParkedOrderAction(self, CThostFtdcParkedOrderActionField *pParkedOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspParkedOrderAction(self, + CThostFtdcParkedOrderActionField *pParkedOrderAction, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspParkedOrderAction( - None if pParkedOrderAction is NULL else ApiStructure.ParkedOrderActionField.from_address( - pParkedOrderAction), + None if pParkedOrderAction is NULL else ApiStructure.ParkedOrderActionField.from_address( pParkedOrderAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspOrderAction(self, CThostFtdcInputOrderActionField *pInputOrderAction, +cdef extern int TraderSpi_OnRspOrderAction(self, + CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: - self.OnRspOrderAction(None if pInputOrderAction is NULL else ApiStructure.InputOrderActionField.from_address( - pInputOrderAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + int nRequestID, + cbool bIsLast) except -1: + self.OnRspOrderAction( + None if pInputOrderAction is NULL else ApiStructure.InputOrderActionField.from_address( pInputOrderAction), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQueryMaxOrderVolume(self, CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQueryMaxOrderVolume(self, + CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQueryMaxOrderVolume( - None if pQueryMaxOrderVolume is NULL else ApiStructure.QueryMaxOrderVolumeField.from_address( - pQueryMaxOrderVolume), + None if pQueryMaxOrderVolume is NULL else ApiStructure.QueryMaxOrderVolumeField.from_address( pQueryMaxOrderVolume), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspSettlementInfoConfirm(self, CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspSettlementInfoConfirm(self, + CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspSettlementInfoConfirm( - None if pSettlementInfoConfirm is NULL else ApiStructure.SettlementInfoConfirmField.from_address( - pSettlementInfoConfirm), + None if pSettlementInfoConfirm is NULL else ApiStructure.SettlementInfoConfirmField.from_address( pSettlementInfoConfirm), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspRemoveParkedOrder(self, CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspRemoveParkedOrder(self, + CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspRemoveParkedOrder( - None if pRemoveParkedOrder is NULL else ApiStructure.RemoveParkedOrderField.from_address( - pRemoveParkedOrder), + None if pRemoveParkedOrder is NULL else ApiStructure.RemoveParkedOrderField.from_address( pRemoveParkedOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspRemoveParkedOrderAction(self, CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspRemoveParkedOrderAction( - None if pRemoveParkedOrderAction is NULL else ApiStructure.RemoveParkedOrderAction( - pRemoveParkedOrderAction), + None if pRemoveParkedOrderAction is NULL else ApiStructure.RemoveParkedOrderActionField( pRemoveParkedOrderAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspExecOrderInsert(self, CThostFtdcInputExecOrderField *pInputExecOrder, +cdef extern int TraderSpi_OnRspExecOrderInsert(self, + CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspExecOrderInsert( None if pInputExecOrder is NULL else ApiStructure.InputExecOrderField.from_address( pInputExecOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspExecOrderAction(self, CThostFtdcInputExecOrderActionField *pInputExecOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspExecOrderAction(self, + CThostFtdcInputExecOrderActionField *pInputExecOrderAction, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspExecOrderAction( - None if pInputExecOrderAction is NULL else ApiStructure.InputExecOrderActionField.from_address( - pInputExecOrderAction), + None if pInputExecOrderAction is NULL else ApiStructure.InputExecOrderActionField.from_address( pInputExecOrderAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspForQuoteInsert(self, CThostFtdcInputForQuoteField *pInputForQuote, +cdef extern int TraderSpi_OnRspForQuoteInsert(self, + CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspForQuoteInsert( None if pInputForQuote is NULL else ApiStructure.InputForQuoteField.from_address( pInputForQuote), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQuoteInsert(self, CThostFtdcInputQuoteField *pInputQuote, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQuoteInsert(self, + CThostFtdcInputQuoteField *pInputQuote, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQuoteInsert( None if pInputQuote is NULL else ApiStructure.InputQuoteField.from_address( pInputQuote), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQuoteAction(self, CThostFtdcInputQuoteActionField *pInputQuoteAction, +cdef extern int TraderSpi_OnRspQuoteAction(self, + CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: - self.OnRspQuoteAction(None if pInputQuoteAction is NULL else ApiStructure.InputQuoteActionField.from_address( - pInputQuoteAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + int nRequestID, + cbool bIsLast) except -1: + self.OnRspQuoteAction( + None if pInputQuoteAction is NULL else ApiStructure.InputQuoteActionField.from_address( pInputQuoteAction), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspCombActionInsert(self, CThostFtdcInputCombActionField *pInputCombAction, +cdef extern int TraderSpi_OnRspCombActionInsert(self, + CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspCombActionInsert( None if pInputCombAction is NULL else ApiStructure.InputCombActionField.from_address( pInputCombAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryOrder(self, CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryOrder(self, + CThostFtdcOrderField *pOrder, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryOrder(None if pOrder is NULL else ApiStructure.OrderField.from_address( pOrder), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryOrder( + None if pOrder is NULL else ApiStructure.OrderField.from_address( pOrder), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTrade(self, CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryTrade(self, + CThostFtdcTradeField *pTrade, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryTrade(None if pTrade is NULL else ApiStructure.TradeField.from_address( pTrade), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryTrade( + None if pTrade is NULL else ApiStructure.TradeField.from_address( pTrade), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryInvestorPosition(self, CThostFtdcInvestorPositionField *pInvestorPosition, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryInvestorPosition(self, + CThostFtdcInvestorPositionField *pInvestorPosition, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInvestorPosition( - None if pInvestorPosition is NULL else ApiStructure.InvestorPositionField.from_address( - pInvestorPosition), + None if pInvestorPosition is NULL else ApiStructure.InvestorPositionField.from_address( pInvestorPosition), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTradingAccount(self, CThostFtdcTradingAccountField *pTradingAccount, +cdef extern int TraderSpi_OnRspQryTradingAccount(self, + CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryTradingAccount( None if pTradingAccount is NULL else ApiStructure.TradingAccountField.from_address( pTradingAccount), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryInvestor(self, CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryInvestor(self, + CThostFtdcInvestorField *pInvestor, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryInvestor(None if pInvestor is NULL else ApiStructure.InvestorField.from_address( pInvestor), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryInvestor( + None if pInvestor is NULL else ApiStructure.InvestorField.from_address( pInvestor), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTradingCode(self, CThostFtdcTradingCodeField *pTradingCode, +cdef extern int TraderSpi_OnRspQryTradingCode(self, + CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryTradingCode( None if pTradingCode is NULL else ApiStructure.TradingCodeField.from_address( pTradingCode), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryInstrumentMarginRate(self, CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryInstrumentMarginRate(self, + CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInstrumentMarginRate( - None if pInstrumentMarginRate is NULL else ApiStructure.InstrumentMarginRateField.from_address( - pInstrumentMarginRate), + None if pInstrumentMarginRate is NULL else ApiStructure.InstrumentMarginRateField.from_address( pInstrumentMarginRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryInstrumentCommissionRate(self, CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInstrumentCommissionRate( - None if pInstrumentCommissionRate is NULL else ApiStructure.InstrumentCommissionRateField.from_address( - pInstrumentCommissionRate), + None if pInstrumentCommissionRate is NULL else ApiStructure.InstrumentCommissionRateField.from_address( pInstrumentCommissionRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryExchange(self, CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryExchange(self, + CThostFtdcExchangeField *pExchange, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryExchange(None if pExchange is NULL else ApiStructure.ExchangeField.from_address( pExchange), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryExchange( + None if pExchange is NULL else ApiStructure.ExchangeField.from_address( pExchange), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryProduct(self, CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryProduct(self, + CThostFtdcProductField *pProduct, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryProduct(None if pProduct is NULL else ApiStructure.ProductField.from_address( pProduct), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryProduct( + None if pProduct is NULL else ApiStructure.ProductField.from_address( pProduct), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) + return 0 -cdef extern int TraderSpi_OnRspQryInstrument(self, CThostFtdcInstrumentField *pInstrument, +cdef extern int TraderSpi_OnRspQryInstrument(self, + CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryInstrument( None if pInstrument is NULL else ApiStructure.InstrumentField.from_address( pInstrument), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryDepthMarketData(self, CThostFtdcDepthMarketDataField *pDepthMarketData, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryDepthMarketData(self, + CThostFtdcDepthMarketDataField *pDepthMarketData, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryDepthMarketData( None if pDepthMarketData is NULL else ApiStructure.DepthMarketDataField.from_address( pDepthMarketData), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQrySettlementInfo(self, CThostFtdcSettlementInfoField *pSettlementInfo, +cdef extern int TraderSpi_OnRspQrySettlementInfo(self, + CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQrySettlementInfo( None if pSettlementInfo is NULL else ApiStructure.SettlementInfoField.from_address( pSettlementInfo), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTransferBank(self, CThostFtdcTransferBankField *pTransferBank, +cdef extern int TraderSpi_OnRspQryTransferBank(self, + CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryTransferBank( None if pTransferBank is NULL else ApiStructure.TransferBankField.from_address( pTransferBank), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryInvestorPositionDetail(self, CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInvestorPositionDetail( - None if pInvestorPositionDetail is NULL else ApiStructure.InvestorPositionDetailField.from_address( - pInvestorPositionDetail), + None if pInvestorPositionDetail is NULL else ApiStructure.InvestorPositionDetailField.from_address( pInvestorPositionDetail), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryNotice(self, CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryNotice(self, + CThostFtdcNoticeField *pNotice, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryNotice(None if pNotice is NULL else ApiStructure.NoticeField.from_address( pNotice), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryNotice( + None if pNotice is NULL else ApiStructure.NoticeField.from_address( pNotice), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQrySettlementInfoConfirm(self, CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQrySettlementInfoConfirm( - None if pSettlementInfoConfirm is NULL else ApiStructure.SettlementInfoConfirmField.from_address( - pSettlementInfoConfirm), + None if pSettlementInfoConfirm is NULL else ApiStructure.SettlementInfoConfirmField.from_address( pSettlementInfoConfirm), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryInvestorPositionCombineDetail(self, CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInvestorPositionCombineDetail( - None if pInvestorPositionCombineDetail is NULL else ApiStructure.InvestorPositionCombineDetailField.from_address( - pInvestorPositionCombineDetail), + None if pInvestorPositionCombineDetail is NULL else ApiStructure.InvestorPositionCombineDetailField.from_address( pInvestorPositionCombineDetail), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryCFMMCTradingAccountKey(self, CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryCFMMCTradingAccountKey( - None if pCFMMCTradingAccountKey is NULL else ApiStructure.CFMMCTradingAccountKeyField.from_address( - pCFMMCTradingAccountKey), + None if pCFMMCTradingAccountKey is NULL else ApiStructure.CFMMCTradingAccountKeyField.from_address( pCFMMCTradingAccountKey), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryEWarrantOffset(self, CThostFtdcEWarrantOffsetField *pEWarrantOffset, +cdef extern int TraderSpi_OnRspQryEWarrantOffset(self, + CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryEWarrantOffset( None if pEWarrantOffset is NULL else ApiStructure.EWarrantOffsetField.from_address( pEWarrantOffset), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryInvestorProductGroupMargin(self, CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInvestorProductGroupMargin( - None if pInvestorProductGroupMargin is NULL else ApiStructure.InvestorProductGroupMarginField.from_address( - pInvestorProductGroupMargin), + None if pInvestorProductGroupMargin is NULL else ApiStructure.InvestorProductGroupMarginField.from_address( pInvestorProductGroupMargin), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryExchangeMarginRate(self, CThostFtdcExchangeMarginRateField *pExchangeMarginRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryExchangeMarginRate(self, + CThostFtdcExchangeMarginRateField *pExchangeMarginRate, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryExchangeMarginRate( - None if pExchangeMarginRate is NULL else ApiStructure.ExchangeMarginRateField.from_address( - pExchangeMarginRate), + None if pExchangeMarginRate is NULL else ApiStructure.ExchangeMarginRateField.from_address( pExchangeMarginRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryExchangeMarginRateAdjust(self, CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryExchangeMarginRateAdjust( - None if pExchangeMarginRateAdjust is NULL else ApiStructure.ExchangeMarginRateAdjustField.from_address( - pExchangeMarginRateAdjust), + None if pExchangeMarginRateAdjust is NULL else ApiStructure.ExchangeMarginRateAdjustField.from_address( pExchangeMarginRateAdjust), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryExchangeRate(self, CThostFtdcExchangeRateField *pExchangeRate, +cdef extern int TraderSpi_OnRspQryExchangeRate(self, + CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryExchangeRate( None if pExchangeRate is NULL else ApiStructure.ExchangeRateField.from_address( pExchangeRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQrySecAgentACIDMap(self, CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQrySecAgentACIDMap(self, + CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQrySecAgentACIDMap( None if pSecAgentACIDMap is NULL else ApiStructure.SecAgentACIDMapField.from_address( pSecAgentACIDMap), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryProductExchRate(self, CThostFtdcProductExchRateField *pProductExchRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryProductExchRate(self, + CThostFtdcProductExchRateField *pProductExchRate, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryProductExchRate( None if pProductExchRate is NULL else ApiStructure.ProductExchRateField.from_address( pProductExchRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryOptionInstrTradeCost(self, CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryOptionInstrTradeCost(self, + CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryOptionInstrTradeCost( - None if pOptionInstrTradeCost is NULL else ApiStructure.OptionInstrTradeCostField.from_address( - pOptionInstrTradeCost), + None if pOptionInstrTradeCost is NULL else ApiStructure.OptionInstrTradeCostField.from_address( pOptionInstrTradeCost), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryOptionInstrCommRate(self, CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryOptionInstrCommRate(self, + CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryOptionInstrCommRate( - None if pOptionInstrCommRate is NULL else ApiStructure.OptionInstrCommRateField.from_address( - pOptionInstrCommRate), + None if pOptionInstrCommRate is NULL else ApiStructure.OptionInstrCommRateField.from_address( pOptionInstrCommRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryExecOrder(self, CThostFtdcExecOrderField *pExecOrder, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryExecOrder(self, + CThostFtdcExecOrderField *pExecOrder, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryExecOrder( None if pExecOrder is NULL else ApiStructure.ExecOrderField.from_address( pExecOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryForQuote(self, CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryForQuote(self, + CThostFtdcForQuoteField *pForQuote, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryForQuote(None if pForQuote is NULL else ApiStructure.ForQuoteField.from_address( pForQuote), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryForQuote( + None if pForQuote is NULL else ApiStructure.ForQuoteField.from_address( pForQuote), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryQuote(self, CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, +cdef extern int TraderSpi_OnRspQryQuote(self, + CThostFtdcQuoteField *pQuote, + CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: - self.OnRspQryQuote(None if pQuote is NULL else ApiStructure.QuoteField.from_address( pQuote), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( - pRspInfo), nRequestID, bIsLast) + self.OnRspQryQuote( + None if pQuote is NULL else ApiStructure.QuoteField.from_address( pQuote), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryCombInstrumentGuard(self, CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryCombInstrumentGuard(self, + CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryCombInstrumentGuard( - None if pCombInstrumentGuard is NULL else ApiStructure.CombInstrumentGuardField.from_address( - pCombInstrumentGuard), + None if pCombInstrumentGuard is NULL else ApiStructure.CombInstrumentGuardField.from_address( pCombInstrumentGuard), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryCombAction(self, CThostFtdcCombActionField *pCombAction, +cdef extern int TraderSpi_OnRspQryCombAction(self, + CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryCombAction( None if pCombAction is NULL else ApiStructure.CombActionField.from_address( pCombAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTransferSerial(self, CThostFtdcTransferSerialField *pTransferSerial, +cdef extern int TraderSpi_OnRspQryTransferSerial(self, + CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryTransferSerial( None if pTransferSerial is NULL else ApiStructure.TransferSerialField.from_address( pTransferSerial), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryAccountregister(self, CThostFtdcAccountregisterField *pAccountregister, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryAccountregister(self, + CThostFtdcAccountregisterField *pAccountregister, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryAccountregister( None if pAccountregister is NULL else ApiStructure.AccountregisterField.from_address( pAccountregister), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) + return 0 -cdef extern int TraderSpi_OnRspError(self, CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast) except -1: +cdef extern int TraderSpi_OnRspError(self, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: self.OnRspError( None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRtnOrder(self, CThostFtdcOrderField *pOrder) except -1: - self.OnRtnOrder(None if pOrder is NULL else ApiStructure.OrderField.from_address( pOrder)) + self.OnRtnOrder( + None if pOrder is NULL else ApiStructure.OrderField.from_address( pOrder) + ) return 0 cdef extern int TraderSpi_OnRtnTrade(self, CThostFtdcTradeField *pTrade) except -1: - self.OnRtnTrade(None if pTrade is NULL else ApiStructure.TradeField.from_address( pTrade)) + self.OnRtnTrade( + None if pTrade is NULL else ApiStructure.TradeField.from_address( pTrade) + ) return 0 -cdef extern int TraderSpi_OnErrRtnOrderInsert(self, CThostFtdcInputOrderField *pInputOrder, +cdef extern int TraderSpi_OnErrRtnOrderInsert(self, + CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnOrderInsert( None if pInputOrder is NULL else ApiStructure.InputOrderField.from_address( pInputOrder), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnOrderAction(self, CThostFtdcOrderActionField *pOrderAction, +cdef extern int TraderSpi_OnErrRtnOrderAction(self, + CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnOrderAction( None if pOrderAction is NULL else ApiStructure.OrderActionField.from_address( pOrderAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 cdef extern int TraderSpi_OnRtnInstrumentStatus(self, CThostFtdcInstrumentStatusField *pInstrumentStatus) except -1: self.OnRtnInstrumentStatus( - None if pInstrumentStatus is NULL else ApiStructure.InstrumentStatusField.from_address( - pInstrumentStatus)) + None if pInstrumentStatus is NULL else ApiStructure.InstrumentStatusField.from_address( pInstrumentStatus) + ) return 0 cdef extern int TraderSpi_OnRtnTradingNotice(self, CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) except -1: self.OnRtnTradingNotice( - None if pTradingNoticeInfo is NULL else ApiStructure.TradingNoticeInfoField.from_address( - pTradingNoticeInfo)) + None if pTradingNoticeInfo is NULL else ApiStructure.TradingNoticeInfoField.from_address( pTradingNoticeInfo) + ) return 0 -cdef extern int TraderSpi_OnRtnErrorConditionalOrder(self, - CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) except -1: +cdef extern int TraderSpi_OnRtnErrorConditionalOrder(self, CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) except -1: self.OnRtnErrorConditionalOrder( - None if pErrorConditionalOrder is NULL else ApiStructure.ErrorConditionalOrderField.from_address( - pErrorConditionalOrder)) + None if pErrorConditionalOrder is NULL else ApiStructure.ErrorConditionalOrderField.from_address( pErrorConditionalOrder) + ) return 0 cdef extern int TraderSpi_OnRtnExecOrder(self, CThostFtdcExecOrderField *pExecOrder) except -1: - self.OnRtnExecOrder(None if pExecOrder is NULL else ApiStructure.ExecOrderField.from_address( pExecOrder)) + self.OnRtnExecOrder( + None if pExecOrder is NULL else ApiStructure.ExecOrderField.from_address( pExecOrder) + ) return 0 -cdef extern int TraderSpi_OnErrRtnExecOrderInsert(self, CThostFtdcInputExecOrderField *pInputExecOrder, +cdef extern int TraderSpi_OnErrRtnExecOrderInsert(self, + CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnExecOrderInsert( None if pInputExecOrder is NULL else ApiStructure.InputExecOrderField.from_address( pInputExecOrder), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnExecOrderAction(self, CThostFtdcExecOrderActionField *pExecOrderAction, +cdef extern int TraderSpi_OnErrRtnExecOrderAction(self, + CThostFtdcExecOrderActionField *pExecOrderAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnExecOrderAction( None if pExecOrderAction is NULL else ApiStructure.ExecOrderActionField.from_address( pExecOrderAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnForQuoteInsert(self, CThostFtdcInputForQuoteField *pInputForQuote, +cdef extern int TraderSpi_OnErrRtnForQuoteInsert(self, + CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnForQuoteInsert( None if pInputForQuote is NULL else ApiStructure.InputForQuoteField.from_address( pInputForQuote), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 cdef extern int TraderSpi_OnRtnQuote(self, CThostFtdcQuoteField *pQuote) except -1: - self.OnRtnQuote(None if pQuote is NULL else ApiStructure.QuoteField.from_address( pQuote)) + self.OnRtnQuote( + None if pQuote is NULL else ApiStructure.QuoteField.from_address( pQuote) + ) return 0 -cdef extern int TraderSpi_OnErrRtnQuoteInsert(self, CThostFtdcInputQuoteField *pInputQuote, +cdef extern int TraderSpi_OnErrRtnQuoteInsert(self, + CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnQuoteInsert( None if pInputQuote is NULL else ApiStructure.InputQuoteField.from_address( pInputQuote), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnQuoteAction(self, CThostFtdcQuoteActionField *pQuoteAction, +cdef extern int TraderSpi_OnErrRtnQuoteAction(self, + CThostFtdcQuoteActionField *pQuoteAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnQuoteAction( None if pQuoteAction is NULL else ApiStructure.QuoteActionField.from_address( pQuoteAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 cdef extern int TraderSpi_OnRtnForQuoteRsp(self, CThostFtdcForQuoteRspField *pForQuoteRsp) except -1: self.OnRtnForQuoteRsp( - None if pForQuoteRsp is NULL else ApiStructure.ForQuoteRspField.from_address( pForQuoteRsp)) + None if pForQuoteRsp is NULL else ApiStructure.ForQuoteRspField.from_address( pForQuoteRsp) + ) return 0 -cdef extern int TraderSpi_OnRtnCFMMCTradingAccountToken(self, - CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) except -1: +cdef extern int TraderSpi_OnRtnCFMMCTradingAccountToken(self, CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) except -1: self.OnRtnCFMMCTradingAccountToken( - None if pCFMMCTradingAccountToken is NULL else ApiStructure.CFMMCTradingAccountTokenField.from_address( - pCFMMCTradingAccountToken)) + None if pCFMMCTradingAccountToken is NULL else ApiStructure.CFMMCTradingAccountTokenField.from_address( pCFMMCTradingAccountToken) + ) return 0 cdef extern int TraderSpi_OnRtnCombAction(self, CThostFtdcCombActionField *pCombAction) except -1: self.OnRtnCombAction( - None if pCombAction is NULL else ApiStructure.CombActionField.from_address( pCombAction)) + None if pCombAction is NULL else ApiStructure.CombActionField.from_address( pCombAction) + ) return 0 -cdef extern int TraderSpi_OnErrRtnCombActionInsert(self, CThostFtdcInputCombActionField *pInputCombAction, +cdef extern int TraderSpi_OnErrRtnCombActionInsert(self, + CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnCombActionInsert( None if pInputCombAction is NULL else ApiStructure.InputCombActionField.from_address( pInputCombAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnRspQryContractBank(self, CThostFtdcContractBankField *pContractBank, +cdef extern int TraderSpi_OnRspQryContractBank(self, + CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryContractBank( None if pContractBank is NULL else ApiStructure.ContractBankField.from_address( pContractBank), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryParkedOrder(self, CThostFtdcParkedOrderField *pParkedOrder, +cdef extern int TraderSpi_OnRspQryParkedOrder(self, + CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryParkedOrder( None if pParkedOrder is NULL else ApiStructure.ParkedOrderField.from_address( pParkedOrder), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryParkedOrderAction(self, CThostFtdcParkedOrderActionField *pParkedOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryParkedOrderAction(self, + CThostFtdcParkedOrderActionField *pParkedOrderAction, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryParkedOrderAction( - None if pParkedOrderAction is NULL else ApiStructure.ParkedOrderActionField.from_address( - pParkedOrderAction), + None if pParkedOrderAction is NULL else ApiStructure.ParkedOrderActionField.from_address( pParkedOrderAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryTradingNotice(self, CThostFtdcTradingNoticeField *pTradingNotice, +cdef extern int TraderSpi_OnRspQryTradingNotice(self, + CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryTradingNotice( None if pTradingNotice is NULL else ApiStructure.TradingNoticeField.from_address( pTradingNotice), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryBrokerTradingParams(self, CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryBrokerTradingParams(self, + CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryBrokerTradingParams( - None if pBrokerTradingParams is NULL else ApiStructure.BrokerTradingParamsField.from_address( - pBrokerTradingParams), + None if pBrokerTradingParams is NULL else ApiStructure.BrokerTradingParamsField.from_address( pBrokerTradingParams), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryBrokerTradingAlgos(self, CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryBrokerTradingAlgos(self, + CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryBrokerTradingAlgos( - None if pBrokerTradingAlgos is NULL else ApiStructure.BrokerTradingAlgosField.from_address( - pBrokerTradingAlgos), + None if pBrokerTradingAlgos is NULL else ApiStructure.BrokerTradingAlgosField.from_address( pBrokerTradingAlgos), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQueryCFMMCTradingAccountToken(self, CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQueryCFMMCTradingAccountToken( - None if pQueryCFMMCTradingAccountToken is NULL else ApiStructure.QueryCFMMCTradingAccountTokenField.from_address( - pQueryCFMMCTradingAccountToken), + None if pQueryCFMMCTradingAccountToken is NULL else ApiStructure.QueryCFMMCTradingAccountTokenField.from_address( pQueryCFMMCTradingAccountToken), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast) + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRtnFromBankToFutureByBank(self, CThostFtdcRspTransferField *pRspTransfer) except -1: self.OnRtnFromBankToFutureByBank( - None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer)) + None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer) + ) return 0 cdef extern int TraderSpi_OnRtnFromFutureToBankByBank(self, CThostFtdcRspTransferField *pRspTransfer) except -1: self.OnRtnFromFutureToBankByBank( - None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer)) + None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer) + ) return 0 cdef extern int TraderSpi_OnRtnRepealFromBankToFutureByBank(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromBankToFutureByBank( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 cdef extern int TraderSpi_OnRtnRepealFromFutureToBankByBank(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromFutureToBankByBank( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 cdef extern int TraderSpi_OnRtnFromBankToFutureByFuture(self, CThostFtdcRspTransferField *pRspTransfer) except -1: self.OnRtnFromBankToFutureByFuture( - None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer)) + None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer) + ) return 0 cdef extern int TraderSpi_OnRtnFromFutureToBankByFuture(self, CThostFtdcRspTransferField *pRspTransfer) except -1: self.OnRtnFromFutureToBankByFuture( - None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer)) + None if pRspTransfer is NULL else ApiStructure.RspTransferField.from_address( pRspTransfer) + ) return 0 -cdef extern int TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(self, - CThostFtdcRspRepealField *pRspRepeal) except -1: +cdef extern int TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromBankToFutureByFutureManual( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 -cdef extern int TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(self, - CThostFtdcRspRepealField *pRspRepeal) except -1: +cdef extern int TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromFutureToBankByFutureManual( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 -cdef extern int TraderSpi_OnRtnQueryBankBalanceByFuture(self, - CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) except -1: +cdef extern int TraderSpi_OnRtnQueryBankBalanceByFuture(self, CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) except -1: self.OnRtnQueryBankBalanceByFuture( - None if pNotifyQueryAccount is NULL else ApiStructure.NotifyQueryAccountField.from_address( - pNotifyQueryAccount)) + None if pNotifyQueryAccount is NULL else ApiStructure.NotifyQueryAccountField.from_address( pNotifyQueryAccount) + ) return 0 -cdef extern int TraderSpi_OnErrRtnBankToFutureByFuture(self, CThostFtdcReqTransferField *pReqTransfer, +cdef extern int TraderSpi_OnErrRtnBankToFutureByFuture(self, + CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnBankToFutureByFuture( None if pReqTransfer is NULL else ApiStructure.ReqTransferField.from_address( pReqTransfer), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnFutureToBankByFuture(self, CThostFtdcReqTransferField *pReqTransfer, +cdef extern int TraderSpi_OnErrRtnFutureToBankByFuture(self, + CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnFutureToBankByFuture( None if pReqTransfer is NULL else ApiStructure.ReqTransferField.from_address( pReqTransfer), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(self, CThostFtdcReqRepealField *pReqRepeal, +cdef extern int TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(self, + CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnRepealBankToFutureByFutureManual( None if pReqRepeal is NULL else ApiStructure.ReqRepealField.from_address( pReqRepeal), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(self, CThostFtdcReqRepealField *pReqRepeal, +cdef extern int TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(self, + CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnRepealFutureToBankByFutureManual( None if pReqRepeal is NULL else ApiStructure.ReqRepealField.from_address( pReqRepeal), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 -cdef extern int TraderSpi_OnErrRtnQueryBankBalanceByFuture(self, CThostFtdcReqQueryAccountField *pReqQueryAccount, +cdef extern int TraderSpi_OnErrRtnQueryBankBalanceByFuture(self, + CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnQueryBankBalanceByFuture( None if pReqQueryAccount is NULL else ApiStructure.ReqQueryAccountField.from_address( pReqQueryAccount), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 cdef extern int TraderSpi_OnRtnRepealFromBankToFutureByFuture(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromBankToFutureByFuture( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 cdef extern int TraderSpi_OnRtnRepealFromFutureToBankByFuture(self, CThostFtdcRspRepealField *pRspRepeal) except -1: self.OnRtnRepealFromFutureToBankByFuture( - None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal)) + None if pRspRepeal is NULL else ApiStructure.RspRepealField.from_address( pRspRepeal) + ) return 0 -cdef extern int TraderSpi_OnRspFromBankToFutureByFuture(self, CThostFtdcReqTransferField *pReqTransfer, +cdef extern int TraderSpi_OnRspFromBankToFutureByFuture(self, + CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspFromBankToFutureByFuture( None if pReqTransfer is NULL else ApiStructure.ReqTransferField.from_address( pReqTransfer), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspFromFutureToBankByFuture(self, CThostFtdcReqTransferField *pReqTransfer, +cdef extern int TraderSpi_OnRspFromFutureToBankByFuture(self, + CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspFromFutureToBankByFuture( None if pReqTransfer is NULL else ApiStructure.ReqTransferField.from_address( pReqTransfer), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQueryBankAccountMoneyByFuture(self, CThostFtdcReqQueryAccountField *pReqQueryAccount, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQueryBankAccountMoneyByFuture(self, + CThostFtdcReqQueryAccountField *pReqQueryAccount, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQueryBankAccountMoneyByFuture( None if pReqQueryAccount is NULL else ApiStructure.ReqQueryAccountField.from_address( pReqQueryAccount), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, bIsLast) + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), + nRequestID, + bIsLast + ) return 0 cdef extern int TraderSpi_OnRtnOpenAccountByBank(self, CThostFtdcOpenAccountField *pOpenAccount) except -1: self.OnRtnOpenAccountByBank( - None if pOpenAccount is NULL else ApiStructure.OpenAccountField.from_address( pOpenAccount)) + None if pOpenAccount is NULL else ApiStructure.OpenAccountField.from_address( pOpenAccount) + ) return 0 cdef extern int TraderSpi_OnRtnCancelAccountByBank(self, CThostFtdcCancelAccountField *pCancelAccount) except -1: self.OnRtnCancelAccountByBank( - None if pCancelAccount is NULL else ApiStructure.CancelAccountField.from_address( pCancelAccount)) + None if pCancelAccount is NULL else ApiStructure.CancelAccountField.from_address( pCancelAccount) + ) return 0 cdef extern int TraderSpi_OnRtnChangeAccountByBank(self, CThostFtdcChangeAccountField *pChangeAccount) except -1: self.OnRtnChangeAccountByBank( - None if pChangeAccount is NULL else ApiStructure.ChangeAccountField.from_address( pChangeAccount)) + None if pChangeAccount is NULL else ApiStructure.ChangeAccountField.from_address( pChangeAccount) + ) return 0 -cdef extern int TraderSpi_OnErrRtnBatchOrderAction(self, CThostFtdcBatchOrderActionField *pBatchOrderAction, +cdef extern int TraderSpi_OnErrRtnBatchOrderAction(self, + CThostFtdcBatchOrderActionField *pBatchOrderAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnBatchOrderAction( - None if pBatchOrderAction is NULL else ApiStructure.BatchOrderActionField.from_address( - pBatchOrderAction), - None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo)) + None if pBatchOrderAction is NULL else ApiStructure.BatchOrderActionField.from_address( pBatchOrderAction), + None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo) + ) return 0 cdef extern int TraderSpi_OnRtnBulletin(self, CThostFtdcBulletinField *pBulletin) except -1: - self.OnRtnBulletin(None if pBulletin is NULL else ApiStructure.BulletinField.from_address( pBulletin)) + self.OnRtnBulletin( + None if pBulletin is NULL else ApiStructure.BulletinField.from_address( pBulletin) + ) return 0 cdef extern int TraderSpi_OnRspQryInstrumentOrderCommRate(self, CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryInstrumentOrderCommRate( - None if pInstrumentOrderCommRate is NULL else ApiStructure.InstrumentOrderCommRateField.from_address( - pInstrumentOrderCommRate), + None if pInstrumentOrderCommRate is NULL else ApiStructure.InstrumentOrderCommRateField.from_address( pInstrumentOrderCommRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, bIsLast @@ -1792,121 +2051,140 @@ cdef extern int TraderSpi_OnRspQryInstrumentOrderCommRate(self, return 0 cdef extern int TraderSpi_OnRspQryMMOptionInstrCommRate(self, CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryMMOptionInstrCommRate( - None if pMMOptionInstrCommRate is NULL else ApiStructure.MMOptionInstrCommRateField.from_address( - pMMOptionInstrCommRate), + None if pMMOptionInstrCommRate is NULL else ApiStructure.MMOptionInstrCommRateField.from_address( pMMOptionInstrCommRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, bIsLast ) return 0 cdef extern int TraderSpi_OnRspBatchOrderAction(self, CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspBatchOrderAction( - None if pInputBatchOrderAction is NULL else ApiStructure.InputBatchOrderActionField.from_address( - pInputBatchOrderAction), + None if pInputBatchOrderAction is NULL else ApiStructure.InputBatchOrderActionField.from_address( pInputBatchOrderAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 cdef extern int TraderSpi_OnRspQryMMInstrumentCommissionRate(self, CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryMMInstrumentCommissionRate( - None if pRspInfo is NULL else ApiStructure.MMInstrumentCommissionRateField.from_address( - pMMInstrumentCommissionRate), + None if pRspInfo is NULL else ApiStructure.MMInstrumentCommissionRateField.from_address( pMMInstrumentCommissionRate), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 -cdef extern int TraderSpi_OnRspQryProductGroup(self, CThostFtdcProductGroupField *pProductGroup, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspQryProductGroup(self, + CThostFtdcProductGroupField *pProductGroup, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspQryProductGroup( None if pProductGroup is NULL else ApiStructure.ProductGroupField.from_address( pProductGroup), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #期权自对冲录入请求响应 -cdef extern int TraderSpi_OnRspOptionSelfCloseInsert(self, CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, +cdef extern int TraderSpi_OnRspOptionSelfCloseInsert(self, + CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspOptionSelfCloseInsert( - None if pInputOptionSelfClose is NULL else ApiStructure.InputOptionSelfCloseField.from_address( - pInputOptionSelfClose), + None if pInputOptionSelfClose is NULL else ApiStructure.InputOptionSelfCloseField.from_address( pInputOptionSelfClose), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #期权自对冲操作请求响应 cdef extern int TraderSpi_OnRspOptionSelfCloseAction(self, CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, cbool bIsLast) except -1: self.OnRspOptionSelfCloseAction( - None if pInputOptionSelfCloseAction is NULL else ApiStructure.InputOptionSelfCloseActionField.from_address( - pInputOptionSelfCloseAction), + None if pInputOptionSelfCloseAction is NULL else ApiStructure.InputOptionSelfCloseActionField.from_address( pInputOptionSelfCloseAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #请求查询资金账户响应 -cdef extern int TraderSpi_OnRspQrySecAgentTradingAccount(self, CThostFtdcTradingAccountField *pTradingAccount, +cdef extern int TraderSpi_OnRspQrySecAgentTradingAccount(self, + CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQrySecAgentTradingAccount( None if pTradingAccount is NULL else ApiStructure.TradingAccountField.from_address( pTradingAccount), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #请求查询二级代理商资金校验模式响应 -cdef extern int TraderSpi_OnRspQrySecAgentCheckMode(self, CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, +cdef extern int TraderSpi_OnRspQrySecAgentCheckMode(self, + CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQrySecAgentCheckMode( - None if pSecAgentCheckMode is NULL else ApiStructure.SecAgentCheckModeField.from_address( - pSecAgentCheckMode), + None if pSecAgentCheckMode is NULL else ApiStructure.SecAgentCheckModeField.from_address( pSecAgentCheckMode), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #请求查询期权自对冲响应 -cdef extern int TraderSpi_OnRspQryOptionSelfClose(self, CThostFtdcOptionSelfCloseField *pOptionSelfClose, +cdef extern int TraderSpi_OnRspQryOptionSelfClose(self, + CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryOptionSelfClose( None if pOptionSelfClose is NULL else ApiStructure.OptionSelfCloseField.from_address( pOptionSelfClose), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #请求查询投资单元响应 -cdef extern int TraderSpi_OnRspQryInvestUnit(self, CThostFtdcInvestUnitField *pInvestUnit, +cdef extern int TraderSpi_OnRspQryInvestUnit(self, + CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast) except -1: + int nRequestID, + cbool bIsLast) except -1: self.OnRspQryInvestUnit( None if pInvestUnit is NULL else ApiStructure.InvestUnitField.from_address( pInvestUnit), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), nRequestID, - bIsLast) + bIsLast + ) return 0 #期权自对冲通知 cdef extern int TraderSpi_OnRtnOptionSelfClose(self, CThostFtdcOptionSelfCloseField *pOptionSelfClose) except -1: self.OnRtnOptionSelfClose( - None if pOptionSelfClose is NULL else ApiStructure.OptionSelfCloseField.from_address( pOptionSelfClose), + None if pOptionSelfClose is NULL else ApiStructure.OptionSelfCloseField.from_address( pOptionSelfClose) ) return 0 #期权自对冲录入错误回报 @@ -1914,8 +2192,7 @@ cdef extern int TraderSpi_OnErrRtnOptionSelfCloseInsert(self, CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnOptionSelfCloseInsert( - None if pInputOptionSelfClose is NULL else ApiStructure.InputOptionSelfCloseField.from_address( - pInputOptionSelfClose), + None if pInputOptionSelfClose is NULL else ApiStructure.InputOptionSelfCloseField.from_address( pInputOptionSelfClose), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), ) return 0 @@ -1924,48 +2201,61 @@ cdef extern int TraderSpi_OnErrRtnOptionSelfCloseAction(self, CThostFtdcOptionSelfCloseActionField *pOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo) except -1: self.OnErrRtnOptionSelfCloseAction( - None if pOptionSelfCloseAction is NULL else ApiStructure.OptionSelfCloseActionField.from_address( - pOptionSelfCloseAction), + None if pOptionSelfCloseAction is NULL else ApiStructure.OptionSelfCloseActionField.from_address( pOptionSelfCloseAction), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), ) return 0 # 查询用户当前支持的认证模式的回复 -cdef extern int TraderSpi_OnRspUserAuthMethod(self, CThostFtdcRspUserAuthMethodField *pRspUserAuthMethod, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast): - +cdef extern int TraderSpi_OnRspUserAuthMethod(self, + CThostFtdcRspUserAuthMethodField *pRspUserAuthMethod, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: self.OnErrRtnOptionSelfCloseAction( None if pRspUserAuthMethod is NULL else ApiStructure.RspUserAuthMethodField.from_address( pRspUserAuthMethod), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast + nRequestID, + bIsLast ) return 0 # 获取图形验证码请求的回复 -cdef extern int TraderSpi_OnRspGenUserCaptcha(self, CThostFtdcRspGenUserCaptchaField *pRspGenUserCaptcha, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast): +cdef extern int TraderSpi_OnRspGenUserCaptcha(self, + CThostFtdcRspGenUserCaptchaField *pRspGenUserCaptcha, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: self.OnErrRtnOptionSelfCloseAction( None if pRspGenUserCaptcha is NULL else ApiStructure.RspGenUserCaptchaField.from_address( pRspGenUserCaptcha), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast + nRequestID, + bIsLast ) return 0 # 获取短信验证码请求的回复 -cdef extern int TraderSpi_OnRspGenUserText(self, CThostFtdcRspGenUserTextField *pRspGenUserText, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, cbool bIsLast): +cdef extern int TraderSpi_OnRspGenUserText(self, + CThostFtdcRspGenUserTextField *pRspGenUserText, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: self.OnErrRtnOptionSelfCloseAction( None if pRspGenUserText is NULL else ApiStructure.RspGenUserTextField.from_address( pRspGenUserText), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast + nRequestID, + bIsLast ) return 0 #请求查询二级代理商信息响应 -cdef extern int TraderSpi_OnRspQrySecAgentTradeInfo(self,CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, cbool bIsLast): - +cdef extern int TraderSpi_OnRspQrySecAgentTradeInfo(self, + CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, + CThostFtdcRspInfoField *pRspInfo, + int nRequestID, + cbool bIsLast) except -1: self.OnErrRtnOptionSelfCloseAction( None if pSecAgentTradeInfo is NULL else ApiStructure.SecAgentTradeInfoField.from_address( pSecAgentTradeInfo), None if pRspInfo is NULL else ApiStructure.RspInfoField.from_address( pRspInfo), - nRequestID, bIsLast + nRequestID, + bIsLast ) - return 0 \ No newline at end of file + return 0 diff --git a/ctpwrapper/__init__.py b/ctpwrapper/__init__.py index e837006..cbfda04 100644 --- a/ctpwrapper/__init__.py +++ b/ctpwrapper/__init__.py @@ -16,7 +16,7 @@ along with ctpwrapper. If not, see . """ -__version__ = "6.3.19" +__version__ = "6.3.19.1" __date__ = "2020-01-06" from ctpwrapper.Md import MdApiPy diff --git a/ctpwrapper/base.py b/ctpwrapper/base.py index cbf1024..703c347 100644 --- a/ctpwrapper/base.py +++ b/ctpwrapper/base.py @@ -21,6 +21,13 @@ class Base(ctypes.Structure): + def __getattribute__(self, item): + value = super().__getattribute__(item) + if isinstance(value, bytes): + return value.decode("gbk") + else: + return value + def _to_bytes(self, value): """ :return: @@ -44,15 +51,12 @@ def to_dict(self): results = {} for key, _ in self._fields_: _value = getattr(self, key) - if isinstance(_value, bytes): - results[key] = _value.decode("gbk") - else: - results[key] = _value + results[key] = _value return results def __repr__(self): """ :return: """ - items = ["%s:%s" % (item, getattr(self, item)) for item, value in self._fields_] - return "%s<%s>" % (self.__class__.__name__, ",".join(items)) + items = ["{0}({1})".format(item, getattr(self, item)) for item, value in self._fields_] + return "{0}<{1}>".format(self.__class__.__name__, ",".join(items)) diff --git a/ctpwrapper/cppheader/CMdAPI.h b/ctpwrapper/cppheader/CMdAPI.h index f5ba693..e64d0f3 100644 --- a/ctpwrapper/cppheader/CMdAPI.h +++ b/ctpwrapper/cppheader/CMdAPI.h @@ -25,88 +25,100 @@ along with ctpwrapper. If not, see . static inline int MdSpi_OnFrontConnected(PyObject *); + static inline int MdSpi_OnFrontDisconnected(PyObject *, int); + static inline int MdSpi_OnHeartBeatWarning(PyObject *, int); + static inline int MdSpi_OnRspUserLogin(PyObject *, CThostFtdcRspUserLoginField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspUserLogout(PyObject *, CThostFtdcUserLogoutField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspError(PyObject *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspSubMarketData(PyObject *, CThostFtdcSpecificInstrumentField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspUnSubMarketData(PyObject *, CThostFtdcSpecificInstrumentField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspSubForQuoteRsp(PyObject *, CThostFtdcSpecificInstrumentField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRspUnSubForQuoteRsp(PyObject *, CThostFtdcSpecificInstrumentField *, CThostFtdcRspInfoField *, int, bool); + static inline int MdSpi_OnRtnDepthMarketData(PyObject *, CThostFtdcDepthMarketDataField *); + static inline int MdSpi_OnRtnForQuoteRsp(PyObject *, CThostFtdcForQuoteRspField *); + static inline int MdSpi_OnRspQryMulticastInstrument(PyObject *, CThostFtdcMulticastInstrumentField *, CThostFtdcRspInfoField *, int, bool); #define Python_GIL(func) \ - do { \ - PyGILState_STATE gil_state = PyGILState_Ensure(); \ - if ((func) == -1) PyErr_Print(); \ - PyGILState_Release(gil_state); \ - } while (false) + do { \ + PyGILState_STATE gil_state = PyGILState_Ensure(); \ + if ((func) == -1) PyErr_Print(); \ + PyGILState_Release(gil_state); \ + } while (false) class CMdSpi : public CThostFtdcMdSpi { public: - CMdSpi(PyObject *obj):self(obj) {}; + CMdSpi(PyObject *obj) : self(obj) {}; - virtual ~CMdSpi() {}; + virtual ~CMdSpi() {}; - virtual void OnFrontConnected() { - Python_GIL(MdSpi_OnFrontConnected(self)); - }; + virtual void OnFrontConnected() { + Python_GIL(MdSpi_OnFrontConnected(self)); + }; - virtual void OnFrontDisconnected(int nReason) { - Python_GIL(MdSpi_OnFrontDisconnected(self, nReason)); - }; + virtual void OnFrontDisconnected(int nReason) { + Python_GIL(MdSpi_OnFrontDisconnected(self, nReason)); + }; - virtual void OnHeartBeatWarning(int nTimeLapse) { - Python_GIL(MdSpi_OnHeartBeatWarning(self, nTimeLapse)); - }; + virtual void OnHeartBeatWarning(int nTimeLapse) { + Python_GIL(MdSpi_OnHeartBeatWarning(self, nTimeLapse)); + }; - virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspUserLogout(self, pUserLogout, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspUserLogout(self, pUserLogout, pRspInfo, nRequestID, bIsLast)); + }; virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { Python_GIL(MdSpi_OnRspQryMulticastInstrument(self, pMulticastInstrument, pRspInfo, nRequestID, bIsLast)); }; - virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspError(self, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspError(self, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspUnSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspUnSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspSubForQuoteRsp(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspSubForQuoteRsp(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(MdSpi_OnRspUnSubForQuoteRsp(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(MdSpi_OnRspUnSubForQuoteRsp(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast)); + }; - virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) { - Python_GIL(MdSpi_OnRtnDepthMarketData(self, pDepthMarketData)); - }; + virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) { + Python_GIL(MdSpi_OnRtnDepthMarketData(self, pDepthMarketData)); + }; - virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) { - Python_GIL(MdSpi_OnRtnForQuoteRsp(self, pForQuoteRsp)); - }; + virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) { + Python_GIL(MdSpi_OnRtnForQuoteRsp(self, pForQuoteRsp)); + }; private: - PyObject *self; + PyObject *self; }; #endif /* CMDAPI_H */ \ No newline at end of file diff --git a/ctpwrapper/cppheader/CTraderAPI.h b/ctpwrapper/cppheader/CTraderAPI.h index 6f0a210..5aae100 100644 --- a/ctpwrapper/cppheader/CTraderAPI.h +++ b/ctpwrapper/cppheader/CTraderAPI.h @@ -24,126 +24,239 @@ along with ctpwrapper. If not, see . #include "ThostFtdcTraderApi.h" static inline int TraderSpi_OnFrontConnected(PyObject *); + static inline int TraderSpi_OnFrontDisconnected(PyObject *, int); + static inline int TraderSpi_OnHeartBeatWarning(PyObject *, int); + static inline int TraderSpi_OnRspAuthenticate(PyObject *, CThostFtdcRspAuthenticateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspUserLogin(PyObject *, CThostFtdcRspUserLoginField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspUserLogout(PyObject *, CThostFtdcUserLogoutField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspUserPasswordUpdate(PyObject *, CThostFtdcUserPasswordUpdateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspTradingAccountPasswordUpdate(PyObject *, CThostFtdcTradingAccountPasswordUpdateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspOrderInsert(PyObject *, CThostFtdcInputOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspParkedOrderInsert(PyObject *, CThostFtdcParkedOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspParkedOrderAction(PyObject *, CThostFtdcParkedOrderActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspOrderAction(PyObject *, CThostFtdcInputOrderActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQueryMaxOrderVolume(PyObject *, CThostFtdcQueryMaxOrderVolumeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspSettlementInfoConfirm(PyObject *, CThostFtdcSettlementInfoConfirmField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspRemoveParkedOrder(PyObject *, CThostFtdcRemoveParkedOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspRemoveParkedOrderAction(PyObject *, CThostFtdcRemoveParkedOrderActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspExecOrderInsert(PyObject *, CThostFtdcInputExecOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspExecOrderAction(PyObject *, CThostFtdcInputExecOrderActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspForQuoteInsert(PyObject *, CThostFtdcInputForQuoteField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQuoteInsert(PyObject *, CThostFtdcInputQuoteField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQuoteAction(PyObject *, CThostFtdcInputQuoteActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspCombActionInsert(PyObject *, CThostFtdcInputCombActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryOrder(PyObject *, CThostFtdcOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTrade(PyObject *, CThostFtdcTradeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestorPosition(PyObject *, CThostFtdcInvestorPositionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTradingAccount(PyObject *, CThostFtdcTradingAccountField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestor(PyObject *, CThostFtdcInvestorField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTradingCode(PyObject *, CThostFtdcTradingCodeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInstrumentMarginRate(PyObject *, CThostFtdcInstrumentMarginRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInstrumentCommissionRate(PyObject *, CThostFtdcInstrumentCommissionRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryExchange(PyObject *, CThostFtdcExchangeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryProduct(PyObject *, CThostFtdcProductField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInstrument(PyObject *, CThostFtdcInstrumentField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryDepthMarketData(PyObject *, CThostFtdcDepthMarketDataField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQrySettlementInfo(PyObject *, CThostFtdcSettlementInfoField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTransferBank(PyObject *, CThostFtdcTransferBankField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestorPositionDetail(PyObject *, CThostFtdcInvestorPositionDetailField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryNotice(PyObject *, CThostFtdcNoticeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQrySettlementInfoConfirm(PyObject *, CThostFtdcSettlementInfoConfirmField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestorPositionCombineDetail(PyObject *, CThostFtdcInvestorPositionCombineDetailField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryCFMMCTradingAccountKey(PyObject *, CThostFtdcCFMMCTradingAccountKeyField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryEWarrantOffset(PyObject *, CThostFtdcEWarrantOffsetField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestorProductGroupMargin(PyObject *, CThostFtdcInvestorProductGroupMarginField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryExchangeMarginRate(PyObject *, CThostFtdcExchangeMarginRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryExchangeMarginRateAdjust(PyObject *, CThostFtdcExchangeMarginRateAdjustField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryExchangeRate(PyObject *, CThostFtdcExchangeRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQrySecAgentACIDMap(PyObject *, CThostFtdcSecAgentACIDMapField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryProductExchRate(PyObject *, CThostFtdcProductExchRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryOptionInstrTradeCost(PyObject *, CThostFtdcOptionInstrTradeCostField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryOptionInstrCommRate(PyObject *, CThostFtdcOptionInstrCommRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryExecOrder(PyObject *, CThostFtdcExecOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryForQuote(PyObject *, CThostFtdcForQuoteField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryQuote(PyObject *, CThostFtdcQuoteField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryCombInstrumentGuard(PyObject *, CThostFtdcCombInstrumentGuardField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryCombAction(PyObject *, CThostFtdcCombActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTransferSerial(PyObject *, CThostFtdcTransferSerialField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryAccountregister(PyObject *, CThostFtdcAccountregisterField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspError(PyObject *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRtnOrder(PyObject *, CThostFtdcOrderField *); + static inline int TraderSpi_OnRtnTrade(PyObject *, CThostFtdcTradeField *); + static inline int TraderSpi_OnErrRtnOrderInsert(PyObject *, CThostFtdcInputOrderField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnOrderAction(PyObject *, CThostFtdcOrderActionField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRtnInstrumentStatus(PyObject *, CThostFtdcInstrumentStatusField *); + static inline int TraderSpi_OnRtnTradingNotice(PyObject *, CThostFtdcTradingNoticeInfoField *); + static inline int TraderSpi_OnRtnErrorConditionalOrder(PyObject *, CThostFtdcErrorConditionalOrderField *); + static inline int TraderSpi_OnRtnExecOrder(PyObject *, CThostFtdcExecOrderField *); + static inline int TraderSpi_OnErrRtnExecOrderInsert(PyObject *, CThostFtdcInputExecOrderField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnExecOrderAction(PyObject *, CThostFtdcExecOrderActionField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnForQuoteInsert(PyObject *, CThostFtdcInputForQuoteField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRtnQuote(PyObject *, CThostFtdcQuoteField *); + static inline int TraderSpi_OnErrRtnQuoteInsert(PyObject *, CThostFtdcInputQuoteField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnQuoteAction(PyObject *, CThostFtdcQuoteActionField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRtnForQuoteRsp(PyObject *, CThostFtdcForQuoteRspField *); + static inline int TraderSpi_OnRtnCFMMCTradingAccountToken(PyObject *, CThostFtdcCFMMCTradingAccountTokenField *); + static inline int TraderSpi_OnRtnCombAction(PyObject *, CThostFtdcCombActionField *); + static inline int TraderSpi_OnErrRtnCombActionInsert(PyObject *, CThostFtdcInputCombActionField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRspQryContractBank(PyObject *, CThostFtdcContractBankField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryParkedOrder(PyObject *, CThostFtdcParkedOrderField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryParkedOrderAction(PyObject *, CThostFtdcParkedOrderActionField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryTradingNotice(PyObject *, CThostFtdcTradingNoticeField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryBrokerTradingParams(PyObject *, CThostFtdcBrokerTradingParamsField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryBrokerTradingAlgos(PyObject *, CThostFtdcBrokerTradingAlgosField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQueryCFMMCTradingAccountToken(PyObject *, CThostFtdcQueryCFMMCTradingAccountTokenField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRtnFromBankToFutureByBank(PyObject *, CThostFtdcRspTransferField *); + static inline int TraderSpi_OnRtnFromFutureToBankByBank(PyObject *, CThostFtdcRspTransferField *); + static inline int TraderSpi_OnRtnRepealFromBankToFutureByBank(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRtnRepealFromFutureToBankByBank(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRtnFromBankToFutureByFuture(PyObject *, CThostFtdcRspTransferField *); + static inline int TraderSpi_OnRtnFromFutureToBankByFuture(PyObject *, CThostFtdcRspTransferField *); + static inline int TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRtnQueryBankBalanceByFuture(PyObject *, CThostFtdcNotifyQueryAccountField *); + static inline int TraderSpi_OnErrRtnBankToFutureByFuture(PyObject *, CThostFtdcReqTransferField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnFutureToBankByFuture(PyObject *, CThostFtdcReqTransferField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(PyObject *, CThostFtdcReqRepealField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(PyObject *, CThostFtdcReqRepealField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnErrRtnQueryBankBalanceByFuture(PyObject *, CThostFtdcReqQueryAccountField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRtnRepealFromBankToFutureByFuture(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRtnRepealFromFutureToBankByFuture(PyObject *, CThostFtdcRspRepealField *); + static inline int TraderSpi_OnRspFromBankToFutureByFuture(PyObject *, CThostFtdcReqTransferField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspFromFutureToBankByFuture(PyObject *, CThostFtdcReqTransferField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQueryBankAccountMoneyByFuture(PyObject *, CThostFtdcReqQueryAccountField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRtnOpenAccountByBank(PyObject *, CThostFtdcOpenAccountField *); + static inline int TraderSpi_OnRtnCancelAccountByBank(PyObject *, CThostFtdcCancelAccountField *); + static inline int TraderSpi_OnRtnChangeAccountByBank(PyObject *, CThostFtdcChangeAccountField *); static inline int TraderSpi_OnErrRtnBatchOrderAction(PyObject *, CThostFtdcBatchOrderActionField *, CThostFtdcRspInfoField *); + static inline int TraderSpi_OnRtnBulletin(PyObject *, CThostFtdcBulletinField *); -static inline int TraderSpi_OnRspQryInstrumentOrderCommRate(PyObject *,CThostFtdcInstrumentOrderCommRateField *, CThostFtdcRspInfoField *, int, bool); -static inline int TraderSpi_OnRspQryMMOptionInstrCommRate(PyObject *,CThostFtdcMMOptionInstrCommRateField *, CThostFtdcRspInfoField *, int, bool); + +static inline int TraderSpi_OnRspQryInstrumentOrderCommRate(PyObject *, CThostFtdcInstrumentOrderCommRateField *, CThostFtdcRspInfoField *, int, bool); + +static inline int TraderSpi_OnRspQryMMOptionInstrCommRate(PyObject *, CThostFtdcMMOptionInstrCommRateField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspBatchOrderAction(PyObject *, CThostFtdcInputBatchOrderActionField *, CThostFtdcRspInfoField *, int, bool); -static inline int TraderSpi_OnRspQryMMInstrumentCommissionRate(PyObject *, CThostFtdcMMInstrumentCommissionRateField *,CThostFtdcRspInfoField *, int, bool); -static inline int TraderSpi_OnRspQryProductGroup(PyObject *, CThostFtdcProductGroupField *,CThostFtdcRspInfoField *, int, bool); + +static inline int TraderSpi_OnRspQryMMInstrumentCommissionRate(PyObject *, CThostFtdcMMInstrumentCommissionRateField *, CThostFtdcRspInfoField *, int, bool); + +static inline int TraderSpi_OnRspQryProductGroup(PyObject *, CThostFtdcProductGroupField *, CThostFtdcRspInfoField *, int, bool); static inline int TraderSpi_OnRspOptionSelfCloseInsert(PyObject *, CThostFtdcInputOptionSelfCloseField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspOptionSelfCloseAction(PyObject *, CThostFtdcInputOptionSelfCloseActionField *, CThostFtdcRspInfoField *, int, bool); static inline int TraderSpi_OnRspQrySecAgentTradingAccount(PyObject *, CThostFtdcTradingAccountField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQrySecAgentCheckMode(PyObject *, CThostFtdcSecAgentCheckModeField *, CThostFtdcRspInfoField *, int, bool); static inline int TraderSpi_OnRspQryOptionSelfClose(PyObject *, CThostFtdcOptionSelfCloseField *, CThostFtdcRspInfoField *, int, bool); + static inline int TraderSpi_OnRspQryInvestUnit(PyObject *, CThostFtdcInvestUnitField *, CThostFtdcRspInfoField *, int, bool); static inline int TraderSpi_OnRtnOptionSelfClose(PyObject *, CThostFtdcOptionSelfCloseField *); @@ -165,17 +278,17 @@ static inline int TraderSpi_OnRspGenUserText(PyObject *, CThostFtdcRspGenUserTex #define Python_GIL(func) \ - do { \ - PyGILState_STATE gil_state = PyGILState_Ensure(); \ - if ((func) == -1) PyErr_Print(); \ - PyGILState_Release(gil_state); \ - } while (false) + do { \ + PyGILState_STATE gil_state = PyGILState_Ensure(); \ + if ((func) == -1) PyErr_Print(); \ + PyGILState_Release(gil_state); \ + } while (false) -class CTraderSpi: public CThostFtdcTraderSpi { +class CTraderSpi : public CThostFtdcTraderSpi { public: - CTraderSpi(PyObject *obj):self(obj) {}; + CTraderSpi(PyObject *obj) : self(obj) {}; virtual ~CTraderSpi() {}; @@ -192,707 +305,643 @@ class CTraderSpi: public CThostFtdcTraderSpi { /// 0x2002 发送心跳失败 /// 0x2003 收到错误报文 virtual void OnFrontDisconnected(int nReason) { - Python_GIL(TraderSpi_OnFrontDisconnected(self,nReason)); + Python_GIL(TraderSpi_OnFrontDisconnected(self, nReason)); }; ///心跳超时警告。当长时间未收到报文时,该方法被调用。 ///@param nTimeLapse 距离上次接收报文的时间 virtual void OnHeartBeatWarning(int nTimeLapse) { - Python_GIL(TraderSpi_OnHeartBeatWarning(self,nTimeLapse)); + Python_GIL(TraderSpi_OnHeartBeatWarning(self, nTimeLapse)); }; ///客户端认证响应 - virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo,int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspAuthenticate(self,pRspAuthenticateField,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspAuthenticate(self, pRspAuthenticateField, pRspInfo, nRequestID, bIsLast)); }; ///登录请求响应 virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspUserLogin(self,pRspUserLogin,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast)); }; ///登出请求响应 - virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID,bool bIsLast) { - Python_GIL(TraderSpi_OnRspUserLogout(self,pUserLogout,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspUserLogout(self, pUserLogout, pRspInfo, nRequestID, bIsLast)); }; ///用户口令更新请求响应 virtual void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspUserPasswordUpdate(self,pUserPasswordUpdate,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspUserPasswordUpdate(self, pUserPasswordUpdate, pRspInfo, nRequestID, bIsLast)); }; ///资金账户口令更新请求响应 virtual void OnRspTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspTradingAccountPasswordUpdate(self,pTradingAccountPasswordUpdate,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspTradingAccountPasswordUpdate(self, pTradingAccountPasswordUpdate, pRspInfo, nRequestID, bIsLast)); }; ///报单录入请求响应 - virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspOrderInsert(self,pInputOrder,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspOrderInsert(self, pInputOrder, pRspInfo, nRequestID, bIsLast)); + }; ///预埋单录入请求响应 - virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspParkedOrderInsert(self,pParkedOrder,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspParkedOrderInsert(self, pParkedOrder, pRspInfo, nRequestID, bIsLast)); + }; ///预埋撤单录入请求响应 - virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspParkedOrderAction(self,pParkedOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspParkedOrderAction(self, pParkedOrderAction, pRspInfo, nRequestID, bIsLast)); + }; ///报单操作请求响应 - virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspOrderAction(self,pInputOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspOrderAction(self, pInputOrderAction, pRspInfo, nRequestID, bIsLast)); + }; ///查询最大报单数量响应 - virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQueryMaxOrderVolume(self,pQueryMaxOrderVolume,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQueryMaxOrderVolume(self, pQueryMaxOrderVolume, pRspInfo, nRequestID, bIsLast)); + }; ///投资者结算结果确认响应 - virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspSettlementInfoConfirm(self,pSettlementInfoConfirm,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspSettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast)); + }; ///删除预埋单响应 - virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspRemoveParkedOrder(self,pRemoveParkedOrder,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspRemoveParkedOrder(self, pRemoveParkedOrder, pRspInfo, nRequestID, bIsLast)); + }; ///删除预埋撤单响应 - virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspRemoveParkedOrderAction(self,pRemoveParkedOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspRemoveParkedOrderAction(self, pRemoveParkedOrderAction, pRspInfo, nRequestID, bIsLast)); + }; ///执行宣告录入请求响应 - virtual void OnRspExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspExecOrderInsert(self,pInputExecOrder,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspExecOrderInsert(self, pInputExecOrder, pRspInfo, nRequestID, bIsLast)); + }; ///执行宣告操作请求响应 - virtual void OnRspExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspExecOrderAction(self,pInputExecOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspExecOrderAction(self, pInputExecOrderAction, pRspInfo, nRequestID, bIsLast)); + }; ///询价录入请求响应 - virtual void OnRspForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspForQuoteInsert(self,pInputForQuote,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspForQuoteInsert(self, pInputForQuote, pRspInfo, nRequestID, bIsLast)); + }; ///报价录入请求响应 - virtual void OnRspQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQuoteInsert(self,pInputQuote,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQuoteInsert(self, pInputQuote, pRspInfo, nRequestID, bIsLast)); + }; ///报价操作请求响应 - virtual void OnRspQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQuoteAction(self,pInputQuoteAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQuoteAction(self, pInputQuoteAction, pRspInfo, nRequestID, bIsLast)); + }; ///批量报单操作请求响应 - virtual void OnRspBatchOrderAction(CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspBatchOrderAction(self,pInputBatchOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspBatchOrderAction(CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspBatchOrderAction(self, pInputBatchOrderAction, pRspInfo, nRequestID, bIsLast)); + }; + ///期权自对冲录入请求响应 - virtual void OnRspOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspOptionSelfCloseInsert(self,pInputOptionSelfClose,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspOptionSelfCloseInsert(self, pInputOptionSelfClose, pRspInfo, nRequestID, bIsLast)); + }; ///期权自对冲操作请求响应 - virtual void OnRspOptionSelfCloseAction(CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspOptionSelfCloseAction(self,pInputOptionSelfCloseAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspOptionSelfCloseAction(CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspOptionSelfCloseAction(self, pInputOptionSelfCloseAction, pRspInfo, nRequestID, bIsLast)); + }; ///申请组合录入请求响应 - virtual void OnRspCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspCombActionInsert(self,pInputCombAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspCombActionInsert(self, pInputCombAction, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询报单响应 virtual void OnRspQryOrder(CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryOrder(self,pOrder,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspQryOrder(self, pOrder, pRspInfo, nRequestID, bIsLast)); }; ///请求查询成交响应 virtual void OnRspQryTrade(CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTrade(self,pTrade,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspQryTrade(self, pTrade, pRspInfo, nRequestID, bIsLast)); }; ///请求查询投资者持仓响应 - virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestorPosition(self,pInvestorPosition,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestorPosition(self, pInvestorPosition, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询资金账户响应 - virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTradingAccount(self,pTradingAccount,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryTradingAccount(self, pTradingAccount, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询投资者响应 - virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestor(self,pInvestor,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestor(self, pInvestor, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询交易编码响应 - virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTradingCode(self,pTradingCode,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryTradingCode(self, pTradingCode, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询合约保证金率响应 - virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInstrumentMarginRate(self,pInstrumentMarginRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInstrumentMarginRate(self, pInstrumentMarginRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询合约手续费率响应 - virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInstrumentCommissionRate(self,pInstrumentCommissionRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInstrumentCommissionRate(self, pInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询交易所响应 - virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryExchange(self,pExchange,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryExchange(self, pExchange, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询产品响应 - virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryProduct(self,pProduct,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryProduct(self, pProduct, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询合约响应 - virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInstrument(self,pInstrument,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInstrument(self, pInstrument, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询行情响应 - virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryDepthMarketData(self,pDepthMarketData,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryDepthMarketData(self, pDepthMarketData, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询投资者结算结果响应 - virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySettlementInfo(self,pSettlementInfo,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySettlementInfo(self, pSettlementInfo, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询转帐银行响应 - virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTransferBank(self,pTransferBank,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryTransferBank(self, pTransferBank, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询投资者持仓明细响应 - virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestorPositionDetail(self,pInvestorPositionDetail,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestorPositionDetail(self, pInvestorPositionDetail, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询客户通知响应 virtual void OnRspQryNotice(CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryNotice(self,pNotice,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspQryNotice(self, pNotice, pRspInfo, nRequestID, bIsLast)); }; ///请求查询结算信息确认响应 - virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySettlementInfoConfirm(self,pSettlementInfoConfirm,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询投资者持仓明细响应 - virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestorPositionCombineDetail(self,pInvestorPositionCombineDetail,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestorPositionCombineDetail(self, pInvestorPositionCombineDetail, pRspInfo, nRequestID, bIsLast)); + }; ///查询保证金监管系统经纪公司资金账户密钥响应 - virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryCFMMCTradingAccountKey(self,pCFMMCTradingAccountKey,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryCFMMCTradingAccountKey(self, pCFMMCTradingAccountKey, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询仓单折抵信息响应 - virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryEWarrantOffset(self,pEWarrantOffset,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryEWarrantOffset(self, pEWarrantOffset, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询投资者品种/跨品种保证金响应 - virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestorProductGroupMargin(self,pInvestorProductGroupMargin,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestorProductGroupMargin(self, pInvestorProductGroupMargin, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询交易所保证金率响应 - virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryExchangeMarginRate(self,pExchangeMarginRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryExchangeMarginRate(self, pExchangeMarginRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询交易所调整保证金率响应 - virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryExchangeMarginRateAdjust(self,pExchangeMarginRateAdjust,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryExchangeMarginRateAdjust(self, pExchangeMarginRateAdjust, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询汇率响应 - virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryExchangeRate(self,pExchangeRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryExchangeRate(self, pExchangeRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询二级代理操作员银期权限响应 virtual void - OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySecAgentACIDMap(self,pSecAgentACIDMap,pRspInfo,nRequestID,bIsLast)); - }; + OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySecAgentACIDMap(self, pSecAgentACIDMap, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询产品报价汇率 - virtual void OnRspQryProductExchRate(CThostFtdcProductExchRateField *pProductExchRate, CThostFtdcRspInfoField *pRspInfo,int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryProductExchRate(self,pProductExchRate,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspQryProductExchRate(CThostFtdcProductExchRateField *pProductExchRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryProductExchRate(self, pProductExchRate, pRspInfo, nRequestID, bIsLast)); }; ///请求查询产品组 - virtual void OnRspQryProductGroup(CThostFtdcProductGroupField *pProductGroup, CThostFtdcRspInfoField *pRspInfo, int nRequestID,bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryProductGroup(self,pProductGroup,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspQryProductGroup(CThostFtdcProductGroupField *pProductGroup, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryProductGroup(self, pProductGroup, pRspInfo, nRequestID, bIsLast)); }; ///请求查询做市商合约手续费率响应 - virtual void OnRspQryMMInstrumentCommissionRate(CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryMMInstrumentCommissionRate(self,pMMInstrumentCommissionRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryMMInstrumentCommissionRate(CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryMMInstrumentCommissionRate(self, pMMInstrumentCommissionRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询做市商期权合约手续费响应 - virtual void OnRspQryMMOptionInstrCommRate(CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryMMOptionInstrCommRate(self,pMMOptionInstrCommRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryMMOptionInstrCommRate(CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryMMOptionInstrCommRate(self, pMMOptionInstrCommRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询报单手续费响应 - virtual void OnRspQryInstrumentOrderCommRate(CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInstrumentOrderCommRate(self,pInstrumentOrderCommRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryInstrumentOrderCommRate(CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInstrumentOrderCommRate(self, pInstrumentOrderCommRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询资金账户响应 - virtual void OnRspQrySecAgentTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySecAgentTradingAccount(self,pTradingAccount,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQrySecAgentTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySecAgentTradingAccount(self, pTradingAccount, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询二级代理商资金校验模式响应 - virtual void OnRspQrySecAgentCheckMode(CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySecAgentCheckMode(self,pSecAgentCheckMode,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQrySecAgentCheckMode(CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySecAgentCheckMode(self, pSecAgentCheckMode, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询期权交易成本响应 - virtual void OnRspQryOptionInstrTradeCost(CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryOptionInstrTradeCost(self,pOptionInstrTradeCost,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryOptionInstrTradeCost(CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryOptionInstrTradeCost(self, pOptionInstrTradeCost, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询期权合约手续费响应 - virtual void OnRspQryOptionInstrCommRate(CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryOptionInstrCommRate(self,pOptionInstrCommRate,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryOptionInstrCommRate(CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryOptionInstrCommRate(self, pOptionInstrCommRate, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询执行宣告响应 - virtual void OnRspQryExecOrder(CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryExecOrder(self,pExecOrder,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryExecOrder(CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryExecOrder(self, pExecOrder, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询询价响应 - virtual void OnRspQryForQuote(CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryForQuote(self,pForQuote,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryForQuote(CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryForQuote(self, pForQuote, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询报价响应 virtual void OnRspQryQuote(CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryQuote(self,pQuote,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspQryQuote(self, pQuote, pRspInfo, nRequestID, bIsLast)); }; ///请求查询期权自对冲响应 - virtual void OnRspQryOptionSelfClose(CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryOptionSelfClose(self,pOptionSelfClose,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspQryOptionSelfClose(CThostFtdcOptionSelfCloseField *pOptionSelfClose, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryOptionSelfClose(self, pOptionSelfClose, pRspInfo, nRequestID, bIsLast)); - }; + }; ///请求查询投资单元响应 - virtual void OnRspQryInvestUnit(CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryInvestUnit(self,pInvestUnit,pRspInfo,nRequestID,bIsLast)); + virtual void OnRspQryInvestUnit(CThostFtdcInvestUnitField *pInvestUnit, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryInvestUnit(self, pInvestUnit, pRspInfo, nRequestID, bIsLast)); - }; + }; ///请求查询组合合约安全系数响应 - virtual void OnRspQryCombInstrumentGuard(CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryCombInstrumentGuard(self,pCombInstrumentGuard,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryCombInstrumentGuard(CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryCombInstrumentGuard(self, pCombInstrumentGuard, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询申请组合响应 virtual void - OnRspQryCombAction(CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryCombAction(self,pCombAction,pRspInfo,nRequestID,bIsLast)); - }; + OnRspQryCombAction(CThostFtdcCombActionField *pCombAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryCombAction(self, pCombAction, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询转帐流水响应 virtual void - OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTransferSerial(self,pTransferSerial,pRspInfo,nRequestID,bIsLast)); - }; + OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryTransferSerial(self, pTransferSerial, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询银期签约关系响应 virtual void - OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryAccountregister(self,pAccountregister,pRspInfo,nRequestID,bIsLast)); - }; + OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryAccountregister(self, pAccountregister, pRspInfo, nRequestID, bIsLast)); + }; ///错误应答 virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspError(self,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspError(self, pRspInfo, nRequestID, bIsLast)); }; ///报单通知 virtual void OnRtnOrder(CThostFtdcOrderField *pOrder) { - Python_GIL(TraderSpi_OnRtnOrder(self,pOrder)); + Python_GIL(TraderSpi_OnRtnOrder(self, pOrder)); }; ///成交通知 virtual void OnRtnTrade(CThostFtdcTradeField *pTrade) { - Python_GIL(TraderSpi_OnRtnTrade(self,pTrade)); + Python_GIL(TraderSpi_OnRtnTrade(self, pTrade)); }; ///报单录入错误回报 virtual void OnErrRtnOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnOrderInsert(self,pInputOrder,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnOrderInsert(self, pInputOrder, pRspInfo)); }; ///报单操作错误回报 virtual void OnErrRtnOrderAction(CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnOrderAction(self,pOrderAction,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnOrderAction(self, pOrderAction, pRspInfo)); }; ///合约交易状态通知 virtual void OnRtnInstrumentStatus(CThostFtdcInstrumentStatusField *pInstrumentStatus) { - Python_GIL(TraderSpi_OnRtnInstrumentStatus(self,pInstrumentStatus)); + Python_GIL(TraderSpi_OnRtnInstrumentStatus(self, pInstrumentStatus)); }; ///交易所公告通知 virtual void OnRtnBulletin(CThostFtdcBulletinField *pBulletin) { - Python_GIL(TraderSpi_OnRtnBulletin(self,pBulletin)); + Python_GIL(TraderSpi_OnRtnBulletin(self, pBulletin)); }; ///交易通知 virtual void OnRtnTradingNotice(CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) { - Python_GIL(TraderSpi_OnRtnTradingNotice(self,pTradingNoticeInfo)); + Python_GIL(TraderSpi_OnRtnTradingNotice(self, pTradingNoticeInfo)); }; ///提示条件单校验错误 virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) { - Python_GIL(TraderSpi_OnRtnErrorConditionalOrder(self,pErrorConditionalOrder)); + Python_GIL(TraderSpi_OnRtnErrorConditionalOrder(self, pErrorConditionalOrder)); }; ///执行宣告通知 virtual void OnRtnExecOrder(CThostFtdcExecOrderField *pExecOrder) { - Python_GIL(TraderSpi_OnRtnExecOrder(self,pExecOrder)); + Python_GIL(TraderSpi_OnRtnExecOrder(self, pExecOrder)); }; ///执行宣告录入错误回报 virtual void OnErrRtnExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnExecOrderInsert(self,pInputExecOrder,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnExecOrderInsert(self, pInputExecOrder, pRspInfo)); }; ///执行宣告操作错误回报 virtual void OnErrRtnExecOrderAction(CThostFtdcExecOrderActionField *pExecOrderAction, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnExecOrderAction(self,pExecOrderAction,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnExecOrderAction(self, pExecOrderAction, pRspInfo)); }; ///询价录入错误回报 virtual void OnErrRtnForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnForQuoteInsert(self,pInputForQuote,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnForQuoteInsert(self, pInputForQuote, pRspInfo)); }; ///报价通知 virtual void OnRtnQuote(CThostFtdcQuoteField *pQuote) { - Python_GIL(TraderSpi_OnRtnQuote(self,pQuote)); + Python_GIL(TraderSpi_OnRtnQuote(self, pQuote)); }; ///报价录入错误回报 virtual void OnErrRtnQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnQuoteInsert(self,pInputQuote,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnQuoteInsert(self, pInputQuote, pRspInfo)); }; ///报价操作错误回报 virtual void OnErrRtnQuoteAction(CThostFtdcQuoteActionField *pQuoteAction, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnQuoteAction(self,pQuoteAction,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnQuoteAction(self, pQuoteAction, pRspInfo)); }; ///询价通知 virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) { - Python_GIL(TraderSpi_OnRtnForQuoteRsp(self,pForQuoteRsp)); + Python_GIL(TraderSpi_OnRtnForQuoteRsp(self, pForQuoteRsp)); }; ///保证金监控中心用户令牌 virtual void OnRtnCFMMCTradingAccountToken(CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) { - Python_GIL(TraderSpi_OnRtnCFMMCTradingAccountToken(self,pCFMMCTradingAccountToken)); + Python_GIL(TraderSpi_OnRtnCFMMCTradingAccountToken(self, pCFMMCTradingAccountToken)); }; ///批量报单操作错误回报 virtual void OnErrRtnBatchOrderAction(CThostFtdcBatchOrderActionField *pBatchOrderAction, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnBatchOrderAction(self,pBatchOrderAction,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnBatchOrderAction(self, pBatchOrderAction, pRspInfo)); }; ///期权自对冲通知 virtual void OnRtnOptionSelfClose(CThostFtdcOptionSelfCloseField *pOptionSelfClose) { - Python_GIL(TraderSpi_OnRtnOptionSelfClose(self,pOptionSelfClose)); + Python_GIL(TraderSpi_OnRtnOptionSelfClose(self, pOptionSelfClose)); }; ///期权自对冲录入错误回报 - virtual void OnErrRtnOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, - CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnOptionSelfCloseInsert(self,pInputOptionSelfClose,pRspInfo)); + virtual void OnErrRtnOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, CThostFtdcRspInfoField *pRspInfo) { + Python_GIL(TraderSpi_OnErrRtnOptionSelfCloseInsert(self, pInputOptionSelfClose, pRspInfo)); - }; + }; ///期权自对冲操作错误回报 - virtual void OnErrRtnOptionSelfCloseAction(CThostFtdcOptionSelfCloseActionField *pOptionSelfCloseAction, - CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnOptionSelfCloseAction(self,pOptionSelfCloseAction,pRspInfo)); - - }; + virtual void OnErrRtnOptionSelfCloseAction(CThostFtdcOptionSelfCloseActionField *pOptionSelfCloseAction, CThostFtdcRspInfoField *pRspInfo) { + Python_GIL(TraderSpi_OnErrRtnOptionSelfCloseAction(self, pOptionSelfCloseAction, pRspInfo)); + }; ///申请组合通知 virtual void OnRtnCombAction(CThostFtdcCombActionField *pCombAction) { - Python_GIL(TraderSpi_OnRtnCombAction(self,pCombAction)); + Python_GIL(TraderSpi_OnRtnCombAction(self, pCombAction)); }; ///申请组合录入错误回报 virtual void OnErrRtnCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnCombActionInsert(self,pInputCombAction,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnCombActionInsert(self, pInputCombAction, pRspInfo)); }; ///请求查询签约银行响应 - virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryContractBank(self,pContractBank,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryContractBank(self, pContractBank, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询预埋单响应 virtual void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, - bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryParkedOrder(self,pParkedOrder,pRspInfo,nRequestID,bIsLast)); - }; + bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryParkedOrder(self, pParkedOrder, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询预埋撤单响应 - virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryParkedOrderAction(self,pParkedOrderAction,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryParkedOrderAction(self, pParkedOrderAction, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询交易通知响应 - virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryTradingNotice(self,pTradingNotice,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryTradingNotice(self, pTradingNotice, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询经纪公司交易参数响应 - virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryBrokerTradingParams(self,pBrokerTradingParams,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryBrokerTradingParams(self, pBrokerTradingParams, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询经纪公司交易算法响应 virtual void OnRspQryBrokerTradingAlgos(CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQryBrokerTradingAlgos(self,pBrokerTradingAlgos,pRspInfo,nRequestID,bIsLast)); - }; + int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQryBrokerTradingAlgos(self, pBrokerTradingAlgos, pRspInfo, nRequestID, bIsLast)); + }; ///请求查询监控中心用户令牌 - virtual void OnRspQueryCFMMCTradingAccountToken(CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, - CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQueryCFMMCTradingAccountToken(self,pQueryCFMMCTradingAccountToken,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspQueryCFMMCTradingAccountToken(CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQueryCFMMCTradingAccountToken(self, pQueryCFMMCTradingAccountToken, pRspInfo, nRequestID, bIsLast)); + }; ///银行发起银行资金转期货通知 virtual void OnRtnFromBankToFutureByBank(CThostFtdcRspTransferField *pRspTransfer) { - Python_GIL(TraderSpi_OnRtnFromBankToFutureByBank(self,pRspTransfer)); + Python_GIL(TraderSpi_OnRtnFromBankToFutureByBank(self, pRspTransfer)); }; ///银行发起期货资金转银行通知 virtual void OnRtnFromFutureToBankByBank(CThostFtdcRspTransferField *pRspTransfer) { - Python_GIL(TraderSpi_OnRtnFromFutureToBankByBank(self,pRspTransfer)); + Python_GIL(TraderSpi_OnRtnFromFutureToBankByBank(self, pRspTransfer)); }; ///银行发起冲正银行转期货通知 virtual void OnRtnRepealFromBankToFutureByBank(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByBank(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByBank(self, pRspRepeal)); }; ///银行发起冲正期货转银行通知 virtual void OnRtnRepealFromFutureToBankByBank(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByBank(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByBank(self, pRspRepeal)); }; ///期货发起银行资金转期货通知 virtual void OnRtnFromBankToFutureByFuture(CThostFtdcRspTransferField *pRspTransfer) { - Python_GIL(TraderSpi_OnRtnFromBankToFutureByFuture(self,pRspTransfer)); + Python_GIL(TraderSpi_OnRtnFromBankToFutureByFuture(self, pRspTransfer)); }; ///期货发起期货资金转银行通知 virtual void OnRtnFromFutureToBankByFuture(CThostFtdcRspTransferField *pRspTransfer) { - Python_GIL(TraderSpi_OnRtnFromFutureToBankByFuture(self,pRspTransfer)); + Python_GIL(TraderSpi_OnRtnFromFutureToBankByFuture(self, pRspTransfer)); }; ///系统运行时期货端手工发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 virtual void OnRtnRepealFromBankToFutureByFutureManual(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(self, pRspRepeal)); }; ///系统运行时期货端手工发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 virtual void OnRtnRepealFromFutureToBankByFutureManual(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(self, pRspRepeal)); }; ///期货发起查询银行余额通知 virtual void OnRtnQueryBankBalanceByFuture(CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) { - Python_GIL(TraderSpi_OnRtnQueryBankBalanceByFuture(self,pNotifyQueryAccount)); + Python_GIL(TraderSpi_OnRtnQueryBankBalanceByFuture(self, pNotifyQueryAccount)); }; ///期货发起银行资金转期货错误回报 virtual void OnErrRtnBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnBankToFutureByFuture(self,pReqTransfer,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnBankToFutureByFuture(self, pReqTransfer, pRspInfo)); }; ///期货发起期货资金转银行错误回报 virtual void OnErrRtnFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnFutureToBankByFuture(self,pReqTransfer,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnFutureToBankByFuture(self, pReqTransfer, pRspInfo)); }; ///系统运行时期货端手工发起冲正银行转期货错误回报 virtual void OnErrRtnRepealBankToFutureByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(self,pReqRepeal,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(self, pReqRepeal, pRspInfo)); }; ///系统运行时期货端手工发起冲正期货转银行错误回报 virtual void OnErrRtnRepealFutureToBankByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(self,pReqRepeal,pRspInfo)); + Python_GIL(TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(self, pReqRepeal, pRspInfo)); }; ///期货发起查询银行余额错误回报 - virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, - CThostFtdcRspInfoField *pRspInfo) { - Python_GIL(TraderSpi_OnErrRtnQueryBankBalanceByFuture(self,pReqQueryAccount,pRspInfo)); - }; + virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo) { + Python_GIL(TraderSpi_OnErrRtnQueryBankBalanceByFuture(self, pReqQueryAccount, pRspInfo)); + }; ///期货发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 virtual void OnRtnRepealFromBankToFutureByFuture(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByFuture(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromBankToFutureByFuture(self, pRspRepeal)); }; ///期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 virtual void OnRtnRepealFromFutureToBankByFuture(CThostFtdcRspRepealField *pRspRepeal) { - Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByFuture(self,pRspRepeal)); + Python_GIL(TraderSpi_OnRtnRepealFromFutureToBankByFuture(self, pRspRepeal)); }; ///期货发起银行资金转期货应答 - virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspFromBankToFutureByFuture(self,pReqTransfer,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspFromBankToFutureByFuture(self, pReqTransfer, pRspInfo, nRequestID, bIsLast)); + }; ///期货发起期货资金转银行应答 - virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, - int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspFromFutureToBankByFuture(self,pReqTransfer,pRspInfo,nRequestID,bIsLast)); - }; + virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspFromFutureToBankByFuture(self, pReqTransfer, pRspInfo, nRequestID, bIsLast)); + }; ///期货发起查询银行余额应答 virtual void OnRspQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQueryBankAccountMoneyByFuture(self,pReqQueryAccount,pRspInfo,nRequestID,bIsLast)); + Python_GIL(TraderSpi_OnRspQueryBankAccountMoneyByFuture(self, pReqQueryAccount, pRspInfo, nRequestID, bIsLast)); }; ///银行发起银期开户通知 virtual void OnRtnOpenAccountByBank(CThostFtdcOpenAccountField *pOpenAccount) { - Python_GIL(TraderSpi_OnRtnOpenAccountByBank(self,pOpenAccount)); + Python_GIL(TraderSpi_OnRtnOpenAccountByBank(self, pOpenAccount)); }; ///银行发起银期销户通知 virtual void OnRtnCancelAccountByBank(CThostFtdcCancelAccountField *pCancelAccount) { - Python_GIL(TraderSpi_OnRtnCancelAccountByBank(self,pCancelAccount)); + Python_GIL(TraderSpi_OnRtnCancelAccountByBank(self, pCancelAccount)); }; ///银行发起变更银行账号通知 virtual void OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccount) { - Python_GIL(TraderSpi_OnRtnChangeAccountByBank(self,pChangeAccount)); + Python_GIL(TraderSpi_OnRtnChangeAccountByBank(self, pChangeAccount)); }; ///请求查询二级代理商信息响应 - virtual void OnRspQrySecAgentTradeInfo(CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspQrySecAgentTradeInfo(self,pSecAgentTradeInfo, pRspInfo, nRequestID, bIsLast)); - }; + virtual void OnRspQrySecAgentTradeInfo(CThostFtdcSecAgentTradeInfoField *pSecAgentTradeInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { + Python_GIL(TraderSpi_OnRspQrySecAgentTradeInfo(self, pSecAgentTradeInfo, pRspInfo, nRequestID, bIsLast)); + }; ///查询用户当前支持的认证模式的回复 virtual void OnRspUserAuthMethod(CThostFtdcRspUserAuthMethodField *pRspUserAuthMethod, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspUserAuthMethod(self,pRspUserAuthMethod, pRspInfo, nRequestID, bIsLast)); + Python_GIL(TraderSpi_OnRspUserAuthMethod(self, pRspUserAuthMethod, pRspInfo, nRequestID, bIsLast)); }; ///获取图形验证码请求的回复 virtual void OnRspGenUserCaptcha(CThostFtdcRspGenUserCaptchaField *pRspGenUserCaptcha, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspGenUserCaptcha(self,pRspGenUserCaptcha, pRspInfo, nRequestID, bIsLast)); + Python_GIL(TraderSpi_OnRspGenUserCaptcha(self, pRspGenUserCaptcha, pRspInfo, nRequestID, bIsLast)); }; ///获取短信验证码请求的回复 virtual void OnRspGenUserText(CThostFtdcRspGenUserTextField *pRspGenUserText, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { - Python_GIL(TraderSpi_OnRspGenUserText(self,pRspGenUserText, pRspInfo, nRequestID, bIsLast)); + Python_GIL(TraderSpi_OnRspGenUserText(self, pRspGenUserText, pRspInfo, nRequestID, bIsLast)); }; private: - PyObject *self; + PyObject *self; }; #endif /* CTRADERAPI_H */ diff --git a/ctpwrapper/datacollect.pyx b/ctpwrapper/datacollect.pyx index 72504c9..fd214cb 100644 --- a/ctpwrapper/datacollect.pyx +++ b/ctpwrapper/datacollect.pyx @@ -1,7 +1,7 @@ # encoding:utf-8 # distutils: language=c++ -from .headers.DataCollect cimport CTP_GetSystemInfo +from ctpwrapper.headers.DataCollect cimport CTP_GetSystemInfo def GetSystemInfo(char *pSystemInfo,int nLen): """ diff --git a/ctpwrapper/headers/ThostFtdcUserApiDataType.pxd b/ctpwrapper/headers/ThostFtdcUserApiDataType.pxd index 607a07e..6d20c14 100644 --- a/ctpwrapper/headers/ThostFtdcUserApiDataType.pxd +++ b/ctpwrapper/headers/ThostFtdcUserApiDataType.pxd @@ -15,8 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ctpwrapper. If not, see . - """ + cdef extern from 'ThostFtdcUserApiDataType.h': cdef enum THOST_TE_RESUME_TYPE: THOST_TERT_RESTART = 0 diff --git a/ctpwrapper/headers/ThostFtdcUserApiStruct.pxd b/ctpwrapper/headers/ThostFtdcUserApiStruct.pxd index 89a63e9..eff785c 100644 --- a/ctpwrapper/headers/ThostFtdcUserApiStruct.pxd +++ b/ctpwrapper/headers/ThostFtdcUserApiStruct.pxd @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with ctpwrapper. If not, see . """ -from .ThostFtdcUserApiDataType cimport * +from ctpwrapper.headers.ThostFtdcUserApiDataType cimport * cdef extern from 'ThostFtdcUserApiStruct.h': cdef struct CThostFtdcDisseminationField: diff --git a/ctpwrapper/headers/cMdAPI.pxd b/ctpwrapper/headers/cMdAPI.pxd index c447b8b..e4987c6 100644 --- a/ctpwrapper/headers/cMdAPI.pxd +++ b/ctpwrapper/headers/cMdAPI.pxd @@ -23,7 +23,7 @@ from libcpp cimport bool as cbool # from libcpp.memory cimport shared_ptr,make_shared -from .ThostFtdcUserApiStruct cimport ( +from ctpwrapper.headers.ThostFtdcUserApiStruct cimport ( CThostFtdcReqUserLoginField, CThostFtdcUserLogoutField, CThostFtdcFensUserInfoField, @@ -35,19 +35,19 @@ cdef extern from 'ThostFtdcMdApi.h': cdef cppclass CMdApi "CThostFtdcMdApi": @staticmethod - const_char *GetApiVersion() nogil + const_char *GetApiVersion() # 删除接口对象本身 # @remark 不再使用本接口对象时,调用该函数删除接口对象 - void Release() nogil + void Release() nogil except + # 初始化 # @remark 初始化运行环境,只有调用后,接口才开始工作 - void Init() nogil + void Init() nogil except + # 等待接口线程结束运行 # @return 线程退出代码 - int Join() nogil + int Join() nogil except + # 获取当前交易日 # @retrun 获取到的交易日 @@ -110,4 +110,4 @@ cdef extern from 'ThostFtdcMdApi.h' namespace "CThostFtdcMdApi": cdef extern from 'CMdAPI.h': cdef cppclass CMdSpi: - CMdSpi(PyObject *obj) + CMdSpi(PyObject *obj) except + diff --git a/ctpwrapper/headers/cTraderApi.pxd b/ctpwrapper/headers/cTraderApi.pxd index 671eac6..9d3f39a 100644 --- a/ctpwrapper/headers/cTraderApi.pxd +++ b/ctpwrapper/headers/cTraderApi.pxd @@ -20,7 +20,7 @@ along with ctpwrapper. If not, see . from cpython cimport PyObject from libc.string cimport const_char -from .ThostFtdcUserApiStruct cimport * +from ctpwrapper.headers.ThostFtdcUserApiStruct cimport * cdef extern from "ThostFtdcTraderApi.h": @@ -28,19 +28,19 @@ cdef extern from "ThostFtdcTraderApi.h": cdef cppclass CTraderApi "CThostFtdcTraderApi": @staticmethod - const_char *GetApiVersion() nogil + const_char *GetApiVersion() # 删除接口对象本身 #@remark 不再使用本接口对象时,调用该函数删除接口对象 - void Release() nogil + void Release() nogil except + #初始化 #@remark 初始化运行环境,只有调用后,接口才开始工作 - void Init() nogil + void Init() nogil except + #等待接口线程结束运行 #@return 线程退出代码 - int Join() nogil + int Join() nogil except + #获取当前交易日 #@retrun 获取到的交易日 @@ -105,8 +105,7 @@ cdef extern from "ThostFtdcTraderApi.h": int ReqUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) nogil except + #资金账户口令更新请求 - int ReqTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, - int nRequestID) nogil except + + int ReqTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, int nRequestID) nogil except + # 查询用户当前支持的认证模式 int ReqUserAuthMethod(CThostFtdcReqUserAuthMethodField *pReqUserAuthMethod, int nRequestID) nogil except + @@ -174,8 +173,7 @@ cdef extern from "ThostFtdcTraderApi.h": int ReqOptionSelfCloseInsert(CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose, int nRequestID) nogil except + #期权自对冲操作请求 - int ReqOptionSelfCloseAction(CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, - int nRequestID) nogil except + + int ReqOptionSelfCloseAction(CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction, int nRequestID) nogil except + #申请组合录入请求 int ReqCombActionInsert(CThostFtdcInputCombActionField *pInputCombAction, int nRequestID) nogil except + @@ -347,4 +345,4 @@ cdef extern from "ThostFtdcTraderApi.h" namespace "CThostFtdcTraderApi": cdef extern from "CTraderAPI.h": cdef cppclass CTraderSpi: - CTraderSpi(PyObject *obj) + CTraderSpi(PyObject *obj) except + diff --git a/makefile b/makefile index bdd520d..5e9f696 100644 --- a/makefile +++ b/makefile @@ -26,4 +26,10 @@ sdist: clean twine: twine upload dist/* +.PHONY: pypy +pypy: + pypy3 setup.py clean --all + pypy3 setup.py build_ext --inplace + + diff --git a/pypy3-Dockerfile b/pypy3-Dockerfile new file mode 100644 index 0000000..959d733 --- /dev/null +++ b/pypy3-Dockerfile @@ -0,0 +1,4 @@ +FROM pypy:3.6 +RUN pypy3 -m ensurepip +RUN pip3 install cython pip setuptools --upgrade +WORKDIR /code diff --git a/samples/config.json b/samples/config.json new file mode 100644 index 0000000..df10597 --- /dev/null +++ b/samples/config.json @@ -0,0 +1,9 @@ +{ + "investor_id": "", + "broker_id": "", + "password": "", + "md_server": "tcp://180.168.146.187:10110", + "trader_server": "tcp://180.168.146.187:10100", + "app_id": "simnow_client_test", + "auth_code": "0000000000000000" +} \ No newline at end of file diff --git a/samples/md_main.py b/samples/md_main.py index db54f6a..d180282 100755 --- a/samples/md_main.py +++ b/samples/md_main.py @@ -18,12 +18,12 @@ along with ctpwrapper. If not, see . """ - +import json import socket import sys import urllib.parse from contextlib import closing - +import time from ctpwrapper import ApiStructure from ctpwrapper import MdApiPy @@ -49,47 +49,42 @@ class Md(MdApiPy): """ """ - def __init__(self, broker_id, investor_id, password, request_id=1): - + def __init__(self, broker_id, investor_id, password, request_id=100): + """ + """ + self.login = False self.broker_id = broker_id self.investor_id = investor_id self.password = password - self.request_id = request_id - - def OnRspError(self, pRspInfo, nRequestID, bIsLast): + self._request_id = request_id - self.ErrorRspInfo(pRspInfo, nRequestID) + @property + def request_id(self): + self._request_id += 1 + return self._request_id - def ErrorRspInfo(self, info, request_id): - """ - :param info: - :return: - """ - if info.ErrorID != 0: - print('request_id=%s ErrorID=%d, ErrorMsg=%s', - request_id, info.ErrorID, info.ErrorMsg.decode('gbk')) - return info.ErrorID != 0 + def OnRspError(self, pRspInfo, nRequestID, bIsLast): + print("OnRspError:") + print("requestID:", nRequestID) + print(pRspInfo) + print(bIsLast) def OnFrontConnected(self): """ :return: """ - - user_login = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, - UserID=self.investor_id, - Password=self.password) + user_login = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, UserID=self.investor_id, Password=self.password) self.ReqUserLogin(user_login, self.request_id) def OnFrontDisconnected(self, nReason): - - print("Md OnFrontDisconnected %s", nReason) + print("Md OnFrontDisconnected {0}".format(nReason)) sys.exit() def OnHeartBeatWarning(self, nTimeLapse): """心跳超时警告。当长时间未收到报文时,该方法被调用。 @param nTimeLapse 距离上次接收报文的时间 """ - print('Md OnHeartBeatWarning, time = %s', nTimeLapse) + print('Md OnHeartBeatWarning, time = {0}'.format(nTimeLapse)) def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): """ @@ -100,13 +95,16 @@ def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): :param bIsLast: :return: """ + print("OnRspUserLogin") + print("requestID:", nRequestID) + print("RspInfo:", pRspInfo) + if pRspInfo.ErrorID != 0: - print("Md OnRspUserLogin failed error_id=%s msg:%s", - pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')) + print("RspInfo:", pRspInfo) else: - print("Md user login successfully") - print(pRspUserLogin) - print(pRspInfo) + print("user login successfully") + print("RspUserLogin:", pRspUserLogin) + self.login = True def OnRtnDepthMarketData(self, pDepthMarketData): """ @@ -114,8 +112,8 @@ def OnRtnDepthMarketData(self, pDepthMarketData): :param pDepthMarketData: :return: """ - market_data = pDepthMarketData.to_dict() - print(market_data) + print("OnRtnDepthMarketData") + print("DepthMarketData:", pDepthMarketData) def OnRspSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast): """ @@ -127,8 +125,10 @@ def OnRspSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast) :return: """ print("OnRspSubMarketData") - print(pSpecificInstrument) - print(pRspInfo) + print("RequestId:", nRequestID) + print("isLast:", bIsLast) + print("pRspInfo:", pRspInfo) + print("pSpecificInstrument:", pSpecificInstrument) def OnRspUnSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLast): """ @@ -140,32 +140,43 @@ def OnRspUnSubMarketData(self, pSpecificInstrument, pRspInfo, nRequestID, bIsLas :return: """ print("OnRspUnSubMarketData") - print(pSpecificInstrument) - print(pRspInfo) + print("RequestId:", nRequestID) + print("isLast:", bIsLast) + print("pRspInfo:", pRspInfo) + print("pSpecificInstrument:", pSpecificInstrument) def main(): - investor_id = "089303" - broker_id = "9999" - password = "198759" - server = "tcp://180.168.146.187:10011" + json_file = open("config.json") + config = json.load(json_file) + json_file.close() - if check_address_port(server): + investor_id = config["investor_id"] + broker_id = config["broker_id"] + password = config["password"] + server = config["md_server"] + if check_address_port(server): + print("connect to md sever successfully") + # 1 create + # 2 register + # 3 register front + # 4 init md = Md(broker_id, investor_id, password) md.Create() md.RegisterFront(server) md.Init() - day = md.GetTradingDay() - print(day) - - print("md_start") - - md.SubscribeMarketData(["rb1810"]) - md.Join() + day = md.GetTradingDay() + print("trading day:", day) + print("md login:", md.login) + if md.login: + md.SubscribeMarketData(["ru2101"]) + time.sleep(30) + md.UnSubscribeMarketData(["ru2101"]) + md.Join() else: - print("md server down") + print("md server is down") if __name__ == "__main__": diff --git a/samples/trader_main.py b/samples/trader_main.py index 8cedc39..f903cac 100755 --- a/samples/trader_main.py +++ b/samples/trader_main.py @@ -18,11 +18,11 @@ along with ctpwrapper. If not, see . """ - +import json import socket import urllib.parse from contextlib import closing - +import time from ctpwrapper import ApiStructure from ctpwrapper import TraderApiPy @@ -46,94 +46,153 @@ def check_address_port(tcp): class Trader(TraderApiPy): - def __init__(self, broker_id, investor_id, password, request_id=1): - self.request_id = request_id - self.broker_id = broker_id.encode() - self.investor_id = investor_id.encode() - self.password = password.encode() - - def OnRspError(self, pRspInfo, nRequestID, bIsLast): + def __init__(self, app_id, auth_code, broker_id, investor_id, password, request_id=100): + self.app_id = app_id + self.auth_code = auth_code + self.broker_id = broker_id + self.investor_id = investor_id + self.password = password + self._request_id = request_id + self.login = False - self.ErrorRspInfo(pRspInfo, nRequestID) + @property + def request_id(self): + self._request_id += 1 + return self._request_id - def ErrorRspInfo(self, info, request_id): - """ - :param info: - :return: - """ - if info.ErrorID != 0: - print('request_id=%s ErrorID=%d, ErrorMsg=%s', - request_id, info.ErrorID, info.ErrorMsg.decode('gbk')) - return info.ErrorID != 0 + def OnRspError(self, pRspInfo, nRequestID, bIsLast): + print("OnRspError:") + print("requestID:", nRequestID) + print(pRspInfo) + print(bIsLast) def OnHeartBeatWarning(self, nTimeLapse): """心跳超时警告。当长时间未收到报文时,该方法被调用。 @param nTimeLapse 距离上次接收报文的时间 """ - print("on OnHeartBeatWarning time: ", nTimeLapse) + print("OnHeartBeatWarning time: ", nTimeLapse) def OnFrontDisconnected(self, nReason): - print("on FrontDisConnected disconnected", nReason) + print("OnFrontConnected:", nReason) def OnFrontConnected(self): - - req = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, - UserID=self.investor_id, - Password=self.password) - self.ReqUserLogin(req, self.request_id) - print("trader on front connection") + print("OnFrontConnected") + authenticate = ApiStructure.ReqAuthenticateField(BrokerID=self.broker_id, + UserID=self.investor_id, + AppID=self.app_id, + AuthCode=self.auth_code) + + self.ReqAuthenticate(authenticate, self.request_id) + + def OnRspAuthenticate(self, pRspAuthenticateField, pRspInfo, nRequestID, bIsLast): + + print("OnRspAuthenticate") + print("pRspInfo:", pRspInfo) + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + + if pRspInfo.ErrorID == 0: + req = ApiStructure.ReqUserLoginField(BrokerID=self.broker_id, + UserID=self.investor_id, + Password=self.password) + self.ReqUserLogin(req, self.request_id) + else: + print("auth failed") def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): + print("OnRspUserLogin") + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + print("pRspInfo:", pRspInfo) if pRspInfo.ErrorID != 0: - print("Md OnRspUserLogin failed error_id=%s msg:%s", - pRspInfo.ErrorID, pRspInfo.ErrorMsg.decode('gbk')) + print("RspInfo:", pRspInfo) else: - print("Md user login successfully") - - inv = ApiStructure.QryInvestorField(BrokerID=self.broker_id, InvestorID=self.investor_id) - - self.ReqQryInvestor(inv, self.inc_request_id()) - req = ApiStructure.SettlementInfoConfirmField.from_dict({"BrokerID": self.broker_id, - "InvestorID": self.investor_id}) - - self.ReqSettlementInfoConfirm(req, self.inc_request_id()) + print("trader user login successfully") + self.login = True + print("pRspUserLogin:", pRspUserLogin) def OnRspSettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast): - print(pSettlementInfoConfirm, pRspInfo) - print(pRspInfo.ErrorMsg.decode("GBK")) + """ + """ + print("OnRspSettlementInfoConfirm") + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + print("pRspInfo:", pRspInfo) - def inc_request_id(self): - self.request_id += 1 - return self.request_id + print(pSettlementInfoConfirm) def OnRspQryInvestor(self, pInvestor, pRspInfo, nRequestID, bIsLast): - print(pInvestor, pRspInfo) + """ + """ + print("OnRspQryInvestor") + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + print("pRspInfo:", pRspInfo) + print("pInvestor:", pInvestor) + + def OnRspQryInvestorPosition(self, pInvestorPosition, pRspInfo, nRequestID, bIsLast): + print("OnRspQryInvestorPosition") + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + print("pRspInfo:", pRspInfo) + print("pInvestorPosition:", pInvestorPosition) + + def OnRspQryTradingAccount(self, pTradingAccount, pRspInfo, nRequestID, bIsLast): + print("OnRspQryTradingAccount") + print("nRequestID:", nRequestID) + print("bIsLast:", bIsLast) + print("pRspInfo:", pRspInfo) + print("pTradingAccount:", pTradingAccount) def main(): + json_file = open("config.json") + config = json.load(json_file) + json_file.close() - investor_id = "089303" - broker_id = "9999" - password = "198759" + print(config) - server = "tcp://180.168.146.187:10001" + investor_id = config["investor_id"] + broker_id = config["broker_id"] + password = config["password"] + server = config["trader_server"] + app_id = config["app_id"] + auth_code = config["auth_code"] if check_address_port(server): - user_trader = Trader(broker_id=broker_id, investor_id=investor_id, password=password) + user_trader = Trader(broker_id=broker_id, app_id=app_id, auth_code=auth_code, + investor_id=investor_id, password=password) user_trader.Create() user_trader.RegisterFront(server) - user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 - user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 + user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 + user_trader.SubscribePrivateTopic(2) # 只传送登录后的流内容 user_trader.Init() - print("trader started") - print(user_trader.GetTradingDay()) + print("trader api started") + print("trading day:", user_trader.GetTradingDay()) + + if user_trader.login: + investor = ApiStructure.QryInvestorField(broker_id, investor_id) + + user_trader.ReqQryInvestor(investor, user_trader.request_id) + + # position = ApiStructure.QryInvestorPositionField.from_dict({"BrokerID": broker_id, + # "InvestorID": investor_id}) + # user_trader.ReqQryInvestorPosition(position, user_trader.request_id) + + settlement_info = ApiStructure.SettlementInfoConfirmField.from_dict({"BrokerID": broker_id, + "InvestorID": investor_id}) + + user_trader.ReqSettlementInfoConfirm(settlement_info, user_trader.request_id) + + trader_account = ApiStructure.QryTradingAccountField(BrokerID=broker_id, InvestorID=investor_id) + user_trader.ReqQryTradingAccount(trader_account, user_trader.request_id) - user_trader.Join() + user_trader.Join() else: print("trader server down") diff --git a/tests/test_structure.py b/tests/test_structure.py index 05eb833..b475a40 100644 --- a/tests/test_structure.py +++ b/tests/test_structure.py @@ -57,10 +57,10 @@ def test_from_dict(self): } field = ApiStructure.ExchangeRateField.from_dict(result) - self.assertEqual(field.BrokerID, b"45544") - self.assertEqual(field.FromCurrencyID, b"4343") + self.assertEqual(field.BrokerID, "45544") + self.assertEqual(field.FromCurrencyID, "4343") self.assertEqual(field.FromCurrencyUnit, 19.0) - self.assertEqual(field.ToCurrencyID, b"4334") + self.assertEqual(field.ToCurrencyID, "4334") self.assertEqual(field.ExchangeRate, 11.0) def test_struct_missing_parameter(self): @@ -89,8 +89,8 @@ def test_dict_missing_parameter(self): } field = ApiStructure.ExchangeRateField.from_dict(result) - self.assertEqual(field.BrokerID, b"45544") - self.assertEqual(field.FromCurrencyID, b"") + self.assertEqual(field.BrokerID, "45544") + self.assertEqual(field.FromCurrencyID, "") self.assertEqual(field.FromCurrencyUnit, 0.0) - self.assertEqual(field.ToCurrencyID, b"4334") + self.assertEqual(field.ToCurrencyID, "4334") self.assertEqual(field.ExchangeRate, 11.0)