简体   繁体   English

Gdax API:使用美元购买/出售

[英]Gdax API: Buy/Sell with USD

I'm looking at Gdax api and gdax-python library, looks like json request to by/sell is in this format: 我正在查看Gdax api和gdax-python库,看起来像通过/出售的json请求采用以下格式:

# 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? 使用此API或其他方法,是否可以指定购买USD而不是硬币大小的USD

You cannot change API body the way you ask for. 您无法按要求更改API主体。 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', }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM