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
Post a Comment