-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
Here is sample code to reproduce the error in Google Colab:
from coinbase.websocket import WSClient
symbol = "BAT-USD"
num_changes = 10
changes = []
def on_message(message):
m = json.loads(message)
if m["channel"] not in ["l2_data", "market_trades"]:
return
changes.append(message)
print(f"{len(changes)} changes logged ({m['channel']})")
if len(changes) > num_changes / 2:
raise Exception("Stop")
client = WSClient(on_message=on_message, verbose=True)
client.open()
client.subscribe(product_ids=[symbol], channels=["heartbeats", "level2", "market_trades"])
while len(changes) < num_changes:
time.sleep(0.1)
client.unsubscribe(product_ids=[symbol], channels=["heartbeats", "level2", "market_trades"])
client.close()
print("Done")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels