From bbabd742ff3add740dc329489b99c3dd09aeca5b Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 10 Jun 2018 14:59:33 +0800 Subject: [PATCH] =?UTF-8?q?[Add]BitfinexApi=E6=96=B0=E5=A2=9Eclose?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/bitfinex/vnbitfinex.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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):