I am trying to obtain the ticker channel data via a websocket. I am getting a response with some data, however the data I am getting is not matching the what it is suppose to show.
I have tried doing what the API specifies. The API (https://docs.pro.coinbase.com/#the-ticker-channel) says to send the request as follows:
params = { "type": "subscribe", "channels": [{"name": "ticker", "product_ids": ["BTC-USD"]}] }
Now this works, and I get a response, however the response I get is:
{
"type":"ticker",
"sequence":9568995003,
"product_id":"BTC-USD",
"price":"7779.00000000",
"open_24h":"7895.99000000",
"volume_24h":"19546.97986005",
"low_24h":"7467.10000000",
"high_24h":"7945.50000000",
"volume_30d":"569908.80402872",
"best_bid":"7775.66",
"best_ask":"7778.81"
}
when the api says the output should be: { "type": "ticker", "trade_id": 20153558, "sequence": 3262786978, "time": "2017-09-02T17:05:49.250000Z", "product_id": "BTC-USD", "price": "4388.01000000", "side": "buy", // Taker side "last_size": "0.03000000", "best_bid": "4388", "best_ask": "4388.01" }
As you can see, I am missing the last_size, and side. I am unsure as to what I am doing wrong.
from websocket import create_connection
import json
URL = "wss://ws-feed.pro.coinbase.com"
ws = create_connection(URL)
params = {
"type": "subscribe",
"channels": [{"name": "ticker", "product_ids": ["BTC-USD"]}]
}
def single():
ws.send(json.dumps(params))
result = ws.recv()
print(result)
single()
The expected output should include the last_size, and side tags. Any help is greatly appreciated.