status: 400, error code: -1013, error message: Filter failure: PRICE_FILTER
I am trying to create a new order to sell all SCRT
that are on my account and I cannot figure out what is the problem.
The filters for SCRTBUSD
are:
{'filterType': 'PRICE_FILTER', 'minPrice': '0.00100000', 'maxPrice': '1000.00000000', 'tickSize': '0.00100000'}
The code I am using:
client = Spot(key=key, secret=secret)
account = client.account()
for asset in account['balances']:
if asset['asset'] == 'SCRT':
quantity = asset['free']
break
# price = client.ticker_price('SCRTBUSD')['price']
price = client.avg_price('SCRTBUSD')['price']
params = {
"symbol": 'SCRTBUSD',
"side": "SELL",
"type": "LIMIT",
"timeInForce": "GTC",
"quantity": quantity,
"price": round(float(price) * float(quantity), 8)
}
try:
response = client.new_order(**params)
except ClientError as error:
print(f"Found error. status: {error.status_code}, error code: {error.error_code}, error message: {error.error_message}")
The final price (round(float(price) * float(quantity), 8)
) is 30.68230251
.
I have also thought that maybe by "price" they mean a price for 1 BUSD
and I put the "price": float(price)
and I have got the same error.
I tried both avg_price and ticker_price. Any ideas on how to set the right price?
tickSize
for SCRTBUSD
is: 0.001.
Therefore, you have to round the quantity to the next 0.001. For example:
round(30.68230251, 3)
For more information about the tickSize
, check the exchangeInfo on the Binance API documentation.