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

Unable to place orders, receiving empty responses #706

Open sand3r opened 2 years ago

sand3r commented 2 years ago

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] {}
DimitrisMpanis commented 2 years ago

Any news on this?

mining016 commented 2 years ago

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