[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

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

View File

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