问答

行情数据做日切,可以怎么区分出来?

作者:admin 2021-07-13 我要评论

我想对行情数据做日切,在DolphinDB database GUI中执行下列代码: n_move=5t1=select concatDateTime(trade_date,trade_time) as time,secu_code, (close/close...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

我想对行情数据做日切,在DolphinDB database GUI中执行下列代码:

n_move=5
t1=
select concatDateTime(trade_date,trade_time) as time,secu_code,
 (close/close.move(n_move))-1 as r_close, //等价于ratios(close)-1 
 (volume/volume.move(n_move))-1 as r_volume,
 (turnover/turnover.move(n_move))-1 as r_turnover
from quote_1min
where trade_date between date_begin:date_end
context by secu_code

执行后结果如下:
image.png
图中选中的这5根分钟bar,其实是不能参照昨日尾盘的最后5根计算,应该取0了。这句执行后 update一下每日前5根分钟bar数据为0,也是可以达到目的,但我想精炼到一条语句,请问有什么方法?

###

DolphinDB针对时序数据处理,在SQL中增加了一个context by子句,也就是说数据先按照context by后面指定的字段进行分组,每一个组内部再应用序列函数。

上面的例子其实已经使用了context by,只不过只按照股票一个字段进行分组,再增加一个日期字段即可。

n_move=5
t1=
select concatDateTime(trade_date,trade_time) as time,secu_code,
 (close/close.move(n_move))-1 as r_close, //等价于ratios(close)-1 
 (volume/volume.move(n_move))-1 as r_volume,
 (turnover/turnover.move(n_move))-1 as r_turnover
from quote_1min
where trade_date between date_begin:date_end
context by secu_code, trade_date

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 行情数据做日切,可以怎么区分出来?

    行情数据做日切,可以怎么区分出来?

  • 使用WireShark抓包分析握手问题

    使用WireShark抓包分析握手问题

  • intellij idea如何创建maven项目?

    intellij idea如何创建maven项目?

  • 使用keepalived 作为nginx负载均衡,ng

    使用keepalived 作为nginx负载均衡,ng

腾讯云代理商
海外云服务器