补充新的CTP接口中未实现的callback函数
This commit is contained in:
parent
e7582dd01f
commit
e36bd4a3f2
@ -56,6 +56,14 @@ posiDirectionMap[DIRECTION_LONG] = defineDict["THOST_FTDC_PD_Long"]
|
|||||||
posiDirectionMap[DIRECTION_SHORT] = defineDict["THOST_FTDC_PD_Short"]
|
posiDirectionMap[DIRECTION_SHORT] = defineDict["THOST_FTDC_PD_Short"]
|
||||||
posiDirectionMapReverse = {v:k for k,v in posiDirectionMap.items()}
|
posiDirectionMapReverse = {v:k for k,v in posiDirectionMap.items()}
|
||||||
|
|
||||||
|
# 产品类型映射
|
||||||
|
productClassMap = {}
|
||||||
|
productClassMap[PRODUCT_FUTURES] = defineDict["THOST_FTDC_PC_Futures"]
|
||||||
|
productClassMap[PRODUCT_OPTION] = defineDict["THOST_FTDC_PC_Options"]
|
||||||
|
productClassMap[PRODUCT_COMBINATION] = defineDict["THOST_FTDC_PC_Combination"]
|
||||||
|
productClassMapReverse = {v:k for k,v in productClassMap.items()}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
class CtpGateway(VtGateway):
|
class CtpGateway(VtGateway):
|
||||||
@ -443,36 +451,36 @@ class CtpTdApi(TdApi):
|
|||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
"""服务器连接"""
|
"""服务器连接"""
|
||||||
self.connectionStatus = True
|
self.connectionStatus = True
|
||||||
|
|
||||||
log = VtLogData()
|
log = VtLogData()
|
||||||
log.gatewayName = self.gatewayName
|
log.gatewayName = self.gatewayName
|
||||||
log.logContent = u'交易服务器连接成功'
|
log.logContent = u'交易服务器连接成功'
|
||||||
self.gateway.onLog(log)
|
self.gateway.onLog(log)
|
||||||
|
|
||||||
self.login()
|
|
||||||
|
|
||||||
|
self.login()
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onFrontDisconnected(self, n):
|
def onFrontDisconnected(self, n):
|
||||||
"""服务器断开"""
|
"""服务器断开"""
|
||||||
self.connectionStatus = False
|
self.connectionStatus = False
|
||||||
self.loginStatus = False
|
self.loginStatus = False
|
||||||
self.gateway.tdConnected = False
|
self.gateway.tdConnected = False
|
||||||
|
|
||||||
log = VtLogData()
|
log = VtLogData()
|
||||||
log.gatewayName = self.gatewayName
|
log.gatewayName = self.gatewayName
|
||||||
log.logContent = u'交易服务器连接断开'
|
log.logContent = u'交易服务器连接断开'
|
||||||
self.gateway.onLog(log)
|
self.gateway.onLog(log)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onHeartBeatWarning(self, n):
|
def onHeartBeatWarning(self, n):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspAuthenticate(self, data, error, n, last):
|
def onRspAuthenticate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspUserLogin(self, data, error, n, last):
|
def onRspUserLogin(self, data, error, n, last):
|
||||||
"""登陆回报"""
|
"""登陆回报"""
|
||||||
@ -502,7 +510,7 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspUserLogout(self, data, error, n, last):
|
def onRspUserLogout(self, data, error, n, last):
|
||||||
"""登出回报"""
|
"""登出回报"""
|
||||||
@ -523,17 +531,17 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspUserPasswordUpdate(self, data, error, n, last):
|
def onRspUserPasswordUpdate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspTradingAccountPasswordUpdate(self, data, error, n, last):
|
def onRspTradingAccountPasswordUpdate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspOrderInsert(self, data, error, n, last):
|
def onRspOrderInsert(self, data, error, n, last):
|
||||||
"""发单错误(柜台)"""
|
"""发单错误(柜台)"""
|
||||||
@ -542,17 +550,17 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspParkedOrderInsert(self, data, error, n, last):
|
def onRspParkedOrderInsert(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspParkedOrderAction(self, data, error, n, last):
|
def onRspParkedOrderAction(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspOrderAction(self, data, error, n, last):
|
def onRspOrderAction(self, data, error, n, last):
|
||||||
"""撤单错误(柜台)"""
|
"""撤单错误(柜台)"""
|
||||||
@ -561,12 +569,12 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQueryMaxOrderVolume(self, data, error, n, last):
|
def onRspQueryMaxOrderVolume(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspSettlementInfoConfirm(self, data, error, n, last):
|
def onRspSettlementInfoConfirm(self, data, error, n, last):
|
||||||
"""确认结算信息回报"""
|
"""确认结算信息回报"""
|
||||||
@ -574,7 +582,7 @@ class CtpTdApi(TdApi):
|
|||||||
log.gatewayName = self.gatewayName
|
log.gatewayName = self.gatewayName
|
||||||
log.logContent = u'结算信息确认完成'
|
log.logContent = u'结算信息确认完成'
|
||||||
self.gateway.onLog(log)
|
self.gateway.onLog(log)
|
||||||
|
|
||||||
# 查询合约代码
|
# 查询合约代码
|
||||||
self.reqID += 1
|
self.reqID += 1
|
||||||
self.reqQryInstrument({}, self.reqID)
|
self.reqQryInstrument({}, self.reqID)
|
||||||
@ -583,47 +591,57 @@ class CtpTdApi(TdApi):
|
|||||||
def onRspRemoveParkedOrder(self, data, error, n, last):
|
def onRspRemoveParkedOrder(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspRemoveParkedOrderAction(self, data, error, n, last):
|
def onRspRemoveParkedOrderAction(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspExecOrderInsert(self, data, error, n, last):
|
def onRspExecOrderInsert(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspExecOrderAction(self, data, error, n, last):
|
def onRspExecOrderAction(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspForQuoteInsert(self, data, error, n, last):
|
def onRspForQuoteInsert(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQuoteInsert(self, data, error, n, last):
|
def onRspQuoteInsert(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQuoteAction(self, data, error, n, last):
|
def onRspQuoteAction(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspLockInsert(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspCombActionInsert(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryOrder(self, data, error, n, last):
|
def onRspQryOrder(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTrade(self, data, error, n, last):
|
def onRspQryTrade(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInvestorPosition(self, data, error, n, last):
|
def onRspQryInvestorPosition(self, data, error, n, last):
|
||||||
"""持仓查询回报"""
|
"""持仓查询回报"""
|
||||||
@ -644,17 +662,17 @@ class CtpTdApi(TdApi):
|
|||||||
else:
|
else:
|
||||||
pos = posBuffer.updateBuffer(data, size)
|
pos = posBuffer.updateBuffer(data, size)
|
||||||
self.gateway.onPosition(pos)
|
self.gateway.onPosition(pos)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTradingAccount(self, data, error, n, last):
|
def onRspQryTradingAccount(self, data, error, n, last):
|
||||||
"""资金账户查询回报"""
|
"""资金账户查询回报"""
|
||||||
account = VtAccountData()
|
account = VtAccountData()
|
||||||
account.gatewayName = self.gatewayName
|
account.gatewayName = self.gatewayName
|
||||||
|
|
||||||
# 账户代码
|
# 账户代码
|
||||||
account.accountID = data['AccountID']
|
account.accountID = data['AccountID']
|
||||||
account.vtAccountID = '.'.join([self.gatewayName, account.accountID])
|
account.vtAccountID = '.'.join([self.gatewayName, account.accountID])
|
||||||
|
|
||||||
# 数值相关
|
# 数值相关
|
||||||
account.preBalance = data['PreBalance']
|
account.preBalance = data['PreBalance']
|
||||||
account.available = data['Available']
|
account.available = data['Available']
|
||||||
@ -662,46 +680,46 @@ class CtpTdApi(TdApi):
|
|||||||
account.margin = data['CurrMargin']
|
account.margin = data['CurrMargin']
|
||||||
account.closeProfit = data['CloseProfit']
|
account.closeProfit = data['CloseProfit']
|
||||||
account.positionProfit = data['PositionProfit']
|
account.positionProfit = data['PositionProfit']
|
||||||
|
|
||||||
# 这里的balance和快期中的账户不确定是否一样,需要测试
|
# 这里的balance和快期中的账户不确定是否一样,需要测试
|
||||||
account.balance = (data['PreBalance'] - data['PreCredit'] - data['PreMortgage'] +
|
account.balance = (data['PreBalance'] - data['PreCredit'] - data['PreMortgage'] +
|
||||||
data['Mortgage'] - data['Withdraw'] + data['Deposit'] +
|
data['Mortgage'] - data['Withdraw'] + data['Deposit'] +
|
||||||
data['CloseProfit'] + data['PositionProfit'] + data['CashIn'] -
|
data['CloseProfit'] + data['PositionProfit'] + data['CashIn'] -
|
||||||
data['Commission'])
|
data['Commission'])
|
||||||
|
|
||||||
# 推送
|
# 推送
|
||||||
self.gateway.onAccount(account)
|
self.gateway.onAccount(account)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInvestor(self, data, error, n, last):
|
def onRspQryInvestor(self, data, error, n, last):
|
||||||
"""投资者查询回报"""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTradingCode(self, data, error, n, last):
|
def onRspQryTradingCode(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInstrumentMarginRate(self, data, error, n, last):
|
def onRspQryInstrumentMarginRate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInstrumentCommissionRate(self, data, error, n, last):
|
def onRspQryInstrumentCommissionRate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryExchange(self, data, error, n, last):
|
def onRspQryExchange(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryProduct(self, data, error, n, last):
|
def onRspQryProduct(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInstrument(self, data, error, n, last):
|
def onRspQryInstrument(self, data, error, n, last):
|
||||||
"""合约查询回报"""
|
"""合约查询回报"""
|
||||||
@ -712,147 +730,179 @@ class CtpTdApi(TdApi):
|
|||||||
contract.exchange = exchangeMapReverse[data['ExchangeID']]
|
contract.exchange = exchangeMapReverse[data['ExchangeID']]
|
||||||
contract.vtSymbol = contract.symbol #'.'.join([contract.symbol, contract.exchange])
|
contract.vtSymbol = contract.symbol #'.'.join([contract.symbol, contract.exchange])
|
||||||
contract.name = data['InstrumentName'].decode('GBK')
|
contract.name = data['InstrumentName'].decode('GBK')
|
||||||
|
|
||||||
# 合约数值
|
# 合约数值
|
||||||
contract.size = data['VolumeMultiple']
|
contract.size = data['VolumeMultiple']
|
||||||
contract.priceTick = data['PriceTick']
|
contract.priceTick = data['PriceTick']
|
||||||
contract.strikePrice = data['StrikePrice']
|
contract.strikePrice = data['StrikePrice']
|
||||||
contract.underlyingSymbol = data['UnderlyingInstrID']
|
contract.underlyingSymbol = data['UnderlyingInstrID']
|
||||||
|
|
||||||
# 合约类型
|
contract.productClass = productClassMapReverse.get(data['ProductClass'], PRODUCT_UNKNOWN)
|
||||||
if data['ProductClass'] == '1':
|
|
||||||
contract.productClass = PRODUCT_FUTURES
|
|
||||||
elif data['ProductClass'] == '2':
|
|
||||||
contract.productClass = PRODUCT_OPTION
|
|
||||||
elif data['ProductClass'] == '3':
|
|
||||||
contract.productClass = PRODUCT_COMBINATION
|
|
||||||
else:
|
|
||||||
contract.productClass = PRODUCT_UNKNOWN
|
|
||||||
|
|
||||||
# 期权类型
|
# 期权类型
|
||||||
if data['OptionsType'] == '1':
|
if data['OptionsType'] == '1':
|
||||||
contract.optionType = OPTION_CALL
|
contract.optionType = OPTION_CALL
|
||||||
elif data['OptionsType'] == '2':
|
elif data['OptionsType'] == '2':
|
||||||
contract.optionType = OPTION_PUT
|
contract.optionType = OPTION_PUT
|
||||||
|
|
||||||
# 缓存代码和交易所的印射关系
|
# 缓存代码和交易所的印射关系
|
||||||
self.symbolExchangeDict[contract.symbol] = contract.exchange
|
self.symbolExchangeDict[contract.symbol] = contract.exchange
|
||||||
self.symbolSizeDict[contract.symbol] = contract.size
|
self.symbolSizeDict[contract.symbol] = contract.size
|
||||||
|
|
||||||
# 推送
|
# 推送
|
||||||
self.gateway.onContract(contract)
|
self.gateway.onContract(contract)
|
||||||
|
|
||||||
if last:
|
if last:
|
||||||
log = VtLogData()
|
log = VtLogData()
|
||||||
log.gatewayName = self.gatewayName
|
log.gatewayName = self.gatewayName
|
||||||
log.logContent = u'交易合约信息获取完成'
|
log.logContent = u'交易合约信息获取完成'
|
||||||
self.gateway.onLog(log)
|
self.gateway.onLog(log)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryDepthMarketData(self, data, error, n, last):
|
def onRspQryDepthMarketData(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQrySettlementInfo(self, data, error, n, last):
|
def onRspQrySettlementInfo(self, data, error, n, last):
|
||||||
"""查询结算信息回报"""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTransferBank(self, data, error, n, last):
|
def onRspQryTransferBank(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInvestorPositionDetail(self, data, error, n, last):
|
def onRspQryInvestorPositionDetail(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryNotice(self, data, error, n, last):
|
def onRspQryNotice(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQrySettlementInfoConfirm(self, data, error, n, last):
|
def onRspQrySettlementInfoConfirm(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInvestorPositionCombineDetail(self, data, error, n, last):
|
def onRspQryInvestorPositionCombineDetail(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryCFMMCTradingAccountKey(self, data, error, n, last):
|
def onRspQryCFMMCTradingAccountKey(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryEWarrantOffset(self, data, error, n, last):
|
def onRspQryEWarrantOffset(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryInvestorProductGroupMargin(self, data, error, n, last):
|
def onRspQryInvestorProductGroupMargin(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryExchangeMarginRate(self, data, error, n, last):
|
def onRspQryExchangeMarginRate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryExchangeMarginRateAdjust(self, data, error, n, last):
|
def onRspQryExchangeMarginRateAdjust(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryExchangeRate(self, data, error, n, last):
|
def onRspQryExchangeRate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQrySecAgentACIDMap(self, data, error, n, last):
|
def onRspQrySecAgentACIDMap(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryProductExchRate(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryProductGroup(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryOptionInstrTradeCost(self, data, error, n, last):
|
def onRspQryOptionInstrTradeCost(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryOptionInstrCommRate(self, data, error, n, last):
|
def onRspQryOptionInstrCommRate(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryExecOrder(self, data, error, n, last):
|
def onRspQryExecOrder(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryForQuote(self, data, error, n, last):
|
def onRspQryForQuote(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryQuote(self, data, error, n, last):
|
def onRspQryQuote(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryLock(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryLockPosition(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryInvestorLevel(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryExecFreeze(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryCombInstrumentGuard(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQryCombAction(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTransferSerial(self, data, error, n, last):
|
def onRspQryTransferSerial(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryAccountregister(self, data, error, n, last):
|
def onRspQryAccountregister(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspError(self, error, n, last):
|
def onRspError(self, error, n, last):
|
||||||
"""错误回报"""
|
"""错误回报"""
|
||||||
@ -861,7 +911,7 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnOrder(self, data):
|
def onRtnOrder(self, data):
|
||||||
"""报单回报"""
|
"""报单回报"""
|
||||||
@ -925,7 +975,7 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
# 推送
|
# 推送
|
||||||
self.gateway.onOrder(order)
|
self.gateway.onOrder(order)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnTrade(self, data):
|
def onRtnTrade(self, data):
|
||||||
"""成交回报"""
|
"""成交回报"""
|
||||||
@ -957,7 +1007,7 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
# 推送
|
# 推送
|
||||||
self.gateway.onTrade(trade)
|
self.gateway.onTrade(trade)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnOrderInsert(self, data, error):
|
def onErrRtnOrderInsert(self, data, error):
|
||||||
"""发单错误回报(交易所)"""
|
"""发单错误回报(交易所)"""
|
||||||
@ -966,7 +1016,7 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnOrderAction(self, data, error):
|
def onErrRtnOrderAction(self, data, error):
|
||||||
"""撤单错误回报(交易所)"""
|
"""撤单错误回报(交易所)"""
|
||||||
@ -975,227 +1025,233 @@ class CtpTdApi(TdApi):
|
|||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnInstrumentStatus(self, data):
|
def onRtnInstrumentStatus(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnTradingNotice(self, data):
|
def onRtnTradingNotice(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnErrorConditionalOrder(self, data):
|
def onRtnErrorConditionalOrder(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnExecOrder(self, data):
|
def onRtnExecOrder(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnExecOrderInsert(self, data, error):
|
def onErrRtnExecOrderInsert(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnExecOrderAction(self, data, error):
|
def onErrRtnExecOrderAction(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnForQuoteInsert(self, data, error):
|
def onErrRtnForQuoteInsert(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnQuote(self, data):
|
def onRtnQuote(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnQuoteInsert(self, data, error):
|
def onErrRtnQuoteInsert(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnQuoteAction(self, data, error):
|
def onErrRtnQuoteAction(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnForQuoteRsp(self, data):
|
def onRtnForQuoteRsp(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnCFMMCTradingAccountToken(self, data):
|
def onRtnCFMMCTradingAccountToken(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnLock(self, data):
|
def onRtnLock(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnLockInsert(self, data, error):
|
def onErrRtnLockInsert(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnCombAction(self, data):
|
def onRtnCombAction(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnCombActionInsert(self, data, error):
|
def onErrRtnCombActionInsert(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryContractBank(self, data, error, n, last):
|
def onRspQryContractBank(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryParkedOrder(self, data, error, n, last):
|
def onRspQryParkedOrder(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryParkedOrderAction(self, data, error, n, last):
|
def onRspQryParkedOrderAction(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryTradingNotice(self, data, error, n, last):
|
def onRspQryTradingNotice(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryBrokerTradingParams(self, data, error, n, last):
|
def onRspQryBrokerTradingParams(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQryBrokerTradingAlgos(self, data, error, n, last):
|
def onRspQryBrokerTradingAlgos(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def onRspQueryCFMMCTradingAccountToken(self, data, error, n, last):
|
||||||
|
""""""
|
||||||
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnFromBankToFutureByBank(self, data):
|
def onRtnFromBankToFutureByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnFromFutureToBankByBank(self, data):
|
def onRtnFromFutureToBankByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromBankToFutureByBank(self, data):
|
def onRtnRepealFromBankToFutureByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromFutureToBankByBank(self, data):
|
def onRtnRepealFromFutureToBankByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnFromBankToFutureByFuture(self, data):
|
def onRtnFromBankToFutureByFuture(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnFromFutureToBankByFuture(self, data):
|
def onRtnFromFutureToBankByFuture(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromBankToFutureByFutureManual(self, data):
|
def onRtnRepealFromBankToFutureByFutureManual(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromFutureToBankByFutureManual(self, data):
|
def onRtnRepealFromFutureToBankByFutureManual(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnQueryBankBalanceByFuture(self, data):
|
def onRtnQueryBankBalanceByFuture(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnBankToFutureByFuture(self, data, error):
|
def onErrRtnBankToFutureByFuture(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnFutureToBankByFuture(self, data, error):
|
def onErrRtnFutureToBankByFuture(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnRepealBankToFutureByFutureManual(self, data, error):
|
def onErrRtnRepealBankToFutureByFutureManual(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnRepealFutureToBankByFutureManual(self, data, error):
|
def onErrRtnRepealFutureToBankByFutureManual(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onErrRtnQueryBankBalanceByFuture(self, data, error):
|
def onErrRtnQueryBankBalanceByFuture(self, data, error):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromBankToFutureByFuture(self, data):
|
def onRtnRepealFromBankToFutureByFuture(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnRepealFromFutureToBankByFuture(self, data):
|
def onRtnRepealFromFutureToBankByFuture(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspFromBankToFutureByFuture(self, data, error, n, last):
|
def onRspFromBankToFutureByFuture(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspFromFutureToBankByFuture(self, data, error, n, last):
|
def onRspFromFutureToBankByFuture(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRspQueryBankAccountMoneyByFuture(self, data, error, n, last):
|
def onRspQueryBankAccountMoneyByFuture(self, data, error, n, last):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnOpenAccountByBank(self, data):
|
def onRtnOpenAccountByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnCancelAccountByBank(self, data):
|
def onRtnCancelAccountByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnChangeAccountByBank(self, data):
|
def onRtnChangeAccountByBank(self, data):
|
||||||
""""""
|
""""""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def connect(self, userID, password, brokerID, address):
|
def connect(self, userID, password, brokerID, address):
|
||||||
"""初始化连接"""
|
"""初始化连接"""
|
||||||
|
Loading…
Reference in New Issue
Block a user