Skip to content

Book subscription on websocket is not working #49

@DukeOfRI

Description

@DukeOfRI

I am trying to use the book subscription on the websocket. If I run the code that is in the example on the website, I get an error. I am referring to the python example here: https://docs.bitvavo.com/#tag/Market-data-subscription-WebSocket/paths/~1subscribeBook/post

Python 3.12.1
python_bitvavo_api 1.4.1

Steps to reproduce:

from python_bitvavo_api.bitvavo import Bitvavo

def callback(response):
    print(f"Callback: {response}")  # Note that json.dumps from documentation also doesn't work

def errorCallback(error):
    raise RuntimeError()

bitvavo = Bitvavo()
websocket = bitvavo.newWebsocket()
websocket.setErrorCallback(errorCallback)

websocket.subscriptionBook("BTC-EUR", callback)

I get the following traceback.

Traceback (most recent call last):
  File "..\.venv\Lib\site-packages\websocket\_app.py", line 660, in _callback
    callback(self, *args)
  File "..\.venv\Lib\site-packages\python_bitvavo_api\bitvavo.py", line 485, in on_message
    callbacks['subscriptionBook'][market](ws, msg)
  File "..\.venv\Lib\site-packages\python_bitvavo_api\bitvavo.py", line 78, in processLocalBook
    ws.localBook[market]['bids'] = message['response']['bids']
    ^^^^^^^^^^^^
AttributeError: 'WebSocketApp' object has no attribute 'localBook'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions