[Fix]Close #906,Bitfinex接口新增onConnect回调函数

This commit is contained in:
vn.py 2018-06-10 11:53:09 +08:00
parent dfe0304f74
commit 70ed2dfd66
2 changed files with 16 additions and 3 deletions

View File

@ -39,11 +39,15 @@ class BitfinexApi(object):
self.restThread = Thread(target=self.runRest)
self.restThread.start()
self.onConnect()
#----------------------------------------------------------------------
def reconnect(self):
""""""
self.ws = websocket.create_connection(WEBSOCKET_V2_URL)
self.onConnect()
#----------------------------------------------------------------------
def run(self):
""""""
@ -57,6 +61,12 @@ class BitfinexApi(object):
self.onError(msg)
self.reconnect()
#----------------------------------------------------------------------
def onConnect(self):
""""""
print 'connected'
#----------------------------------------------------------------------
def onData(self, data):
""""""

View File

@ -182,7 +182,10 @@ class GatewayApi(BitfinexApi):
self.start()
self.writeLog(u'交易API启动成功')
for symbol in symbols:
#----------------------------------------------------------------------
def onConnect(self):
""""""
for symbol in self.symbols:
self.subscribe(symbol, 'ticker')
self.subscribe(symbol, 'book')
self.writeLog(u'行情推送订阅成功')