实时数据来自 Yahoo Finance。
// 从 Yahoo Finance 获取数据function getData() {const symbol = "XPEV";const url = `${symbol}?range=1d&interval=1m&indicators=quote`;fetch(url).then(response => response.json()).then(data => {const candlesticks = data.chart.result[0].indicators.quote[0].close;// 将数据添加到表格中candlesticks.forEach(candle => {const date = new Date(candle.timestamp 1000).toLocaleDateString();const open = candle.open.toFixed(2);const high = candle.high.toFixed(2);const low = candle.low.toFixed(2);const close = candle.close.toFixed(2);const volume = candle.volume.toLocaleString();const row = `
${date} | ${open} | ${high} | ${low} | ${close} | ${volume} |
`;document.querySelector("tbody").innerHTML += row;});}).catch(error => {console.error(error);alert("无法获取数据,请稍后重试。");});}// 每分钟刷新数据setInterval(getData, 60000);// 初次加载数据getData();
标签: 小鹏汽车股票价格实时行情
版权声明:除非特别标注,否则均为本站转摘于网络,转载时请以链接形式注明文章出处。