node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Unable to place orders, receiving empty responses

Open sand3r opened this issue 3 years ago • 2 comments

Hi, can someone help figuring out the following?

I've tried to place some orders with the following functions I wrote. These are just simple functions to see if node-binance-api gives the result I expect. Unfortunately, I get for both calls an empty object in return, also I have confirmed that the orders are not placed when checking the balance. I can retrieve my account balance so I know the keys I use are alright.

I'm using the following config:

export const binance = new Binance().options({
  APIKEY: config.binance.test.api.key,
  APISECRET: config.binance.test.api.secret,
  test: true,
  useServerTime: true,
  verbose: true,
  urls: {
    base: 'https://testnet.binance.vision/api/',
  },
});

These are the calls that return an empty object/empty response.

export const placeLimitOrderOnExchange = async (
  buyOrSell: 'BUY' | 'SELL',
  symbol: string,
  quantity: number,
  price: number
) => {
  return new Promise((resolve, reject) => {
    binance.buy(symbol, quantity, price, { type: 'LIMIT' }, (err, response) => {
      if (err) {
        console.log('An error has occured.');
        console.log(err);
        reject(err);
      }
      console.log('Response:');
      console.log(response);
      resolve(response);
    });
  });
};

export const placeMarketOrderOnExchange = async () => {
  const response = await binance.marketBuy('BNBBTC', 1);
  console.log('Response:');
  console.log(response);
  return response;
};

Both responding with:

{}

or:

[Object: null prototype] {}

sand3r avatar Jul 28 '21 21:07 sand3r

Any news on this?

DimitrisMpanis avatar Nov 30 '21 10:11 DimitrisMpanis

I tested and found that it works in live mode, and gives empty response in test mode.

mining016 avatar Mar 22 '22 04:03 mining016