F.Arrighi
F.Arrighi

Reputation: 11

python Binance: APIError(code=-1013): Filter failure: LOT_SIZE

When I try to create a limit order with python binance api, I always obtain the LOT_SIZE error. I tried different parameters but the result is always the same (for example I checked the min quantity, the type of parameters or the of the coins availability in the wallet). The following code is an example of a trade order.

order = client.create_order(
  symbol="XLMBUSD",
  side=Client.SIDE_BUY,
  type=Client.ORDER_TYPE_LIMIT,
  timeInForce=Client.TIME_IN_FORCE_GTC,
  quantity="%.8f" % round(105.25651, 8),
  price="0.47593000")

I think is a problem caused by the number of decimals and don't think is a problem of time zone. If someone has some ideas or advices is welcome :)

Upvotes: 1

Views: 966

Answers (1)

gasparsufyan
gasparsufyan

Reputation: 21

I used to get the same error. You are right to think that this is caused by the number of decimals. To resolve this I used this code:

    def precision_step():
        sym_info = client.get_symbol_info(TICKER)
        filters = sym_info['filters']
        for f in filters:
            if f['filterType'] == 'LOT_SIZE':
                step_size = float(f['stepSize'])
                precision = int(round(-math.log(step_size, 10), 0))
                return precision

Where in your case TICKER would be 'XLMBUSD'. This function returns the number of decimal places you are allowed to have when creating your order.

Upvotes: 2

Related Questions