通过设置fetchOHLCV的第三个参数为当前时间戳可以解决此问题。示例代码如下:
const ccxt = require('ccxt');
const binance = new ccxt.binance();
async function fetchOHLCV(symbol, timeframe, limit) {
const endTimestamp = Date.now();
const ohlcvs = await binance.fetchOHLCV(symbol, timeframe, endTimestamp, limit);
// do something with ohlcvs
}
fetchOHLCV('BTC/USDT', '1m', 100);