gpt4 book ai didi

javascript - 在 JS 中转换 OHLC 中的连续股票数据(开盘价、最高价、最低价、收盘价)

转载 作者:行者123 更新时间:2023-12-03 01:33:44 25 4
gpt4 key购买 nike

我有以下格式的连续数据流,我想根据定义的时间片(如 5 分钟、10 分钟、30 分钟等)将其转换为开盘价、最高价、最低价和收盘价。同时 buy_quantity sell_quantity 也应该根据选择的时间片进行聚合。在 Javascript 中对来自 websocket 的连续实时数据流执行此操作的最有效方法是什么?为了增加复杂性,我至少有 50 个不同的股票代码或instrument_token。理想的解决方案类似于 python 的 panda 包中提供的内容 - 这是一个示例 https://www.quantinsti.com/blog/tick-tick-ohlc-data-pandas-tutorial/

{ 
"_id" : "Q6GinQQKKnfA7FrAT",
"instrument_token" : NumberInt(11552514),
"last_price" : 10711.8,
"buy_quantity" : NumberInt(714225),
"sell_quantity" : NumberInt(488775),
"buySellRatio" : 1.4612551787632346,
"timestamp" : "2018 07 03 07:54:52",
"oi" : NumberInt(20539500),
"oi_day_high" : NumberInt(20539500),
"oi_day_low" : NumberInt(19809750)
}
{
"_id" : "Dwez3LuqLsB6MZRnB",
"instrument_token" : NumberInt(11552002),
"last_price" : NumberInt(26329),
"buy_quantity" : NumberInt(185520),
"sell_quantity" : NumberInt(201080),
"buySellRatio" : 0.9226178635369008,
"timestamp" : "2018 07 03 07:54:52",
"oi" : NumberInt(2163040),
"oi_day_high" : NumberInt(2170680),
"oi_day_low" : NumberInt(2018440)
}
{
"_id" : "tcDfqRPk3qs2mYmow",
"instrument_token" : NumberInt(11552514),
"last_price" : 10711.95,
"buy_quantity" : NumberInt(713775),
"sell_quantity" : NumberInt(490125),
"buySellRatio" : 1.4563121652639632,
"timestamp" : "2018 07 03 07:54:53",
"oi" : NumberInt(20539500),
"oi_day_high" : NumberInt(20539500),
"oi_day_low" : NumberInt(19809750)
}

最佳答案

有两部分:
1. 整合数据
2.以图表形式显示数据

为了整合数据,有效的数据结构可能如下所示:

data.slice.roundedtime.id

通过这种方式,您不必使用循环进行搜索,而是可以在浏览输入数据时寻址每个记住的值。

{
"5": { // this line once, for all 5 minutes increments
"2018 07 03 07:50:00": { // this line each 5 minutes
"Q6GinQQKKnfA7FrAT": { // this line for each 5 minutes each ticker
"volume": 123,
"high": 20539500,
"low": 19809750
},
"SecondTicker": {
"volume": 12,
"high": 1234,
"low": 123
}
},
"2018 07 03 07:45:00": {
"Q6GinQQKKnfA7FrAT": {
"volume": 123,
"high": 20539500,
"low": 19809750
}
}
},
"15": { // this line once, for all 15 minutes increments
"2018 07 03 07:45:00": {
"Q6GinQQKKnfA7FrAT": {
"volume": 123,
"high": 20539500,
"low": 19809750
}
}
}
}

数据量对于浏览器来说不是问题。浏览器页面运行且不刷新的每 24 小时,我们有:24 小时 * (2 + 6 + 12) 切片 * 50 个不同的报价 = 24000 条记录。

可以计算而不是记住 15 分钟和 30 分钟的聚合。这是一个细节。

关于javascript - 在 JS 中转换 OHLC 中的连续股票数据(开盘价、最高价、最低价、收盘价),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51172781/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com