# How can I get the right precision? Error 1111

What defines precision? Is it price or position size?
In this case, what should be the precision for this alert and why?

Here’s part of my code:

``````def order(side, quantity, symbol,order_type=ORDER_TYPE_MARKET):
try:
symbol_info = client.get_symbol_info(symbol=symbol)
step_size = 0.0
for f in symbol_info['filters']:
if f['filterType'] == 'LOT_SIZE':
step_size = float(f['stepSize'])
#         print(f['stepSize'])
#         print("Inside if condition Step Size: ", step_size)
# print("Outside if condition Step Size: ", step_size)
precision = int(round(-math.log(step_size, 10), 0))
# print("Precisin:",precision)
quantity = float(round(quantity, precision))
print(f"sending order - {side} {quantity} {symbol}")
order = client.futures_create_order(symbol=symbol, side=side, quantity=quantity, type = order_type)
``````

You do NOT have to round the number but you have to truncate it, let’s suppose that in your ETHUSDT account you have 2.5USDT and you want to buy ETH at the price of 1,500USDT, so 2.5 / 1,500 = 0.00166666667ETH, if you round 0.00166666667 to the precision of the stepsize you get 0.0017 and if you multiply again those 0.0017 x 1,500 = 2.55 USDT so you would be exceeding your available by 0.05USDT instead if you truncate the number to the amount of decimals you would have 0.0016ETH which is equivalent to 0.0016 * 1,500 = 2.4USDT and you no longer exceed your available

PS: Thanks for the formula to convert the stepsize to decimals. Before, I had a longer one, but I was able to shorten it with your example and it stayed like this: Math.abs(Math.round(Math.log10(stepsize)))

Correction since the minimum that can be purchased must be greater than 10USDT this example does not apply with 2.5USDT otherwise you would have an error when placing the order so just change the value for 25USDT hehe

1 Like