【问题标题】:How to aggregate 1-minute data to 30-minutes or 1-hour average data in dolphindb如何在 dolphindb 中将 1 分钟的数据聚合为 30 分钟或 1 小时的平均数据
【发布时间】:2021-06-22 02:47:42
【问题描述】:

我有一个按分钟排序的股票数据,我想将 1 分钟的数据聚合为 30 分钟或 1 小时的平均数据。我先通过 stock_code 上下文,然后调用函数 rolling 进行聚合。但它不起作用。代码是:

mins_data = select rolling(first, code, 15,15) as Code,rolling(first, time_all, 15,15) as time 
, rolling(first, open, 15, 15) as Open, rolling(max, high, 15,15) as High, rolling(min, low, 
15, 15) as Low, rolling(last, close, 15, 15) as Close, rolling(sum, volume, 15, 15) as Volume, 
rolling(sum, turnover, 15, 15) as Turnover from mins_data context by code;

我该怎么办?

【问题讨论】:

    标签: window quantitative-finance dolphindb


    【解决方案1】:

    k线数据可以通过'group by code, date, bar(time,...)'来实现。具体例子请参考k-line tutorial

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多