bitfinexcom/bitfinex-api-py

Error running subscribe_trades_candles.py example.

ssemeniuta opened this issue · 4 comments

Issue type

  • bug
  • missing functionality
  • performance
  • feature request

Brief description

Running the example results in this error message:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/ssemeniuta/.pyenv/versions/3.8.5/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Users/ssemeniuta/.pyenv/versions/3.8.5/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "../../../bfxapi/websockets/generic_websocket.py", line 100, in _start_new_async_socket
    loop.run_until_complete(self._run_socket())
  File "/Users/ssemeniuta/.pyenv/versions/3.8.5/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "../../../bfxapi/websockets/generic_websocket.py", line 147, in _run_socket
    await self.on_message(sId, message)
  File "../../../bfxapi/websockets/bfx_websocket.py", line 503, in on_message
    await self._ws_data_handler(socketId, msg, message)
  File "../../../bfxapi/websockets/bfx_websocket.py", line 250, in _ws_data_handler
    return await self._WS_DATA_HANDLERS[dataEvent](data)
  File "../../../bfxapi/websockets/bfx_websocket.py", line 319, in _trade_executed_handler
    tradeObj = _parse_account_trade(tData)
  File "../../../bfxapi/websockets/bfx_websocket.py", line 75, in _parse_account_trade
    'exec_amount': tData[4],
IndexError: list index out of range

Steps to reproduce

  • Run the example.
Additional Notes:
  • When I remove trades subscription and leave only candles, the example works just fine.
  • I'm looking for a way to get all executed trades and not ones from my account. Is this example intended to show this usecase?
from pprint import pprint
pprint(tData)

Also, check your version of this repo is up to date

Hello @ssemeniuta, thanks for reporting this unexpected behaviour.
I reproduced it and fixed with PR #193. It will be released on pypi asap.
To proceed with your work you can momentarily put into requirements.txt the following line

-e git+https://github.com/bitfinexcom/bitfinex-api-py.git@refs/pull/193/merge#egg=bitfinex-api-py

thank you @itsdeka, just tried with the new version and the example works as expected.