Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision is over the maximum defined for this asset #14

Open
ciclanoio opened this issue Jun 28, 2021 · 6 comments
Open

Precision is over the maximum defined for this asset #14

ciclanoio opened this issue Jun 28, 2021 · 6 comments

Comments

@ciclanoio
Copy link

I'm running tests but I still haven't got it working, it's not clear to me the amount to be invested in the order and I get this error. Any advice is welcome.

{"code":-1111,"msg":"Precision is over the maximum defined for this asset."}
Erro: ('ExecuteError', '[Executing] -1111: Precision is over the maximum defined for this asset.')
Traceback (most recent call last):
File "C:\binance_futures_bot-main\bot.py", line 44, in
qty, side, in_position = bf.handle_signal(client, std,
File "C:\binance_futures_bot-main\bot_functions.py", line 218, in handle_signal
execute_order(client, _qty=qty, _side=order_side, _market=market)
File "C:\binance_futures_bot-main\bot_functions.py", line 107, in execute_order
client.post_order(symbol=_market,
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\requestclient.py", line 246, in post_order
response = call_sync(self.request_impl.post_order(symbol, side, ordertype,
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\impl\restapiinvoker.py", line 44, in call_sync
check_response(json_wrapper)
File "C:\binance_futures_bot-main\venv\lib\site-packages\binance_f\impl\restapiinvoker.py", line 21, in check_response
raise BinanceApiException(BinanceApiException.EXEC_ERROR, "[Executing] " + str(code) + ": " + msg)
binance_f.exception.binanceapiexception.BinanceApiException: ('ExecuteError', '[Executing] -1111: Precision is over the maximum defined for this asset.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\binance_futures_bot-main\bot.py", line 118, in
time.sleep(15)

@Hephyrius
Copy link
Owner

What market/assets are you trying to trade?

@crypto-kotha
Copy link

It's happen if you trade eth/usdt, btc/usdt or xrp. Bot just can't place exact amount order. In bot_functions.py change qty = 0.05 or 0.06 or 0.07 like this way.

@riuslol
Copy link

riuslol commented Jul 5, 2021

im having the same issue, which line we should change exactly and what does it mean basically

@crypto-kotha
Copy link

in bot_functions.py you need to change qty=qty * 0.99
to qty=qty * 0.98 or qty=qty * 0.97 or qty=qty * 0.96 like this way.

the bot are basically failed to calculate how much quantity need to place.

in bot_functions.py you can search buy Ctrl+f by this line qty=qty * 0.99 and then change it.

@lid2000
Copy link

lid2000 commented Dec 14, 2021

I think this is happening because floats aren't great at accuracy in some cases (vs decimals, more info here). What I suspect happens (unverified, just speculating) is the round_to_precision function in bot_functions.py uses string formatting to strip the position size down to 8 significant digits (if it was rounded instead, there's a chance it would round up and the order wouldn't go through as it's more than the wallet has), but then you see the qty figure gets cast as a float before being passed on to the Binance client - in the case of certain difficult-to-represent-in-binary numbers, this'll cause it to flip out and be some gigantic long fraction like 16.6999999999999999999999999) and then Binance rejects it.

However, turns out you can pass a string to Binance and it'll accept it - I removed the float(new_qty) casting on line 167 so it just returns the number as a string instead, and I haven't had precision issues since.

@abuvanth
Copy link

abuvanth commented Mar 5, 2022

I think this is happening because floats aren't great at accuracy in some cases (vs decimals, more info here). What I suspect happens (unverified, just speculating) is the round_to_precision function in bot_functions.py uses string formatting to strip the position size down to 8 significant digits (if it was rounded instead, there's a chance it would round up and the order wouldn't go through as it's more than the wallet has), but then you see the qty figure gets cast as a float before being passed on to the Binance client - in the case of certain difficult-to-represent-in-binary numbers, this'll cause it to flip out and be some gigantic long fraction like 16.6999999999999999999999999) and then Binance rejects it.

However, turns out you can pass a string to Binance and it'll accept it - I removed the float(new_qty) casting on line 167 so it just returns the number as a string instead, and I haven't had precision issues since.

It works. Just return new_qty instead of float(new_qty).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants