Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

在dolphindb中进行数据清洗

有一个表,包含BidPrice,LN和Clean列。

1、LN这一列是计算列,值为:对当前行的BidPrice 除以 前3行的平均值 并取自然对数

2、Clean列是清洗数据的结果 ,取值逻辑:abs(BidPrice) 如果值大于我们设定的波动范围F中的值,取前一个数的值,反之则认为当前报价正常保留当前报价

在dolphindb中应该如何实现?


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

1 Answer

0 votes
by (71.8m points)

可参考下面实现:

F = 0.02
t = table(take(`a`b`c`d`e ,100) as sym, rand(100.0,100) as bidPrice)
tclean = select sym,bidPrice,move(log(bidPrice / mavg(bidPrice,3)),1) as? ln from t?
def cleanFun(F,x,y) : iif(abs(x) > F, y,x)
tclean[`clean] = eachPre(cleanFun{F}, tclean[`ln])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...