[Mod] change connect_status control

This commit is contained in:
vn.py 2019-07-02 18:06:12 +08:00
parent 01dbd2915d
commit ca16e4b58e
3 changed files with 13 additions and 13 deletions

View File

@ -239,7 +239,6 @@ class CtpMdApi(MdApi):
"""
Callback when front server is connected.
"""
self.connect_status = True
self.gateway.write_log("行情服务器连接成功")
self.login()
@ -247,7 +246,6 @@ class CtpMdApi(MdApi):
"""
Callback when front server is disconnected.
"""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
@ -325,6 +323,8 @@ class CtpMdApi(MdApi):
self.registerFront(address)
self.init()
self.connect_status = True
# If already connected, then login immediately.
elif not self.login_status:
self.login()
@ -393,7 +393,6 @@ class CtpTdApi(TdApi):
def onFrontConnected(self):
""""""
self.connect_status = True
self.gateway.write_log("交易服务器连接成功")
if self.auth_code:
@ -403,7 +402,6 @@ class CtpTdApi(TdApi):
def onFrontDisconnected(self, reason: int):
""""""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
@ -668,6 +666,8 @@ class CtpTdApi(TdApi):
self.registerFront(address)
self.init()
self.connect_status = True
else:
self.authenticate()

View File

@ -239,7 +239,6 @@ class CtpMdApi(MdApi):
"""
Callback when front server is connected.
"""
self.connect_status = True
self.gateway.write_log("行情服务器连接成功")
self.login()
@ -247,7 +246,6 @@ class CtpMdApi(MdApi):
"""
Callback when front server is disconnected.
"""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
@ -324,6 +322,8 @@ class CtpMdApi(MdApi):
self.registerFront(address)
self.init()
self.connect_status = True
# If already connected, then login immediately.
elif not self.login_status:
self.login()
@ -392,7 +392,6 @@ class CtpTdApi(TdApi):
def onFrontConnected(self):
""""""
self.connect_status = True
self.gateway.write_log("交易服务器连接成功")
if self.auth_code:
@ -402,7 +401,6 @@ class CtpTdApi(TdApi):
def onFrontDisconnected(self, reason: int):
""""""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
@ -667,6 +665,8 @@ class CtpTdApi(TdApi):
self.registerFront(address)
self.init()
self.connect_status = True
else:
self.authenticate()

View File

@ -228,7 +228,6 @@ class FemasMdApi(MdApi):
"""
Callback when front server is connected.
"""
self.connect_status = True
self.gateway.write_log("行情服务器连接成功")
self.login()
@ -236,7 +235,6 @@ class FemasMdApi(MdApi):
"""
Callback when front server is disconnected.
"""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
@ -307,10 +305,12 @@ class FemasMdApi(MdApi):
if not self.connect_status:
path = get_folder_path(self.gateway_name.lower())
self.createFtdcMdApi(str(path) + "\\Md")
# 订阅主题
self.subscribeMarketDataTopic(100, 2)
self.registerFront(address)
self.init()
self.connect_status = True
# If already connected, then login immediately.
elif not self.login_status:
self.login()
@ -372,14 +372,12 @@ class FemasTdApi(TdApi):
def onFrontConnected(self):
""""""
self.connect_status = True
self.gateway.write_log("交易服务器连接成功")
self.login()
def onFrontDisconnected(self, reason: int):
""""""
self.connect_status = False
self.login_status = False
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
@ -607,6 +605,8 @@ class FemasTdApi(TdApi):
self.registerFront(address)
self.init()
self.connect_status = True
else:
if not self.login_status:
self.login()