diff --git a/vnpy/api/bitfinex/vnbitfinex.py b/vnpy/api/bitfinex/vnbitfinex.py index 4e1b10bb..bd5aa189 100644 --- a/vnpy/api/bitfinex/vnbitfinex.py +++ b/vnpy/api/bitfinex/vnbitfinex.py @@ -32,7 +32,7 @@ class BitfinexApi(object): """""" self.ws = websocket.create_connection(WEBSOCKET_V2_URL) - self.active =True + self.active = True self.thread = Thread(target=self.run) self.thread.start() @@ -61,11 +61,21 @@ class BitfinexApi(object): self.onError(msg) self.reconnect() + #---------------------------------------------------------------------- + def close(self): + """""" + self.active = False + + if self.thread: + self.thread.join() + + if self.restThread: + self.thread.join() + #---------------------------------------------------------------------- def onConnect(self): """""" print 'connected' - #---------------------------------------------------------------------- def onData(self, data):