Heartbeats websocket

This is nice, however, why the glaring inconsistency in format:

  "timestamp": "2023-06-23T20:31:26.122969572Z",
  "sequence_num": 0,
  "events": [
      "current_time": "2023-06-23 20:31:56.121961769 +0000 UTC m=+91717.525857105",

I don’t think even pydantic can read that directly into a timestamp.

Also, is this a typo?

// Heartbeats Message
  "channel": "market_trades",

What is m=+-...?

For now, I’ll simply assume the timestamp field will have similar, but more readable time (although pydantic might invalidate the nanosecond accuracy if not trimmed in pre-validation)

Please provide feedback
@rishabh @Sandy
Thank you and Regards

Hey @MementoMori. Thank you for using Coinbase APIs. We appreciate you sharing this as a feedback with us. We will look intoit and reach out to you. Please keep in touch.

We have taken this as a feedback. The channel name will be corrected. m=+ is monotonic clock reading. You can read more about monotonic clocks here. For the time inconsistency, our team will work on it to change that. Thank you so much for sharing this with us and using our Advanced trade API. We look forward to more such feedbacks from you. Happy trading :slight_smile:

Hey @MementoMori! Hope you are doing well. This is just to let you know that the typo error has been fixed and we have successfully logged the request to standardize the m+ format. Thank you again for sharing such valuable feedbacks.

@Loop_11 , thank you for the update. Note also that the inconsistency encompasses the missing T, the nanoseconds precision, the timezone info and the unconventional space:
2023-06-23 20:31:56.121961769 +0000 UTC
as opposed to:
or preferably:
but then many endpoints would need to be changed
Thank you

@Loop_11 , Hi, It looks like the sequence_num is not specific to the channel subscribed
I get a mix of feed that are well sequenced but for various channels:

+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:57.631501653Z', 'sequence_num': 4, 'events': [{'type': 'snapshot', 'trades': [{'product_id': 'BTC-USD', 'tr...
+   WSResponse(data={'channel': 'subscriptions', 'client_id': '', 'timestamp': '2023-07-14T13:58:57.631685406Z', 'sequence_num': 5, 'events': [{'subscriptions': {'heartbeats': ['heartbeats'], 'level2': ['...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:58:57.932483518Z', 'sequence_num': 6, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': 'b...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:58:58.372761983Z', 'sequence_num': 7, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': 'b...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:58.709366919Z', 'sequence_num': 8, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'trad...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:58:58.877672492Z', 'sequence_num': 9, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': 'b...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.211075424Z', 'sequence_num': 10, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.307580413Z', 'sequence_num': 11, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.372297797Z', 'sequence_num': 12, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': '...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.412169782Z', 'sequence_num': 13, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.614121127Z', 'sequence_num': 14, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.808293759Z', 'sequence_num': 15, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:58:59.873765918Z', 'sequence_num': 16, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': '...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:59:00.113013537Z', 'sequence_num': 17, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'l2_data', 'client_id': '', 'timestamp': '2023-07-14T13:59:00.386838636Z', 'sequence_num': 18, 'events': [{'type': 'update', 'product_id': 'BTC-USD', 'updates': [{'side': '...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:59:00.408465142Z', 'sequence_num': 19, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...
+   WSResponse(data={'channel': 'market_trades', 'client_id': '', 'timestamp': '2023-07-14T13:59:00.612457157Z', 'sequence_num': 20, 'events': [{'type': 'update', 'trades': [{'product_id': 'BTC-USD', 'tra...

This creates a bunch of warnings between expected sequence_num and actual (which would be normal if the sequence_num is common to all subs)

Also, how to use the heartbeat_counter? In the example the sequence_num is 0 but counter is already well ahead:

  "events": [
      "current_time": "2023-06-23 20:31:56.121961769 +0000 UTC m=+91717.525857105",
      "heartbeat_counter": "3049",

Also, the subscriptions channel is not documented on the web
Thank you

@Loop_11 , After more reading, I realized that I forgot the ‘Best Practices’ and followed my previous multi-pair subscription architecture. I am re-factoring to do one ws connection per channel/pair, however, does the documentation hints that when doing so, each ws connection should actually do a:
connect for pair 1: subscribe channel+heartbeats, pair1
connect for pair2: subscribe channel+heartbeats, pair2

It makes sense, though I thought my previous method made sense too, until the sequence_num did not … lOl

Thank you

1 Like

@Loop_11 Could you help understanding how to subscribe for multiple pairs? My connector is very flaky and randomly hangs after subscribing to a few pairs. I get a lot of ConnectionResetError from the aiohttp/http_websocket.py
I create a connection, then immediately subscribe to heartbeats then awaut the pipeline tasks to have started and subscribe to the pair. I have one connection per pair and subscribe hearbeats and user for a pair on that ws connection
Thank you