Binance API return Error: Filter failure: LOT_SIZE
The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. There are 3 parts:
minQty defines the minimum quantity/icebergQty allowed.
maxQty defines the maximum quantity/icebergQty allowed.
stepSize defines the intervals that a quantity/icebergQty can be increased/decreased by.
In Binance, we use the API follow to get lot_size of symbol
GET /api/v3/exchangeInfo
(https://binance-docs.github.io/apidocs/spot/en/#exchange-information)
We can use the function below to make valid quantity:
const getValidQuantity = (floatNumber, lotSize) => {
const n = lotSize.split('.')[1]?.indexOf('1') + 1;
return toFixedWithoutRounding(floatNumber, n);
}
--
const toFixedWithoutRounding = (floatNumber, n) => {
const x = Math.pow(10, n);
return parseFloat(
(parseInt(floatNumber * x) / x).toFixed(n)
);
}
I hope this helpful for you!
Nhận xét
Đăng nhận xét