携程股票价格实时行情 (携程股票价格美股)
访客
28
以下为携程股票 (美股代码: TCOM) 的实时行情数据,数据来源:Yahoo Finance。
时间
|
开盘价
|
最高价
|
最低价
|
收盘价
|
涨跌幅
|
成交量
|
---|
// 获取实时行情数据function getStockData() {const url = 'https://query1.finance.yahoo.com/v7/finance/quote?symbols=TCOM';fetch(url).then(response => response.json()).then(data => {// 解析行情数据const quote = data.quoteResponse.result[0];const timestamp = new Date(quote.regularMarketTime 1000).toLocaleString();const openPrice = quote.regularMarketOpen.toFixed(2);const highPrice = quote.regularMarketHigh.toFixed(2);const lowPrice = quote.regularMarketLow.toFixed(2);const closePrice = quote.regularMarketPrice.toFixed(2);const changePercent = (closePrice - openPrice) / openPrice 100;const volume = quote.regularMarketVolume.toLocaleString();// 创建行情数据行const row =document.createElement('tr');const timeCell = document.createElement('td');timeCell.innerHTML = timestamp;const openPriceCell = document.createElement('td');openPriceCell.innerHTML = openPrice;const highPriceCell = document.createElement('td');highPriceCell.innerHTML = highPrice;const lowPriceCell = document.createElement('td');lowPriceCell.innerHTML = lowPrice;const closePriceCell = document.createElement('td');closePriceCell.innerHTML = closePrice;const changePercentCell = document.createElement('td');changePercentCell.innerHTML = changePercent.toFixed(2) + '%';const volumeCell = document.createElement('td');volumeCell.innerHTML = volume;// 添加行到表格中row.appendChild(timeCell);row.appendChild(openPriceCell);row.appendChild(highPriceCell);row.appendChild(lowPriceCell);row.appendChild(closePriceCell);row.appendChild(changePercentCell);row.appendChild(volumeCell);document.querySelector('tbody').appendChild(row);});}// 定时更新行情数据setInterval(getStockData, 1000);
版权声明:除非特别标注,否则均为本站转摘于网络,转载时请以链接形式注明文章出处。