Reputation: 1121
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?
Upvotes: 0
Views: 204
Reputation: 209
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',
}
Upvotes: 2