APIError(code=-4014): Price not increased by tick size
I get tick size issue with certain coins at random times when setting futures limit orders.
I'm using this function to get the precise price for my limit order.
`def get_price_precision(symbol,price):
info = client.futures_exchange_info()
for item in info['symbols']:
if(item['symbol'] == symbol):
pricePrecision = item['pricePrecision']
quantityS = price
quantityB = "{:0.0{}f}".format(quantityS, pricePrecision)
#print(item['symbol'],quantityS, quantityB)
return float(quantityB)`
I'm expecting the order to be valid, in this eth example 3093.42 is a valid limit price as far as I can see, the price was 3122.53. at the time of setting the buy order.
[Sun Jan 9 01:10:07 2022 - trade() - Order, Sym=ETHUSDT, price=3093.42, side=BUY, qty=0.011]
[Sun Jan 9 01:10:08 2022 - trade() - Failed to make order: APIError(code=-4014): Price not increased by tick size.]
res = client.futures_create_order( symbol=cur, side=action, type='LIMIT', timeInForce='GTC', quantity=min, price=price)
The limit order
Solved using binance helper.
def get_min_quant(symbol):
info = client.futures_exchange_info()
for item in info['symbols']:
if(item['symbol'] == symbol):
for f in item['filters']:
if f['filterType'] == 'LOT_SIZE':
return f['minQty']
tick = get_ticksize(cur)
price = round_step_size(float(price), float(tick))
Hello Aarron! I have the same problem as you, but I can't find a way to solve it! Can you share the function code with me?:
get_ticksize round_step_size
Maybe looking at your code I can guide me a bit. I'm programming it in Dart
I appreciate it a lot!
The information that the console gives me is the following:
"code":-4014,"msg":"Price not increased by tick size."
Hello Aarron! I have the same problem as you, but I can't find a way to solve it! Can you share the function code with me?:
get_ticksize round_step_size
Maybe looking at your code I can guide me a bit. I'm programming it in Dart
I appreciate it a lot!
Sorry it appears I pasted the wrong function.
https://github.com/sammchardy/python-binance/blob/master/binance/helpers.py
round_step_size is here, you can import it using
from binance.helpers import round_step_size
for some reason I couldn't import it and just copy and pasted the function from the source code.
def get_ticksize(symbol):
info = client.futures_exchange_info()
for item in info['symbols']:
if(item['symbol'] == symbol):
for f in item['filters']:
if f['filterType'] == 'PRICE_FILTER':
return f['tickSize']
Hope this helps.
Using round_step_size with the tick size works. Here is the full code I'm using:
from binance.helpers import round_step_size
def get_tick_size(symbol: str) -> float:
info = client.futures_exchange_info()
for symbol_info in info['symbols']:
if symbol_info['symbol'] == symbol:
for symbol_filter in symbol_info['filters']:
if symbol_filter['filterType'] == 'PRICE_FILTER':
return float(symbol_filter['tickSize'])
def get_rounded_price(symbol: str, price: float) -> float:
return round_step_size(price, get_tick_size(symbol))
price = get_rounded_price(symbol, price)
For spot orders you can avoid looping through all the symbols if you use client.get_symbol_info(symbol):
def get_tick_size(symbol: str) -> float:
symbol_info = client.get_symbol_info(symbol)
for symbol_filter in symbol_info['filters']:
if symbol_filter['filterType'] == 'PRICE_FILTER':
return float(symbol_filter['tickSize'])
Getting 'tickSize' without using a for loop
tickSize = my_client.get_symbol_info(symbol=symbol) tickSize = tickSize['filters'] tickSize = float(tickSize[0]['tickSize'])
@RichestSmoke use price + or - tickSize ?
Here is my code to apply this to sl and tp
# get tick size and round tp and sl to tick size
tickSize = float(client.get_symbol_info(symbol=symbol)['filters'][0]['tickSize'])
rounded_tp = round_step_size(float(tp), tickSize)
rounded_sl = round_step_size(float(sl), tickSize)