status: 400, error code: -1013, error message: Filter failure: LOT_SIZE

So, this question again. I’ve read all previous topics but … where is answer?
I’m using Python and Spot API. Here is code:

ei = self.spot.exchange_info(symbol)
quote_precision = int(ei['symbols'][0]['quotePrecision'])
filter_lot_size = [x for x in ei['symbols'][0]['filters'] if
                   x['filterType'] == 'LOT_SIZE']
min_lot_size = float(filter_lot_size[0]['minQty'])
self.log.info(f'Process {order_type.upper()} order. '
              f'Balance {main_coin}: {main_coin_balance}. '
              f'Balance {second_coin}: {second_coin_balance}. '
              f'Market Fee: {market_fee}. Limit Fee: {limit_fee} '
              f'quotePrecision: {quote_precision}. '
              f'minQty: {min_lot_size}')
params = {
        "symbol": symbol,
        "side": "BUY",
        "type": "LIMIT",
        "timeInForce": "GTC",
        "quantity": round(can_buy_second_coin, quote_precision),
        "price": round(price, 6),
    }
try:
    self.log.info(f'Open BUY order: {symbol}, {params}.')
    response = self.spot.new_order(**params)
    self.log.info(f'Response: {response}')
except ClientError as error:
    logging.error(
        f"Found error. status: {error.status_code}, "
        f"error code: {error.error_code}, "
        f"error message: {error.error_message}")

And here is a log:

Process BUY order. Balance USDT: 498.40086358. Balance TRX: 0. Market Fee: 0.001. Limit Fee: 0.001 quotePrecision: 8. minQty: 0.1
I want to spend 38.00000000 USDT to buy 370.87643959 TRX. Calculate by 0.10246000999999999
Open BUY order: TRXUSDT, {‘symbol’: ‘TRXUSDT’, ‘side’: ‘BUY’, ‘type’: ‘LIMIT’, ‘timeInForce’: ‘GTC’, ‘quantity’: 370.87643959, ‘price’: 0.10246}.
Found error. status: 400, error code: -1013, error message: Filter failure: LOT_SIZE

What’s wrong? Thanks in advance

The endpoint /api/v3/exchangeInfo has the info that defines the trading rules for all symbols, including TRXUSDT.


{
                    "filterType": "LOT_SIZE",
                    "minQty": "0.10000000",
                    "maxQty": "9000000.00000000",
                    "stepSize": "0.10000000"
                },

The LOT_SIZE filter shows that you can only give 1 decimal in the quantity. Please have a try with 370.8, it should work.

Hmm.

So, it’s stepSize. Here is code example

ei = self.spot.exchange_info(symbol)
filter_lot_size = [x for x in ei['symbols'][0]['filters'] if
                   x['filterType'] == 'LOT_SIZE']
step = float(filter_lot_size[0]['stepSize'])
quote_precision = len(str(step).split('.')[-1])
params = {
                  "symbol": symbol,
                  "side": "BUY",
                  "type": "LIMIT",
                  "timeInForce": "GTC",
                  "quantity": round(can_buy_second_coin, quote_precision),
                  "price": round(price, 6),
                }
try:
    self.log.info(f'Open BUY order: {symbol}, {params}.')
    response = self.spot.new_order(**params)
    self.log.info(f'Response: {response}')
except ClientError as error:
    logging.error(
        f"Found error. status: {error.status_code}, "
        f"error code: {error.error_code}, "
        f"error message: {error.error_message}")