Lot size issue

I want to know is this the correct way to calculate lot size and is the fees correct??

def lot_sizing(self, price, amount, btc=False, last=False):
precision_oco = int(markets[self.symbol][‘info’][‘quotePrecision’])
price_str_buy = ‘{:0.0{}f}’.format(price, precision_oco)
btc_per_trade = float(amount)

    filters = markets[self.symbol]['info']['filters']
    step_size = None
    for f in filters:
        if f['filterType'] == 'LOT_SIZE':
            step_size = float(f['stepSize'])
            break

    precision = int(round(-math.log(step_size, 10), 0))

    if btc:
        quantity_buy = (btc_per_trade / price) * 0.995  # calculating the quantity of per coin too buy
    else:
        quantity_buy = float(amount) * 0.995  # calculating the quantity of per coin too buy

    final_quantity_buy = round(quantity_buy, precision)  # rounding of the quantity

    if last:
        final_quantity_buy = final_quantity_buy-step_size  # Total tradeable balance

    return final_quantity_buy

Hello,

in order to pass the market lot size, the following must be true for quantity:
quantity >= minQty
quantity <= maxQty
(quantity-minQty) % stepSize == 0

minQty, maxQty and stepSize are obtained from GET /api/v3/exchangeInfo -> “filterType”: “LOT_SIZE”.

Happy coding :slight_smile:

1 Like

But my lot size is right calculated .its just some mistake in rounding off.Do you find any error??

There was an update. Here the new formula:

https://binance-docs.github.io/apidocs/spot/en/#filters

In order to pass the lot size, the following must be true for quantity:

  • quantity >= minQty
  • quantity <= maxQty
  • quantity % stepSize == 0