股票代码:
股票名称:
日期
|
开盘价
|
收盘价
|
最高价
|
最低价
|
成交量
|
成交额
|
振幅
|
涨跌幅
|
---|
// 获取股票代码const stock_code = document.getElementById('stock_code');stock_code.innerText = '300114';// 获取股票名称const stock_name = document.getElementById('stock_name');stock_name.innerText = '中航电测';// 获取股票历史行情数据const stock_history = document.getElementById('stock_history');const xhr = new XMLHttpRequest();xhr.open('GET', 'https://xueqiu.com/stock/forchart/stocklist.json?category=SH&symbol=300114&period=1day');xhr.onload = function() {if (xhr.status === 200) {const response = JSON.parse(xhr.responseText);const data = response.chartlist.item;data.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));data.forEach(item => {const tr = document.createElement('tr');const date = new Date(item.timestamp).toLocaleString();const open = item.open;const close = item.close;const high = item.high;const low = item.low;const volume = item.volume;const amount = item.amount;const amplitude = (high - low) / open 100;const change_percent = (close - open) / open 100;tr.innerHTML = `
${date} | ${open.toFixed(2)} | ${close.toFixed(2)} | ${high.toFixed(2)} | ${low.toFixed(2)} | ${volume} | ${amount} | ${amplitude.toFixed(2)}% | ${change_percent.toFixed(2)}% | `;stock_history.appendChild(tr);});}};xhr.send();
版权声明:除非特别标注,否则均为本站转摘于网络,转载时请以链接形式注明文章出处。