Binance unexpected percent price error for certain symbols

2.7k Views Asked by At

I've got unexpected Binance API error when trying to submit an order for ETHUSDT. The error looks standard:

{'code': -1013, 'msg': 'Filter failure: PERCENT_PRICE'}

I am passing an average price, retrieved a second ago using API's Symbol Price Ticker functions. My order function looks like:

params = {
    "symbol": "ETHUSDT",
    "side": "BUY",
    "type": "LIMIT",
    "quantity" : 0.1,
    "timeInForce" : "GTC",
    "price" : 3391, #A price from GET /api/v3/ticker/price
    "recvWindow" : 40000
}

response = send_signed_request('POST', '/api/v3/order', params)
print(response)

But when passing a tenfold lower price the order completes without any errors. Also, other symbols don't raise any errors too, using the same pipeline. What am I doing wrong? Looks like bug, but not sure where to submit it.

Any advice will be appreciated!

1

There are 1 best solutions below

1
On

The quantity and price are expected to be in a particular string format for it to work consistently. The Binance documentation on this is here.

You can use this syntax to apply formatting:

amt_str = "{:0.0{}f}".format(amount, precision)

Note that precision in this example is an integer, not a step size.