def connect(self):
        """初始化连接"""
        if not self.connected:
            if not os.path.exists(self.temp_path):
                os.makedirs(self.temp_path)
            self.createFtdcTraderApi(self.temp_path)
            self.subscribePrivateTopic(0)
            self.subscribePublicTopic(0)
            self.registerFront(self.address)
            self.init()
        else:
            if self.require_authentication:
                self.authenticate()
            else:
                self.login()