Open bmw7 opened 2 years ago
Anyone else encountered this? Is it only for the testnet that this error occurs? Any help would be greatly appreciated.
Check the symbol info using client.get_symbol_info and find PERCENT_PRICE in it.
The price you send for the order should match the PERCENT_PRICE rule, as well as the PRICE_FILTER rule.
as you can see from @bmw7 sample order properties, there's no price element in order object because it's an MARKET order hence Binance is giving this kind of sh*ty errors of there's a high volatility.
I experienced it many times in production and still couldn't find any solution yet.
@ne0c0de I'm experiencing the same issue, did you ever find a solution for this?
Unfortunately there's no solution, Binance doesn't allow to open position and giving this kind of false errors to manipulate the developers when there's high volatility.
Hey there!
I had the same error a few days ago and found a solution. Maybe it would help some guys ;) First you need to call exchangeInfo endpoint to get the information of the filters on the symbol:
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "5",
"multiplierDown": "0.2",
"avgPriceMins": 5
},
You can see "multiplierUp" and "multiplierDown" value. So if the current price is 200 with a multiplierUp of 5 your price must be less than 200 5 = 1000. With the multiplierDown of 0.2 your price must be more than 200 0.2 = 40.
So all in, the price of your order must be in range:
40 <= your_price <= 1000
And I integrated in my script with:
if round((quantity * leverage) / asset_price, symbolData["quantityPrecision"]) > (float(percentPrice["multiplierUp"])*asset_price):
quantityThreated = round(float(percentPrice["multiplierUp"])*asset_price, symbolData["quantityPrecision"])
print("Up", quantityThreated)
if round((quantity * leverage) / asset_price, symbolData["quantityPrecision"]) < (float(percentPrice["multiplierDown"])*asset_price):
quantityThreated = round(float(percentPrice["multiplierDown"])*asset_price, symbolData["quantityPrecision"])
print("Down", quantityThreated)
if round((quantity * leverage) / asset_price, symbolData["quantityPrecision"]) > float(lotSize["maxQty"]):
quantityThreated = float(lotSize["maxQty"])
if round((quantity * leverage) / asset_price, symbolData["quantityPrecision"]) < float(lotSize["minQty"]):
quantityThreated = float(lotSize["minQty"])
Hope it will help !
Nice solution and I hope it will help but the problem here is we're giving market order which is means that whatever the price is, just execute my order but Binance rejects it. This can happen only if there's high volatility on the price
By "your price", you mean the quantity/position size or bid/ask price? @MOIJESUIS2ENMOI
I use my testnet account , and run the function futures_create_order() for the symbol BTCUSDT, it is all OK. The code is following:
client.futures_create_order(symbol='BTCUSDT', side='BUY', positionSide='LONG',type='MARKET',quantity=20)
But when I use it for the symbol SOLUSDT:
client.futures_create_order(symbol='SOLUSDT', side='BUY', positionSide='LONG',type='MARKET',quantity=20)
Error message appears:
binance.exceptions.BinanceAPIException: APIError(code=-4131): The counterparty's best price does not meet the PERCENT_PRICE filter limit.
How to solve the problem? thanks!!!