binance api 中的“精度”到底意味着什么?

问题描述 投票:0回答:1

我正在使用 python ccxt 在 binance 上下卖单。

order = exchange.create_order(symbol, 'market', 'sell', amount)

我已经获取了所需的精度,并且得到了 5。

markets = exchange.load_markets()
amount_precision = market['precision']['amount']

于是,我将原本

0.0002535009794671468384415698887
的金额精度设置为5,得到了
0.00025

但是当我创建具有此金额值的订单时,我收到错误:

binance amount of BTC/USDT:USDT must be greater than minimum amount precision of 3

虽然我将精度设置为5,这是所需的值。

精度在 binance api 中的真正含义是什么?是有效位数吗?我需要一些澄清。

python precision binance ccxt significant-digits
1个回答
0
投票

您可以使用以下代码来计算数量

market_data = exchange.market(symbol) # load info for your symbol
precision = market_data['precision']['amount']
min_order_amount = market_data['limits']['amount']['min'] # useful to avoid to trigger low amount error
# Determine the number of decimal places from the precision value
precision_decimal_places = max(0, int(-math.log10(precision))) # if precision is a float
precision_decimal_places = len(precision) - 2 #if precision is str (-2 to remove 0.)
# Ensure the quantity is within the allowed precision and limits
quantity = max(min_order_amount, round_down(quantity, precision_decimal_places))

© www.soinside.com 2019 - 2024. All rights reserved.