mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2026-01-27 01:14:26 +01:00
Merge pull request #6 from JacobPlaster/fix-subscriptions
subscription: fix unsubscrbe
This commit is contained in:
@@ -278,6 +278,8 @@ Get the public orderbook of a given symbol
|
||||
|
||||
For more info on how to use this library please see the example scripts in the `bfxapi/examples` directory. Here you will find usage of all interface exposed functions for both the rest and websocket.
|
||||
|
||||
Also please see [this medium article](https://medium.com/@Bitfinex/15f201ad20d4) for a tutorial.
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it ( https://github.com/[my-github-username]/bitfinex/fork )
|
||||
|
||||
@@ -39,7 +39,7 @@ class Subscription:
|
||||
"""
|
||||
if not self.is_subscribed():
|
||||
raise Exception("Subscription is not subscribed to websocket")
|
||||
payload = {'event': 'unsubscribe', 'chan_id': self.chan_id}
|
||||
payload = {'event': 'unsubscribe', 'chanId': self.chan_id}
|
||||
await self._ws.send(json.dumps(payload))
|
||||
|
||||
async def subscribe(self):
|
||||
|
||||
@@ -39,7 +39,7 @@ class Subscription:
|
||||
"""
|
||||
if not self.is_subscribed():
|
||||
raise Exception("Subscription is not subscribed to websocket")
|
||||
payload = {'event': 'unsubscribe', 'chan_id': self.chan_id}
|
||||
payload = {'event': 'unsubscribe', 'chanId': self.chan_id}
|
||||
await self._ws.send(json.dumps(payload))
|
||||
|
||||
async def subscribe(self):
|
||||
|
||||
@@ -67,11 +67,11 @@ class BfxRest:
|
||||
# Public Data #
|
||||
##################################################
|
||||
|
||||
async def get_seed_candles(self, symbol):
|
||||
async def get_seed_candles(self, symbol, tf='1m'):
|
||||
"""
|
||||
Used by the honey framework, this function gets the last 4k candles.
|
||||
"""
|
||||
endpoint = 'candles/trade:1m:{}/hist?limit=5000&_bfx=1'.format(symbol)
|
||||
endpoint = 'candles/trade:{}:{}/hist?limit=5000&_bfx=1'.format(tf, symbol)
|
||||
time_difference = (1000 * 60) * 5000
|
||||
# get now to the nearest min
|
||||
now = int(round((time.time() // 60 * 60) * 1000))
|
||||
|
||||
@@ -194,7 +194,10 @@ class BfxWebsocket(GenericWebsocket):
|
||||
await self.subscriptionManager.confirm_unsubscribe(data)
|
||||
|
||||
async def _system_error_handler(self, data):
|
||||
self._emit('error', data)
|
||||
err_string = self.ERRORS[data.get('code', 10000)]
|
||||
err_string = "{} - {}".format(self.ERRORS[data.get('code', 10000)],
|
||||
data.get("msg", ""))
|
||||
self._emit('error', Exception(err_string))
|
||||
|
||||
async def _system_auth_handler(self, data):
|
||||
if data.get('status') == 'FAILED':
|
||||
|
||||
@@ -91,7 +91,7 @@ class SubscriptionManager:
|
||||
|
||||
This function is mostly used to force the channel to produce a fresh snapshot.
|
||||
"""
|
||||
sub = self.subscriptions_chanid[chan_d]
|
||||
sub = self.subscriptions_chanid[chan_id]
|
||||
|
||||
async def re_sub():
|
||||
await sub.subscribe()
|
||||
|
||||
Reference in New Issue
Block a user