0

我正在查看Gdax api和 gdax-python 库,看起来对 by/sell 的 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)

其中 size 指定硬币的数量。

使用这个 API 或其他东西,是否可以指定购买金额USD而不是硬币大小?

4

1 回答 1

2

您不能按照您的要求更改 API 正文。您可以做的是根据以美元购买的金额和当前价格计算订单大小。假设您想尽快购买,接近当前价格,并投资全部美元金额,订单主体将是:

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

于 2018-04-04T06:58:09.187 回答