From 673314b929965cef29a9a9deca0fb2bb91f8bef7 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 30 Aug 2017 21:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ctpGateway=E4=B8=AD=E5=BD=93?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF=E9=94=99=E8=AF=AF=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E9=87=8D=E5=A4=8D=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/ctpGateway/ctpGateway.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 = {}