jaggedsoft/node-binance-api

100% trading in the market using the .marketBuy function

Mae6e opened this issue · 2 comments

Mae6e commented

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

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:

  • for BUY orders, the baseAsset or BTC is deducted from your account to cover the commissions
  • for SELL orders, the quoteAsset or USDT is deducted from your account

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.

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.