def onFrontConnected(self): """服务器连接""" self.connectionStatus = True logger.info(u'交易服务器连接成功') self.login()
def onRspSettlementInfoConfirm(self, data, error, n, last): """确认结算信息回报""" logger.info(u'结算信息确认完成') self._server.onLogin(self.frontID, self.sessionID) # 查询合约代码 self.reqID += 1 self.reqQryInstrument({}, self.reqID)
def onRspUserLogout(self, data, error, n, last): """登出回报""" # 如果登出成功,推送日志信息 if error['ErrorID'] == 0: self.loginStatus = False logger.info(u'交易服务器登出完成') # 否则,推送错误信息 else: self._log_err(u'服务器登出失败', data, error)
def onRspUserLogin(self, data, error, n, last): """登陆回报""" # 如果登录成功,推送日志信息 if error['ErrorID'] == 0: self.frontID = data['FrontID'] self.sessionID = data['SessionID'] self.loginStatus = True logger.info(u'交易服务器登录完成') # 确认结算信息 req = {} req['BrokerID'] = self.brokerID req['InvestorID'] = self.userID self.reqID += 1 self.reqSettlementInfoConfirm(req, self.reqID) # 否则,推送错误信息 else: self._log_err(u'交易服务器登录失败', data, error)