The API doc discourages polling on /ticker
endpoint, and recommend to use the websocket stream to listen for match message
But the match response only provide a price
and a side
(sell / buy)
How can I recreate the ticker data (price, ask and bid) from the websocket feed ?
{
“price”: “333.99”,
“size”: “0.193”,
“bid”: “333.98”,
“ask”: “333.99”,
“volume”: “5957.11914015”,
“time”: “2015-11-14T20:46:03.511254Z”
}
The ticker
endpoint and the websocket feed both return a 'price', but I guess that it's not the same. Is the price
from the ticker
endpoint some sort of average over time ?
How can I compute Bid
value, Ask
value ?
If I use these parameters in the subscribe message:
Each time a new trade is executed (and visible on http://www.gdax.com), I get this kind of message from the web socket:
Just after this particular message, I did a get on https://api.gdax.com/products/BTC-EUR/ticker, and I got this:
Present data are the same from web socket compared to the get request.
Please find below a complete test script implementing a web socket with this ticker.