Coinbase Pro python API - place_market_order() 使用了错误的金额

Coinbase Pro python API - place_market_order() uses wrong amount

作为参考,这是 python 版本的 GitHub:https://github.com/danpaquin/coinbasepro-python

我的代码旨在将我的美元余额平均分配给最多 3 个账户。下面是为我的代码创建的日志,证明它的值是准确的

Choosing out of random, we'll be purchasing these: 
['SUSHIBUSD', 'NMRBUSD', 'FORTHBUSD']
Placing order for FORTH-USD for the amount of: 6.08
Placing order for NMR-USD for the amount of: 6.08
Placing order for SUSHI-USD for the amount of: 6.08
for b in buy:
    coin = Coins.Coinbase[index[temp]]
    LOG.write("Placing order for " + coin + " for the amount of: ")
    LOG.write(USD)
    LOG.write("\n")
    Bot.place_market_order(str(coin), 'buy', USD)
    temp += 1

本来USD Balance持有18.25,代码确定金额后,6.08就是USD的价值。不幸的是,在我的 Coinbase 订单历史记录中,显示已使用全部余额,留下 0 美元余额,none 留给其他账户。我试图将值保持为 $X.XX 格式的浮点数或将 USD 更改为字符串值,none 显示出任何差异。

问题:为什么?我错过了什么吗? LOG 显示 USD 具有正确的值,因此对函数的调用应该是

Bot.place_market_order('FORTH-USD', 'buy', '6.08')

但它使用的是 all 就好像它是

Bot.place_market_order('FORTH-USD', 'buy', '18.25')
or
Bot.place_market_order('FORTH-USD', 'buy', 'all')

检查代码后,我发现 place_market_order[1] 需要“大小”或“资金”才能下订单 [2]。

根据您的示例,您在位置上传递了“6.08”。这意味着您正在填充定义为基础货币的“大小”参数,在您的情况下为“FORTH”。鉴于 FORTH 高于 19 美元(根据撰写本文时),这意味着您正在尝试使用 115.52 美元,而不是 6.08 美元,因此使用了全部金额。

如果您想使用美元(这是 FORTHUSD 符号的报价资产,您应该使用 Bot.place_market_order('FORTH-USD', 'buy', funds='6.08')


[1] https://github.com/danpaquin/coinbasepro-python/blob/5658b2212b0fe39dde18b792f34aeaf81dda6640/cbpro/authenticated_client.py#L381

[2] https://docs.pro.coinbase.com/#place-a-new-order