binance-exchange/node-binance-api

BalanceData Error

Natedeploys opened this issue · 2 comments

balanceData Error

  • bug: Expected to see a list of balances, actual was an error message and
    empty object.

Short Description:

  • Unable to get a balance from Binance

Platform:

  • macos

node version:

  • 10.1.0

Long descrption

  • Requesting the balance from Binance results in a balance data error. I am unable to establish whether this is a problem from my side or from the Binance API service.

code

const Binance = require('node-binance-api');

const binanceUserAPI = (connection) => {
  const binance = new Binance().options({
    APIKEY: connection.apikey,
    APISECRET: connection.secretkey,
    useServerTime: true,
    log: log => {
      console.log("Connected: ", log);
    }
  });

  binance.balance((error, balances) => {
    console.log("balances()", balances);
  });
}

result

Connected:  balanceData error
balances() {}

Thank you

This would be helpful if you can include the error message:

  binance.balance((error, balances) => {
    if ( error ) return console.error(error);
    console.log("balances()", balances);
  });

I suspect it to say something about your system time being wrong. To fix that, you can do this:

// Wrap your entire program in useServerTime(), or the entry point
binance.useServerTime(function() {
	binance.balance((error, balances) => {
		if ( error ) return console.error(error);
		console.log("balances()", balances);
		console.log("BNB balance: ", balances.BNB.available);
	});
});

It was indeed the system time, the fix worked. Thank you for your time.