I’m going crazy trying to calculate the amount to open a position.

I was reading responses to previous posts and came to the following

def qty_order(symbol,price):

usdt_par = futures_functions.get_qtyU(“USDT”)/price #this get the usdt on my wallet and then divide divide by the current price of the currency in which I am going to make the position

minQ = float(client.get_symbol_info(symbol)[‘filters’][2][‘minQty’])

stepS = float(client.get_symbol_info(symbol)[‘filters’][2][‘stepSize’])

b = (usdt_par-minQ)/stepS

quantity = minQ + b * stepS

return quantity

I’m testing with btc and this is the amount that it returns:

0.0013700000000000001

and this is the error:

Precision is over the maximum defined for this asset.

I understand why the error comes out, what I’m looking for is a way to calculate the amount

Then I try:

from binance.helpers import round_step_size

stepS = float(client.get_symbol_info(“BTCUSDT”)[‘filters’][2][‘stepSize’])

round_step_size(qty, stepS) - stepS

output:

0.00137

and again the same error

So my question is how can I calculate the number of correct decimal places in general for any currency?