highcharts 在json的高脚椅上绘制股票价格图表

olhwl3o2  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(161)

什么是最好的方法图表股票数据从以下来源在highcharts?我一直有一个发挥周围的小提琴,但我一直无法得到的数据Map在正确的格式。
https://financialmodelingprep.com/api/v3/historical-price-full/AAPL?apikey=1920dcbb65f52e51cf4ceb45d64d6bd9
谢谢你布鲁斯

mspsb9vt

mspsb9vt1#

您需要解析您的数据,以便Highcharts能够读取。

示例代码:

var ohlc = [],
    volume = [],
    vwap = [],
    mainData = data.historical.length,
    i = 0;

  for (i; i < mainData; i += 1) {

    let date = data.historical[i].date,
      utcTimestamp = new Date(date).getTime();

    ohlc.push([
      utcTimestamp, // the date
      data.historical[i].open, // open
      data.historical[i].high, // high
      data.historical[i].low, // low
      data.historical[i].close // close
    ]);

    volume.push([
      utcTimestamp, // the date
      data.historical[i].volume // the volume
    ]);

    vwap.push([
      utcTimestamp, // the date
      data.historical[i].vwap // the volume
    ]);
  }

数据
请注意:

相关问题