jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.57k stars 767 forks source link

100% trading in the market using the .marketBuy function #886

Open Mae6e opened 1 year ago

Mae6e commented 1 year ago

hello. Is it necessary that the user's usdt balance is a slightly higher than the amount for the trade to take place in .marketBuy function?

Is the transaction definitely done without the buffer amount?

amount = 0.2
price = binance.prices('BTCUSDT')
total = price * amount 

const buffer = 2; // set a buffer of 2 usdt
if (balance < total + buffer) {
  console.error('Insufficient USDT balance');
  return;
}
else{
  binance.marketBuy('BNBBTC', amount)
}
GTedZ commented 1 year ago

If you do not have BNB to cover the commissions, yes I think so, since binance will need to take some BTC in order to pay your commission.

Binance prefers to take BNB for every order no matter the side (with a 25% discount) BUT if BNB wasn't available:

It could be the opposite, but I think its baseAsset for BUY, and quoteAsset for SELL, since this is why your order is erroring out.

jamestangeres commented 12 months ago

I have issue on this also.

when futuresMarketBuy. I can buy with the usdt amount I need but when selling it some 0.19 USDT position will still remain.

I used the position.isolatedMargin to get the USDT amount to sell.