[Fix]Close #906,Bitfinex接口新增onConnect回调函数
This commit is contained in:
parent
dfe0304f74
commit
70ed2dfd66
@ -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):
|
||||||
""""""
|
""""""
|
||||||
|
@ -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'交易推送订阅成功')
|
||||||
|
Loading…
Reference in New Issue
Block a user