Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README file shows incorrect example for WSClient and WSUserClient heartbeats methods #85

Closed
djflux opened this issue Dec 6, 2024 · 2 comments

Comments

@djflux
Copy link

djflux commented Dec 6, 2024

The main README.md file adds parameters to the heartbeats() and heartbeats_unsubscribe() methods when the coinbase.github.io documentation indicates that these methods do not accept parameters.

The lines in the README file are:

client.heartbeats(product_ids=["BTC-USD", "ETH-USD"])

client.heartbeats_unsubscribe(product_ids=["BTC-USD", "ETH-USD"])

The coinbase.github.io documentation for the referenced methods are here and those docs show (self) as the only argument:

https://coinbase.github.io/coinbase-advanced-py/coinbase.websocket.html#coinbase.websocket.WSClient.heartbeats
https://coinbase.github.io/coinbase-advanced-py/coinbase.websocket.html#coinbase.websocket.WSClient.heartbeats_unsubscribe
https://coinbase.github.io/coinbase-advanced-py/coinbase.websocket.user.html#coinbase.websocket.WSUserClient.heartbeats
https://coinbase.github.io/coinbase-advanced-py/coinbase.websocket.user.html#coinbase.websocket.WSUserClient.heartbeats_unsubscribe

Test Environment

I installed the coinbase-advanced-py via pip3 install coinbase-advanced-py inside a Red Hat UBI9 Python 3.12 docker container. When trying the commands listed in the README a TypeError is returned:

>>> from coinbase.websocket import WSClient,WSUserClient
>>> def on_message(msg):
...     print(msg)
... 
>>> client = WSClient(on_message=on_message)
>>> user_client = WSUserClient(on_message=on_message)
>>> 
>>> client.open()
>>> user_client.open()
>>> client.heartbeats(product_ids=["BTC-USD", "ETH-USD"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: heartbeats() got an unexpected keyword argument 'product_ids'
>>> user_client.heartbeats(product_ids=["BTC-USD", "ETH-USD"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: heartbeats() got an unexpected keyword argument 'product_ids'

I've attached a log file with the entire docker and installation command outputs for reference: README-issue.log

Versions

MacOS Ventura 13.6.9
Docker Desktop v4.36.0
Red Hat UBI9 Python 3.12 image: registry.access.redhat.com/ubi9/python-312:9.5-1733164709 88ea2d10c741

Data from PIP package METADATA file:

Metadata-Version: 2.1
Name: coinbase-advanced-py
Version: 1.8.2
Summary: Coinbase Advanced API Python SDK
Home-page: https://github.com/coinbase/coinbase-advanced-py
Author: Coinbase
License: Apache 2.0
Keywords: Coinbase,Advanced Trade,API,Advanced API

Solution Suggestion

Using no input parameters results in expected behavior:

>>> client.heartbeats()
>>> time.sleep(2)
{"channel":"subscriptions","client_id":"","timestamp":"2024-12-06T17:55:09.15020546Z","sequence_num":6,"events":[{"subscriptions":{"heartbeats":["heartbeats"]}}]}
{"channel":"heartbeats","client_id":"","timestamp":"2024-12-06T17:55:09.532711507Z","sequence_num":7,"events":[{"current_time":"2024-12-06 17:55:09.530511264 +0000 UTC m=+170873.540093264","heartbeat_counter":170871}]}
{"channel":"heartbeats","client_id":"","timestamp":"2024-12-06T17:55:10.533900172Z","sequence_num":8,"events":[{"current_time":"2024-12-06 17:55:10.53051926 +0000 UTC m=+170874.540101260","heartbeat_counter":170872}]}
>>> client.heartbeats_unsubscribe()
>>> 
>>> {"channel":"subscriptions","client_id":"","timestamp":"2024-12-06T17:55:11.158043234Z","sequence_num":9,"events":[{"subscriptions":{}}]}

>>> user_client.heartbeats()
>>> time.sleep(2)
{"channel":"subscriptions","client_id":"","timestamp":"2024-12-06T17:55:24.061525223Z","sequence_num":7,"events":[{"subscriptions":{"heartbeats":["heartbeats"]}}]}
{"channel":"heartbeats","client_id":"","timestamp":"2024-12-06T17:55:24.678624018Z","sequence_num":8,"events":[{"current_time":"2024-12-06 17:55:24.678576985 +0000 UTC m=+268007.465323498","heartbeat_counter":268005}]}
{"channel":"heartbeats","client_id":"","timestamp":"2024-12-06T17:55:25.678859295Z","sequence_num":9,"events":[{"current_time":"2024-12-06 17:55:25.67885075 +0000 UTC m=+268008.465597263","heartbeat_counter":268006}]}
>>> user_client.heartbeats_unsubscribe()
>>> 
>>> {"channel":"subscriptions","client_id":"","timestamp":"2024-12-06T17:55:26.06345944Z","sequence_num":10,"events":[{"subscriptions":{}}]}

I can create a quick pull request to fix the README file if anyone wants it.

Copy link

github-actions bot commented Dec 6, 2024

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord).

@urischwartz-cb
Copy link
Contributor

Thanks for pointing out. Resolved with #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants