0

I'm looking at Gdax api and gdax-python library, looks like json request to by/sell is in this format:

# Place an order
order = {
    'size': 1.0,
    'price': 1.0,
    'side': 'buy',
    'product_id': 'BTC-USD',
}
r = requests.post(api_url + 'orders', json=order, auth=auth)

Where size specifies the amount of coin.

Using this API or something else, is it possible to specify the amount to buy in USD instead of coin-size?

Mahyar
  • 1,011
  • 2
  • 17
  • 37

1 Answers1

2

You cannot change API body the way you ask for. What you can do is to calculate the order size based on the amount to buy in USD and current price. Assuming you wan to buy soon, close to the current price, and to invest the whole USD amount the order body will be:

# Place an order order = { 'size': currentPrice/USD_TO_BUY, 'price': currentPrice, 'side': 'buy', 'product_id': 'BTC-USD', }

Johan Duke
  • 199
  • 6