How to fetch last one minute volume of BTC in CCXT Nodejs.

 const exchange = new ccxt.binance();

async  function  getLastOneMinuteVolume() {
    try {
      const binance = new ccxt.binance();
      const symbol = "BTC/USDT";
    //   const symbol = "USDT";
      const ohlcv = await binance.fetchOHLCV(symbol, "1m");
        console.log(ohlcv[ohlcv.length -1])
      const lastCandle = ohlcv[ohlcv.length - 1];
      const volume = lastCandle[5];
    //   console.log(lastCandle[5])
      console.log("Last one minute volume:", volume);
    } catch (error) {
      console.error(error);
    }
  }
 
//   getLastOneMinuteVolume();
  setInterval(getLastOneMinuteVolume, 1000)




first data in array is volume in USDT , last is volume in BTC , second is price.

Comments

All time Best Post

Write a program that declares a class named Person. It should have instance variables to record name, age and salary. Use new operator to create a Person object. Set and display its instance variables.

IMAGE CRUD OPERATION USING EXPRESS MONGOOSE MULTER

connect websocket to binance api and store t he true value in the db

CRUD APP WITH SORT IN NODE EXPRESS AND MONGODB

express session login system using node express mongodb

how to delete image from the folder directly from a Request (MULTER)

calculate rsi

java program for 1 to 10 print using while loop