Hello all. Firstly thank you so much for this forum. I had been wishing for a developer forum for Binance for a while now, and found this right now.
My issue had been posted here a lot of times but I still have some confusions about it so I’m posting here again.
The issue is I’m getting LOT_SIZE error when I’m trying to place a LIMIT order. And I can’t seem to wrap my head around two of the filter types: LOT_SIZE and MIN_NOTIONAL.
I’m working on a NodeJS/Express app and trying to place an order based on the “data” object below. The data has been fetched from “exchangeInfo” endpoint.
const data = {
symbol: ‘BNBBTC’,
type: ‘LIMIT’,
side: ‘BUY’,
price: ‘0.0095000’,
baseAsset: ‘BNB’,
baseAssetPrecision: 8,
quoteAsset: ‘BTC’,
quotePrecision: 8,
lotSizeFilter: {
filterType: ‘LOT_SIZE’,
minQty: ‘0.01000000’,
maxQty: ‘100000.00000000’,
stepSize: ‘0.01000000’
},
minNotionalFilter: {
filterType: ‘MIN_NOTIONAL’,
minNotional: ‘0.00010000’,
applyToMarket: true,
avgPriceMins: 5
}
}
This function help figure out the actual quantity of BNB to be bought. Here, I compared the minimum lot size needed with the actual quantity my BTC amount (20k sats for testing purposes) would get. This fumction takes in the amount to be spent (in BTC), price of the asset, minimum lot size of the asset and minimum notional value.
const quantityFunc = ( amount, price, lotSize, orderSize ) => {
// amount divided price gives the BNB amount I'll get.
let quantity = `${(amount / price).toFixed(8)}`;
if ( Number(quantity) < Number(lotSize) ) {
console.log( `Error: Quantity Supplied: ${quantity}. Quantity Required: ${lotSize}` );
return;
}
if ( Number(quantity) >= Number(lotSize) ) {
return quantity;
}
}
This function executes the order with values taken from the object above as well as the value of the quantity from quantity function.
const orderExecutionFunc = async (pair, side, quantity, price) => {
const orderExecution = await bRest.testOrder({
“symbol”: pair,
“type”: “LIMIT”,
“side”: side,
“quantity”: quantity,
“timeInForce”: “FOK”,
“price”: price
});
return orderExecution;
};
const pair = data.pair;
const side = data.side;
const price = data.price;
const minLotSize = data.lotSizeFilter.minQty;
const minOrderSize = data.minNotionalFilter.minNotional;
const quantity = quantityFunc( 0.00020000, price, minLotSize, minOrderSize );
const executeOrder = await orderExecutionFunc(pair, side, quantity, price);
So is this how lot size is supposed to be compared with quantity? And should I compare MIN_NOTIONAL value with btc value on sell side or should I just compare both LOT_SIZE and MIN_NOTIONAL value in both sell and buy side? Please note that for testing purposes I’m using 20k sats as the initial value of my BTC.
Your help would be highly appreciated.