Error handling with orders

I’m trying to execute a market order sell in Python. I am expecting the order to fail as I currently have the token staked (so it’s unavailable). I would expect there to be some decent error message returned but I’m just getting back a 400!

payload = {
“client_order_id”: “7268540131810426987”,
“product_id”: “ADA-GBP”,
“side”: “SELL”,
“order_configuration”: {
“market_market_ioc”: {
“base_size”: “10.0”
}
}
}

Endpoint: /api/v3/brokerage/orders

400 Client Error: Bad Request for url: https://api.coinbase.com/api/v3/brokerage/orders

Is there a problem with my order above resulting in the 400 or is it strange that a more descriptive error message is not being returned?

You get 400 without response body?

Actually I am seeing something in the body but not sure what it means?
‘json: cannot unmarshal number into Go value of type string’

Does the order payload look okay?

My code looks like this:

        order = {
            "client_order_id": str(np.random.randint(2**63)),
            "product_id": market,
            "side": "SELL",
            "order_configuration": {
                "market_market_ioc": {
                    "base_size": self.market_base_increment(market, base_quantity),
                }
            }
        }

Resulting in this:

I guess your problem might be that you are sending base_size as double not string.

1 Like

That worked, thanks a lot.