danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 738 forks source link

Websocketclient requires channel #371

Closed Londo-Mollari closed 4 years ago

Londo-Mollari commented 4 years ago

Hello, It appears that the websocketclient and orderbook will no longer run their demo code. Upon inspection of the replies from Coinbase:

{ "message": "Failed to subscribe", "reason": "No channels provided", "type": "error" }

This seems to be due to a change on the Coinbase end because unchanged code that I have had for a month no longer runs. I am trying to edit websocket_client.py but changing the following channels definition does not work:

class WebsocketClient(object): def __init__(self, url="wss://ws-feed.pro.coinbase.com", products=None, message_type="subscribe", mongo_collection=None, should_print=True, auth=False, api_key="", api_secret="", api_passphrase="", channels="'full'"):

I'm probably overlooking something - perhaps someone could review this and modify the base code if necessary?

pdoodling commented 4 years ago

Hi Londo-Mollari, add this to the demo code's on_open method: self.channels = ['ticker', 'user', 'matches', 'level2', 'full'] # includes all the options; revise to just what you need. Regards, Pups

Londo-Mollari commented 4 years ago

Thanks! I spent last evening poking at creating a custom subscription string and sending it but my Python skills are not very good - I'm actually using this as a learning tool.

I can confirm that your change worked! Thank you very much!

The base code needs to be updated at some point.