Advanced Trade Feedback

After integrating against WebSockets I have some suggestions that would have made my life easier.

The documentation doesn’t actually show the schema format of the messages coming from CoinBase. In my opinion, the schema doesn’t make a whole lot of sense and is a bit painful to work with.

As an example for tickers
The docs say to expect a message that looks like

{
   "type":"ticker",
   "sequence":29912240,
   "product_id":"BTC-USD",
   "price":"40552.26",
   "volume_24h":"0.43526841",
   "low_24h":"40552.26",
   "high_24h":"40662.06"
}

This is fine. But this isn’t really what comes over the wire.
Instead you get

{
	"channel": "ticker",
	"client_id": "",
	"timestamp": "2022-11-22T04:23:54.618364894Z",
	"sequence_num": 0,
	"events": [{
		"type": "snapshot",
		"tickers": [{
			"type": "ticker",
			"product_id": "BTC-USD",
			"price": "15801.22",
			"volume_24_h": "39927.87557223",
			"low_24_h": "15460",
			"high_24_h": "16257",
			"low_52_w": "15460",
			"high_52_w": "59526.51",
			"price_percent_chg_24_h": "-2.32280685270057"
		}]
	}]
}

What’s weird for me is an event contains a type (snapshot or update) and then a list of the actual events within the event. It would make a lot more sense (and be easier to work with) if it were flatter like this

{
	"channel": "ticker",
	"client_id": "",
	"timestamp": "2022-11-22T04:23:54.618364894Z",
	"sequence_num": 0,
	"events": [
		{
			"event_type": "snapshot",
			"type": "ticker",
			"product_id": "BTC-USD",
			"price": "15801.22",
			"volume_24_h": "39927.87557223",
			"low_24_h": "15460",
			"high_24_h": "16257",
			"low_52_w": "15460",
			"high_52_w": "59526.51",
			"price_percent_chg_24_h": "-2.32280685270057"
		},
		{
			"event_type": "update",
			"type": "ticker",
			"product_id": "BTC-USD",
			"price": "15801.11",
			"volume_24_h": "39927.87557223",
			"low_24_h": "15460",
			"high_24_h": "16257",
			"low_52_w": "15460",
			"high_52_w": "59526.51",
			"price_percent_chg_24_h": "-2.32348683128742"
		}
	]
}

In this format, it allows the client to iterate over each one without so many nested loops and temporary states to keep track of the “event type”

On a side note, I don’t know why exchanges are using JSON over WebSockets anymore. I’ve not found one that’s easy to work with. When open-source technologies like gRPC exist, designing these WebSocket API’s doesn’t make sense. With a gRPC endpoint, developers can have a fully working and very high-performance client up and running in minutes without reading any documentation. gRPC supports request and response style (REST) or bidirectional style communication (WebSocket). It would most likely reduce the overhead for the exchange, too, as encoding and decoding can often be less compute and memory intense than JSON and will consume a fraction of the bandwidth to send the messages.

gRPC doesn’t really work in web browsers which doesn’t make it a great option for Coinbases own website. Still, Protobuf also defines a JSON representation and often without too much extra effort, a server can offer a standard HTTP API, JSON over WebSocket AND a gRPC endpoint sharing the same implementation, all documented by the proto files.

This seems like a no-brainer for a new high-performance API in 2022.

All things being said, even though I think the WebSocket schemas could be better. Advanced trade WebSockets have been relatively easy to work with. Especially compared to the competition. Great work to the team at Coinbase!

3 Likes

Are there any updates on this?

Would be helpful if the product_id could be included in order messages sent in the user WebSocket stream. Makes things easier to group orders by product IDs. The client IDs work, but it means I have to scans all products to find an order.

{
      "type": "update",
      "orders": [
        {
          "order_id": "01a7f73b-8e67-4c05-9b6c-2c6695c12726",
          "client_order_id": "40931f27-08ae-48cb-a6ba-36c1c53133be",
          "cumulative_quantity": "0",
          "leaves_quantity": "10",
          "avg_price": "0",
          "total_fees": "0",
          "status": "OPEN"
        }
      ]
    }

I might not be understanding you correctly, but could you just open a new socket for each product? Then you don’t need to check the product on each order. You would just know what product it is based on which socket it comes in on.

I’m fetching the products I need using the REST API and subscribing to them using a single socket connection to update them. If I want to monitor all USD pairs, that would be over 200 connections verses just one. The ticker event has a product_id for example which lets me find the product and update it. Just need the same for the order events, which is present on PRO, but not on AT. Hope that makes sense.

1 Like

Hahaha okay, fair enough. At a rate limit of 1 connection every 4 seconds (per the docs) it would take over 10 minutes just to connect them all. Not exactly the easiest thing to test/troubleshoot :sweat_smile:

2 Likes

Can Coinbase document that OAuth 2.0 is officially supported with Advanced Trade API? Looks like it works based on our own testing, but your documentation only shows support for API key pair signing/authentication.

We’re working on an integrating with Coinbase and would prefer to authenticate our requests via OAuth 2.0 access tokens (with UX top of mind), as this flow mitigates the need for our mutual end-users to copy/paste API key pairs across apps.

Thank you!

My feedback is that it seems like you people are rushing the deprecation of the Pro side of things. You’re constantly pushing messages and announcements about forcing a migration, but your new system isnt even fledged yet and you’re extremely laggardly about answering questions. Tell your managers to calm the heck down.

5 Likes

Hello @tpunt! We’re happy to inform you that a migration page to show API Pro Mapping was already included on the Advance Trade API documentation. You may refer here. Thank you!

2 Likes

Is there an issue with Get Product Candles? I am getting:

The remote server returned an error: (500) Internal Server Error.

IsMutuallyAuthenticated : False
Cookies : {cb_dm=892ee873-8731-40c7-9461-7181ab33bbba,
__cf_bm=ScKONtj9y7wY9gaXCqnxJ.ohC93huDn8l.4BhIJjsdI-1670531117-0-AS55Oufcgm3o7q14JTJFIVfiV9o2eBNnVQ4d7lSx9BF/DbE38gaHbyMNG7I99sPTe1xP2qOWELkSSqKuayKQh6o=}
Headers : {Connection, Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Private-Network…}
SupportsHeaders : True
ContentLength : 80
ContentEncoding :
ContentType : application/json; charset=utf-8
CharacterSet : utf-8
Server : cloudflare
LastModified : 12/8/2022 1:29:08 PM
StatusCode : InternalServerError
StatusDescription : Internal Server Error
ProtocolVersion : 1.1
ResponseUri : https://api.coinbase.com/api/v3/brokerage/products/BTC-USD/candles?start=1670529094&end=1670525505&granularity=ONE_MINUTE
Method : GET
IsFromCache : False

Why does this Coinbase help page say Advanced Trade has Portfolios “In public beta; developer documentation is available” whereas everywhere else implies that portfolios aren’t supported?

https://help.coinbase.com/en/coinbase/trading-and-funding/advanced-trade/what-is-advanced-trade

Really need the ability to separate the balances for coins in separate portfolios.

FYI I just tested my custom script and everything is working. I am just guessing here from a quick glance but it looks like your start and end variables need to be switched.

So I have my own trading algorithm up and running for a few days at this point. All of the endpoints seem to work great/reliably. Only issue is the web socket feed for user seems to have errors every hour or so. Overall it works when I fill an order which is what I need it for, but would be nice to fix the issue. My code just reconnects when it fails so its not the end of the world. I get the following errors randomly with a keep alive of 15 seconds

{‘type’: ‘error’, ‘message’: ‘internal error’}
python error: Connection to remote host was lost
Handshake status 502 Bad Gateway

My Feedback

It is very bad. So bad, that i give up to implement Coinbase Advanced Trading “broker module” to mmbot.trade. So Coinbase will be removed from the support for good

1 Like

How can Coinbase justify forced migration from pro when advanced trade api is broken, has hardly any functionality and isn’t optimised for use and worst of all, there’s not even a testnet available? Who made this decision!? The exchange is literally unusable now! It’s madness! This is crazy. It’s not how professional exchanges operate.

5 Likes

What is the ETA to add product_id and side to the update message in user channel?

Is there a way to get around this 1 new connection every 4 seconds rule? I am writing an institutional trading tool and 1 WS per every 4 seconds is practically un-usable.

At the very least, please add the trade quantity and the maker side!

The company will also be shutting down several projects with a “lower probability of success.”

Considering how many problems the advanced trade api has been found to have, yeah this seems like exactly the time and environment to instead shut down the product that has worked for years.

I’m having this subscription issue as well. Has anyone figured out the cause? I’m revamping my connection recycling rn beacuse of it. Staying connected to the data feed is extremely important. I’m surprised there hasn’t been much reassurance from the staff here.

@arood we where dealing with something similar about a year or so ago. What’s your input on this?

1 Like