历史数据
日期
|
开盘价
|
最高价
|
最低价
|
收盘价
|
成交量
|
js
// JavaScript 代码// 绘制
走势图
const chart = Highcharts.stockChart('chart-container', {rangeSelector: {selected: 1},title: {text: '中信证券行情走势图'},series: [{name: '中信证券',data: [] // 通过 Ajax 请求获取数据并填充}]
});// 获取历史数据
const dataTable = document.getElementById('data-table');
const xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json');
xhr.onload = function() {const data = JSON.parse(this.responseText);for (const row of data) {const newRow = dataTable.insertRow();const dateCell = newRow.insertCell();const openCell = newRow.insertCell();const highCell = newRow.insertCell();const lowCell = newRow.insertCell();const closeCell = newRow.insertCell();const volumeCell = newRow.insertCell();dateCell.textContent = row.date;openCell.textContent = row.open;highCell.textContent = row.high;lowCell.textContent = row.low;closeCell.textContent = row.close;volumeCell.textContent = row.volume;}
};
xhr.send();// 实时更新数据
const socket = new WebSocket('ws://localhost:8080');
socket.onmessage = function(event) {const data = JSON.parse(event.data);chart.series[0].addPoint([data.timestamp, data.price]);
};
json
// data.json 数据示例[{"date": "2023-06-01","open": "20.00","high": "20.50","low": "19.50","close": "20.25","volume": "10000"},// ... 更多数据
]
预约
股票开户,
股票交易佣金万一免五,
资金大佣金更低。国内顶级
证券公司开户,所有
费率均可调到最低标准,开户微信:gpkhcom