I am trying to automate cryptocurrency orders on Binance for several trading pairs. Each trading pair has a specified step size, generally 1.0, 0.1, 0.01, etc. and any order must conform to this constraint or fail. I attempt to calculate the number of coins to order by dividing the dollar amount by the current price, then adjusting for this constraint. Usually it works fine, but not always. Here's a screenshot of some data containing a list of coins with prices, steps and orders. Note item 8, which has a 1 in the last decimal place.
The code to calculate this is:
def calculate_order_sizes():
for coin_dict in coin_list:
coin_dict['order'] = coin_dict['step'] * math.floor((100/coin_dict['price'])/coin_dict['step'])
The 100 is the dollar amount I wish to order.