After seeing how sometimes the orders that I placed were not executed, I decided to implement a filter verification to obtain the correct price and quantity before placing the order, the process is simple, first lower the average price according to the following endpoint 'GET / api / v3 / avgPrice 'and later do the verification that is mentioned in the documentation, this is the code that I implement to achieve it and pass the filters
await avgPrice(symbol, d => aPrice = parseFloat(parseFloat(d.price).toFixed(fix)))
priceFilter = parseFloat(((aPrice - minPrice) % tickSize).toFixed(fix))
while(priceFilter != 0){
console.error('PRICE FILTER ERRR', priceFilter, aPrice)
aPrice = parseFloat((aPrice + tickSize).toFixed(fix))
priceFilter = parseFloat(((aPrice - minPrice) % tickSize).toFixed(fix))
}
if(aPrice > price * multiplierUp || aPrice < price * multiplierDown){
throw new TypeError('PERCENT_PRICE ERROR')
return
}
quantity = parseFloat((amount / aPrice).toFixed(fixQty))
lotSizeFilter = parseFloat(((quantity - minQty) % stepSize).toFixed(fix))
while(lotSizeFilter != 0){
console.error('LOT_SIZE ERROR', lotSizeFilter, quantity)
quantity = parseFloat((quantity + stepSize).toFixed(fix))
lotSizeFilter = parseFloat(((quantity - minQty) % stepSize).toFixed(fix))
}
if(quantity * aPrice <= minNotional){
throw new TypeError('Total value must be at least ' + minNotional)
return
}
var mkOrder = await marketOrder('TEST', symbol, 'BUY', quantity, null, null, d => console.log('OPEN LONG', d))
In some cases it works well, sometimes it passes the filters to the first as seen in the image
And in others after increasing the price a few times according to the tickSize it manages to pass the filter as seen in the following image
The problem is that there are certain cryptos that only pass the price filter after increasing the price too much and even after the first filter passes, they also increase the quantity to buy too much to pass the LOT_SIZE filter, such is the case of TRONUSDT or EOSUSDT and I suppose there are many more but those are the ones I check for now
What can I do in these cases?
Is it necessary to do filter validation on all cryptos?
How can I place an order in cryptos that raise the price and quantity to buy too much to be able to pass the filters as in the case of TRONUSDT?
How is it possible that the Binance app can pass these filters without raising both the price and the quantity to buy?