Esempio n. 1
0
 def OnFrontConnected(self) -> "void":
     print("OnFrontConnected")
     loginfield = api.CThostFtdcReqUserLoginField()
     loginfield.BrokerID = BROKERID
     loginfield.UserID = USERID
     loginfield.Password = PASSWORD
     loginfield.UserProductInfo = "python dll"
     self.tapi.ReqUserLogin(loginfield, 0)
     print("send login ok")
Esempio n. 2
0
 def OnFrontConnected(self):
     print("OnFrontConnected")
     #time.sleep( 60 )
     loginfield = api.CThostFtdcReqUserLoginField()
     loginfield.BrokerID = "8000"
     loginfield.UserID = "00001"
     loginfield.Password = "******"
     loginfield.UserProductInfo = "python dll"
     self.tapi.ReqUserLogin(loginfield, 0)
     print("send login ok")
Esempio n. 3
0
 def OnRspAuthenticate(
         self, pRspAuthenticateField: 'CThostFtdcRspAuthenticateField',
         pRspInfo: 'CThostFtdcRspInfoField', nRequestID: 'int',
         bIsLast: 'bool'):
     if not pRspInfo.ErrorID:
         obj = tdapi.CThostFtdcReqUserLoginField()
         obj.BrokerID = BROKERID
         obj.UserID = USERID
         obj.Password = PASSWORD
         obj.UserProductInfo = "python dll"
         self.api.ReqUserLogin(obj, 0)
     else:
         print('认证错误 {}'.format(pRspInfo.ErrorMsg))
Esempio n. 4
0
	def OnRspAuthenticate(self, pRspAuthenticateField: 'CThostFtdcRspAuthenticateField', pRspInfo: 'CThostFtdcRspInfoField', nRequestID: 'int', bIsLast: 'bool') -> "void":	
		print ("BrokerID=",pRspAuthenticateField.BrokerID)
		print ("UserID=",pRspAuthenticateField.UserID)
		print ("AppID=",pRspAuthenticateField.AppID)
		print ("AppType=",pRspAuthenticateField.AppType)		
		print ("ErrorID=",pRspInfo.ErrorID)
		print ("ErrorMsg=",pRspInfo.ErrorMsg)
		if not pRspInfo.ErrorID :
			loginfield = api.CThostFtdcReqUserLoginField()
			loginfield.BrokerID=BROKERID
			loginfield.UserID=USERID
			loginfield.Password=PASSWORD
			loginfield.UserProductInfo="python dll"
			self.tapi.ReqUserLogin(loginfield,0)
			print ("send login ok")
Esempio n. 5
0
 def OnRspAuthenticate(self, pRspAuthenticateField, pRspInfo, nRequestID,
                       bIsLast):
     print("BrokerID=", pRspAuthenticateField.BrokerID)
     print("UserID=", pRspAuthenticateField.UserID)
     print("AppID=", pRspAuthenticateField.AppID)
     print("AppType=", pRspAuthenticateField.AppType)
     print("ErrorID=", pRspInfo.ErrorID)
     print("ErrorMsg=", pRspInfo.ErrorMsg)
     if not pRspInfo.ErrorID:
         loginfield = api.CThostFtdcReqUserLoginField()
         loginfield.BrokerID = self.BROKERID
         loginfield.UserID = self.USERID
         loginfield.Password = self.PASSWORD
         loginfield.UserProductInfo = "python dll"
         self.tapi.ReqUserLogin(loginfield, 0)
         print("send login ok")
Esempio n. 6
0
def main():
    tradeapi = api.CThostFtdcTraderApi_CreateFtdcTraderApi()
    tradespi = CTradeSpi(tradeapi)
    loginfield = api.CThostFtdcReqUserLoginField()
    loginfield.BrokerID = "8000"
    loginfield.UserID = "000005"
    loginfield.Password = "******"
    loginfield.UserProductInfo = "python dll"
    tradeapi.RegisterFront("tcp://172.19.125.39:39233")
    tradeapi.RegisterSpi(tradespi)
    tradeapi.SubscribePrivateTopic(api.THOST_TERT_RESUME)
    tradeapi.SubscribePublicTopic(api.THOST_TERT_RESUME)
    tradeapi.Init()
    time.sleep(2)
    tradeapi.ReqUserLogin(loginfield, 0)
    tradeapi.Join()
Esempio n. 7
0
 def OnRspAuthenticate(
         self, pRspAuthenticateField: 'CThostFtdcRspAuthenticateField',
         pRspInfo: 'CThostFtdcRspInfoField', nRequestID: 'int',
         bIsLast: 'bool') -> "void":
     print("BrokerID=", pRspAuthenticateField.BrokerID)
     print("UserID=", pRspAuthenticateField.UserID)
     print("AppID=", pRspAuthenticateField.AppID)
     print("AppType=", pRspAuthenticateField.AppType)
     print("ErrorID=", pRspInfo.ErrorID)
     print("ErrorMsg=", pRspInfo.ErrorMsg)
     if not pRspInfo.ErrorID:
         print("验证穿透已完成,开始登录")
         loginfield = api.CThostFtdcReqUserLoginField()
         loginfield.BrokerID = self.BrokerID
         loginfield.UserID = self.UserID
         loginfield.Password = self.PassWord
         loginfield.UserProductInfo = "python dll"
         # 请求账户登录
         time.sleep(2)
         self.tapi.ReqUserLogin(loginfield, 0)
         print("send login ok")