Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

分钟线汇总成半小时线时结果缺少数据

我想把我的分钟线汇总成半小时线:

sessionsStart=09:30:00.000 13:00:00.000
barMinutes = 30
OHLC = select first(open) as open, max(high) as high, min(low) as low, last(close) as close from price_min group by symbol, dailyAlignedBar(time, sessionsStart, barMinutes*60*1000) as barStart

问题是:
1) 用sessionsStart=09:30:00.000 13:00:00.000的时候,报错:
Usage: dailyAlignedBar(X, timeOffset, n). timeOffset must be a scalar or an ascending vector with type SECOND

2)改成sessionsStart=09:30:00 13:00:00后可以,但是只有9:30和13:00区间的。求指导。
谢谢!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

问题一报错原因应该是你原始分钟线数据造成的,你的time列数据应该是DATETIME格式,也就是2020.10.06T13:01:00,而不是TIMESTAMP格式2020.10.06T13:01:00.000

解决方法:price_min[`timestamp]=[timestamp(price_min.time)];

sessionsStart=09:30:00.000 13:00:00.000
barMinutes = 30
OHLC = select first(open) as open, max(high) as high, min(low) as low, last(close) as close from price_min group by symbol, dailyAlignedBar(timestamp, sessionsStart, barMinutes*60*1000) as barStart

问题二 你改成sessionsStart=09:30:00 13:00:00 后面的barMinutes601000就不能*1000

sessionsStart=09:30:00 13:00:00
barMinutes = 30
OHLC = select first(open) as open, max(high) as high, min(low) as low, last(close) as close from price_min group by symbol, dailyAlignedBar(time, sessionsStart, barMinutes*60) as barStart

还有个问题,你要看看你的分钟线数据起始第一根bar是什么时间点,如果类似聚宽分钟线2020.10.06T09:31:00这样的。就必须改为sessionsStart=09:31:00 13:01:00

现在dolphindb的技术迭代很快,很多新的高级函数用起来方便很多,去年初实现上述数据处理还得自编函数来实现。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...