Here is the websocket I used with CoinBasePro. Notice it runs for 1.5 seconds and outputs the data to a dataframe. I had installed a package from github called cbpro that was also used. Can someone show me how to do this with Coinbase Advaced Trade without the need for an outside package from github?
import time
import cbpro
import numpy
import pandas as pd
results =
class myWebsocketClient(cbpro.WebsocketClient):
def on_open(self):
self.url = “wss://ws-feed.pro.coinbase.com/”
self.products = [“BTC-USD”
self.channels = [“ticker”]
def on_message(self, msg):
if “price” in msg and “product_id” in msg:
results.append(msg)
wsClient = myWebsocketClient()
wsClient.start()
time.sleep(1.5)
df = pd.DataFrame(results)
print(df.head())
wsClient.close()