Market ioc order | websocket prices

I am encountering difficulties in understanding how the various prices we find in the websocket, API endpoint, or directly on the Coinbase interface actually work.

Originally, I thought I understood, but I can’t discern why I’m seeing different prices. Perhaps I’ve missed something.

My strategy primarily involves using IOC prices through the dedicated endpoint: /orders with an IOC payload.

I place orders based on the websocket feed, but after passing it, I’ve noticed that the transaction price often differ. I’m struggling to determine whether this discrepancy is due to latency in the websocket itself or a misunderstanding of the relationship between IOC prices and websocket (WS) prices.

Is the IOC price equal to the ticker price received in the websocket feed? If not, how can I obtain it?

I’ve also observed that the prices displayed on the Coinbase UI don’t exactly match those I receive from the websocket feed, especially when I retrospectively compare specific websocket records and UI plot points.

So, are the interface prices equivalent to the IOC prices available in the interface, and are they different from websocket prices?

To summarize, prices are available through various sources:

  •{product_id}/ticker - displays multiple trade matches with varying sizes (IOC might be a function of this).

  •{product_id} - shows a single price for an asset: possibly the current price, so either the IOC price, the last match, or something else?

  • Websocket - According to the documentation, it reflects the last match prices, but I’ve noticed a discrepancy between the prices from the websocket and the market_trades endpoint. Some values are very close, but they don’t share the same timestamp, and the overall WS price might be a function of the previous values.

Any clarification on these fundamental concepts would be greatly appreciated.

Thank you.

You probably want to use level2 channel to know actual prices but that channel is batched to ~500ms! So you might get half second old info! In Pro level2 delivered changes as soon as possible and had dedicated level2_batch channel that batched messages every 50ms.

market_trades should send update when actual trade has happened. But also this channel batches updates and you might need to wait up to 250ms to find that trade has happened.

1 Like

Thanks a lot for your answer.

So to resume, if I want to know in advance the price of an IOC order, I should look at the level2 channel?

It looks really long to get updated on last prices…

Is there another efficient way ?
Do we have less limitation using Coinbase One ? Is there any service to be updated in real time?

I think it should be best way to know amount and price someone is ready to buy or sell.

Perhaps, but websocket feed at least theoretically should be best way to know current prices. When you place order, it will be matched to whatever is current info on order book…

Depends on how you look at things…

Get Market Trades endpoint includes bid/ask and best_bid/best_ask. I think (but I am not sure) that these are states when trade did happen, not when you made request. So price has likely changed depending how old that trade is.

Get Product has only price - no idea what it means… There is also mid_market_price that should be middle point of best bid/ask.

Personally I have not used endpoints to keep track of product prices. When Pro was a thing I was using websocket feed for that.

Very likely no. But this is not something I could answer… You will need to wait for official answer.

Pro was good! Now when it has been shut down your only option is to use what is available…

Thank you once again. I’m beginning to think there are several issues with this API.

It seems they are steering users towards their WebSocket, which, in theory, should provide the best real-time updates. However, I’ve found that the pricing data is not entirely reliable.

For your information, here are the delays I’ve observed for some assets:

ETH-USDT: 14.38919091796875 seconds
BAT-BTC: 70.43922192382813 seconds
SOL-USDT: 0.682943115234375 seconds

Yes, these are measured in seconds. This represents the time taken for these assets to update from the last record. It suggests that there were no transactions during this period, which I find hard to believe. To obtain this information, I compared the asset timestamp in the WebSocket feed with the local timestamp of my machine when receiving the record. Essentially, it’s calculated as (local_timestamp - price_timestamp).

This leads me to think that either there’s an issue with my connection, or the WebSocket is not reliable. I’ve run multiple checks and conducted the same test focusing on a single asset, and the delay is consistently similar.

Ultimately, it appears that the WebSocket prices are different, seeming to update significantly after the last trades.

I plan to try using the level2 channel. Perhaps an update delay of half a second might be more accurate and acceptable.

I would suggest that you also include more active products when testing…

For example, I just looked at BAT-BTC! Last two trades at 09:44:38 and 09:07:01. So times you have measured are probably correct.

price_timestamp - with this you mean trade timestamp right? Prices/Order book does change without any trades happening. That is why I am suggesting to use level2 if you want to know actual price.

Sorry I forgot about Get Best Gid/Ask endpoint - you can try to use this if you don’t want to use level2 feed.