I’ve tried various posts on here with working websockets but can’t get them to work. Looks like coinbase advanced websocket needs the api keys and I put those in and still couldn’t get it to work.
Here’s my scenario. I have a websocket that works with coinbase pro and I’m trying to convert it to work with coinbase advanced. I had installed a package from github called “cbpro” and used that for the websocket on coinbase pro. I would run the websocket every 20 seconds or so and bring the prices in. I’m not wanting it to run continuously. It also put it in a dataframe and returned the results.
Here is my code for the coinbase pro websocket. Can anyone convert this to work with coinbase advanced? Any help is appreciated.
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 = [“00-USD”,
“1INCH-USD”,
“AAVE-USD”,
“ABT-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()