[Mod] change connect_status control
This commit is contained in:
parent
01dbd2915d
commit
ca16e4b58e
@ -239,7 +239,6 @@ class CtpMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is connected.
|
Callback when front server is connected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("行情服务器连接成功")
|
self.gateway.write_log("行情服务器连接成功")
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
@ -247,7 +246,6 @@ class CtpMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is disconnected.
|
Callback when front server is disconnected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -325,6 +323,8 @@ class CtpMdApi(MdApi):
|
|||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
# If already connected, then login immediately.
|
# If already connected, then login immediately.
|
||||||
elif not self.login_status:
|
elif not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
@ -393,7 +393,6 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("交易服务器连接成功")
|
self.gateway.write_log("交易服务器连接成功")
|
||||||
|
|
||||||
if self.auth_code:
|
if self.auth_code:
|
||||||
@ -403,7 +402,6 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
def onFrontDisconnected(self, reason: int):
|
def onFrontDisconnected(self, reason: int):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -668,6 +666,8 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
else:
|
else:
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
|
@ -239,7 +239,6 @@ class CtpMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is connected.
|
Callback when front server is connected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("行情服务器连接成功")
|
self.gateway.write_log("行情服务器连接成功")
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
@ -247,7 +246,6 @@ class CtpMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is disconnected.
|
Callback when front server is disconnected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -324,6 +322,8 @@ class CtpMdApi(MdApi):
|
|||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
# If already connected, then login immediately.
|
# If already connected, then login immediately.
|
||||||
elif not self.login_status:
|
elif not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
@ -392,7 +392,6 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("交易服务器连接成功")
|
self.gateway.write_log("交易服务器连接成功")
|
||||||
|
|
||||||
if self.auth_code:
|
if self.auth_code:
|
||||||
@ -402,7 +401,6 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
def onFrontDisconnected(self, reason: int):
|
def onFrontDisconnected(self, reason: int):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -667,6 +665,8 @@ class CtpTdApi(TdApi):
|
|||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
else:
|
else:
|
||||||
self.authenticate()
|
self.authenticate()
|
||||||
|
|
||||||
|
@ -228,7 +228,6 @@ class FemasMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is connected.
|
Callback when front server is connected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("行情服务器连接成功")
|
self.gateway.write_log("行情服务器连接成功")
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
@ -236,7 +235,6 @@ class FemasMdApi(MdApi):
|
|||||||
"""
|
"""
|
||||||
Callback when front server is disconnected.
|
Callback when front server is disconnected.
|
||||||
"""
|
"""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"行情服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -307,10 +305,12 @@ class FemasMdApi(MdApi):
|
|||||||
if not self.connect_status:
|
if not self.connect_status:
|
||||||
path = get_folder_path(self.gateway_name.lower())
|
path = get_folder_path(self.gateway_name.lower())
|
||||||
self.createFtdcMdApi(str(path) + "\\Md")
|
self.createFtdcMdApi(str(path) + "\\Md")
|
||||||
# 订阅主题
|
|
||||||
self.subscribeMarketDataTopic(100, 2)
|
self.subscribeMarketDataTopic(100, 2)
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
# If already connected, then login immediately.
|
# If already connected, then login immediately.
|
||||||
elif not self.login_status:
|
elif not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
@ -372,14 +372,12 @@ class FemasTdApi(TdApi):
|
|||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = True
|
|
||||||
self.gateway.write_log("交易服务器连接成功")
|
self.gateway.write_log("交易服务器连接成功")
|
||||||
|
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def onFrontDisconnected(self, reason: int):
|
def onFrontDisconnected(self, reason: int):
|
||||||
""""""
|
""""""
|
||||||
self.connect_status = False
|
|
||||||
self.login_status = False
|
self.login_status = False
|
||||||
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
self.gateway.write_log(f"交易服务器连接断开,原因{reason}")
|
||||||
|
|
||||||
@ -607,6 +605,8 @@ class FemasTdApi(TdApi):
|
|||||||
|
|
||||||
self.registerFront(address)
|
self.registerFront(address)
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
|
self.connect_status = True
|
||||||
else:
|
else:
|
||||||
if not self.login_status:
|
if not self.login_status:
|
||||||
self.login()
|
self.login()
|
||||||
|
Loading…
Reference in New Issue
Block a user