diff --git a/vnpy/trader/gateway/ctpGateway/ctpGateway.py b/vnpy/trader/gateway/ctpGateway/ctpGateway.py index f9390b2a..c218c289 100644 --- a/vnpy/trader/gateway/ctpGateway/ctpGateway.py +++ b/vnpy/trader/gateway/ctpGateway/ctpGateway.py @@ -452,7 +452,8 @@ class CtpTdApi(TdApi): self.connectionStatus = False # 连接状态 self.loginStatus = False # 登录状态 - self.authStatus = False + self.authStatus = False # 验证状态 + self.loginFailed = False # 登录失败(账号密码错误) self.userID = EMPTY_STRING # 账号 self.password = EMPTY_STRING # 密码 @@ -530,6 +531,9 @@ class CtpTdApi(TdApi): err.errorID = error['ErrorID'] err.errorMsg = error['ErrorMsg'].decode('gbk') self.gateway.onError(err) + + # 标识登录失败,防止用错误信息连续重复登录 + self.loginFailed = True #---------------------------------------------------------------------- def onRspUserLogout(self, data, error, n, last): @@ -1335,6 +1339,10 @@ class CtpTdApi(TdApi): #---------------------------------------------------------------------- def login(self): """连接服务器""" + # 如果之前有过登录失败,则不再进行尝试 + if self.loginFailed: + return + # 如果填入了用户名密码等,则登录 if self.userID and self.password and self.brokerID: req = {}