精度超过了该资产定义的最大定义。 binance?

发布于 2025-02-06 20:43:31 字数 595 浏览 3 评论 0原文

我的代码

if side == "LONG" and client.futures_get_open_orders(symbol=symbol) == []:
    print(data)
    pos = "BUY"
    q = tbal / price

    q = round(q, 1)
    print(tbal)
    print(q)
    client.futures_change_leverage(symbol=symbol, leverage=info.laverage)
    buyorder = client.futures_create_order(symbol=symbol, side=pos, type="LIMIT", quantity=q, price=price, timeInForce="GTC")

错误:

binance.exceptions.BinanceAPIException: APIError(code=-1111): Precision is over the maximum defined for this asset.

我已经尝试了所有内容,但它仍然无法正常工作

My code

if side == "LONG" and client.futures_get_open_orders(symbol=symbol) == []:
    print(data)
    pos = "BUY"
    q = tbal / price

    q = round(q, 1)
    print(tbal)
    print(q)
    client.futures_change_leverage(symbol=symbol, leverage=info.laverage)
    buyorder = client.futures_create_order(symbol=symbol, side=pos, type="LIMIT", quantity=q, price=price, timeInForce="GTC")

error:

binance.exceptions.BinanceAPIException: APIError(code=-1111): Precision is over the maximum defined for this asset.

I have tried everything, but it still dont working

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

哎呦我呸! 2025-02-13 20:43:33

错误1111仅仅是因为您使用的价格高于允许的小数位数的最大数量。

例如,如果ticksize返回0.01,则最大允许该符号的十进制位置为2。

Error 1111 is simply because the price you have used is above the maximum number of decimal places allowed.

For example, if tickSize returns 0.01, max allowed decimal places for that symbol will be 2.

烟火散人牵绊 2025-02-13 20:43:33

您需要从Binance Exchange信息端点获得允许的PricePrecision。

这是Binance Docs 的链接

You need to get the pair allowed pricePrecision from binance exchange info endpoint.

Here is the link to the binance docs

蓝眸 2025-02-13 20:43:33

您必须以二元定义的精度传递符号。如果您检查二元的股票价格,您将知道那里定义的精度。例如:0.234,精度为4,如果将精度的值超过4的值,您将获得错误的“精度超过此资产定义的最大定义”

来解决此问题,请阅读二元的股票价格,然后读取'小数数量'以股票价格,将您传递给小数的符号价值(在您的情况下)弄清楚。它将解决您的问题。

#read the ticker price from binance
response = um_futures_client.ticker_price('WOOUSDT')
tickerPrice = response['price']
#read 'number of decimals' in the ticker Price
d = decimal.Decimal(tickerPrice)
print(abs(d.as_tuple().exponent))
numOfDecimals = abs(d.as_tuple().exponent)
# ordering price
price =round(price,numOfDecimals)

You have to pass the symbol with precision defined by Binance. If you check the ticker price on Binance, you will know the precision defined there. Ex: 0.234, precision is 4 , if you pass a value of precision above 4, you will get error 'Precision is over the maximum defined for this asset'

To fix this, read the ticker price from binance, then read 'number of decimals' in the ticker Price, round off the symbol value(price in your case) that you pass to that decimals. It will fix your problem.

#read the ticker price from binance
response = um_futures_client.ticker_price('WOOUSDT')
tickerPrice = response['price']
#read 'number of decimals' in the ticker Price
d = decimal.Decimal(tickerPrice)
print(abs(d.as_tuple().exponent))
numOfDecimals = abs(d.as_tuple().exponent)
# ordering price
price =round(price,numOfDecimals)
好听的两个字的网名 2025-02-13 20:43:33

解决方案是在代码中使用“ Math.floor”。这样,脚本将使用您的数字的最接近值,然后根据此应用其余的计算。

if side == "LONG" and client.futures_get_open_orders(symbol=symbol) == []:
print(data)
pos = "BUY"
q = tbal / price

q = math.floor(round(q, 1)) # here you have to add the math.floor to solve problem
print(tbal)
print(q)
client.futures_change_leverage(symbol=symbol, leverage=info.laverage)
buyorder = client.futures_create_order(symbol=symbol, side=pos, type="LIMIT", quantity=q, price=price, timeInForce="GTC")

The solution is to use "math.floor" before applying round in your code. This way, the script will use the nearest lower value of your number and then apply the rest of your calculations based on that.

if side == "LONG" and client.futures_get_open_orders(symbol=symbol) == []:
print(data)
pos = "BUY"
q = tbal / price

q = math.floor(round(q, 1)) # here you have to add the math.floor to solve problem
print(tbal)
print(q)
client.futures_change_leverage(symbol=symbol, leverage=info.laverage)
buyorder = client.futures_create_order(symbol=symbol, side=pos, type="LIMIT", quantity=q, price=price, timeInForce="GTC")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文