diff --git a/vnpy/gateway/ctp/ctp_gateway.py b/vnpy/gateway/ctp/ctp_gateway.py index 50f43152..c92781b7 100644 --- a/vnpy/gateway/ctp/ctp_gateway.py +++ b/vnpy/gateway/ctp/ctp_gateway.py @@ -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() diff --git a/vnpy/gateway/ctptest/ctptest_gateway.py b/vnpy/gateway/ctptest/ctptest_gateway.py index 992829fa..44d36fa3 100644 --- a/vnpy/gateway/ctptest/ctptest_gateway.py +++ b/vnpy/gateway/ctptest/ctptest_gateway.py @@ -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() diff --git a/vnpy/gateway/femas/femas_gateway.py b/vnpy/gateway/femas/femas_gateway.py index 2fd6a4e8..2911c9f2 100644 --- a/vnpy/gateway/femas/femas_gateway.py +++ b/vnpy/gateway/femas/femas_gateway.py @@ -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()