Search code examples
pythoncoinbase-api

Coinbase API: buy and sell prices are not as accurate as the spot price


I need help figuring out if I'm doing something wrong with the API calls.

In python using the library provided by coinbase I run this code:

from coinbase.wallet.client import Client

client = Client(coinbase_API_key, coinbase_API_secret)

print(client.get_buy_price(currency_pair = 'SHIB-EUR'))
print(client.get_sell_price(currency_pair = 'SHIB-EUR'))
print(client.get_spot_price(currency_pair = 'SHIB-EUR'))

And the console gives me these values:

{
  "amount": "0.00",
  "base": "SHIB",
  "currency": "EUR"
}
{
  "amount": "0.00",
  "base": "SHIB",
  "currency": "EUR"
}
{
  "amount": "0.000043788348",
  "base": "SHIB",
  "currency": "EUR"
}

Am I doing something wrong or does the API not have accurate prices?


Solution

  • You probably just want to use the Ticker if you want the price:

    https://api.exchange.coinbase.com/products/SHIB-EUR/ticker

    to answer your question:

    Am I doing something wrong or does the API not have accurate prices?

    I think coinbase had some issues listing shib because of the 9 decimals so it's possible all the issues including the coinbase.com api hasn't solved them. OR they're not overly interested on showing the accurate price on .com because they like to overcharge with slipage anyway.