我想在移动窗口内对值与窗口内最后一个值的大小进行判断后(大于则为原值,小于则为0)再进行加权平均
但使用mwavg(price*iif(price>last(price,1,0),vol,3)函数时候last取值为所有序列值得最后一个值 请问使用什么函数进行计算
实现方式:
price=2.1 2.2 2.3 2.5 2.6 2.8 2.7 2.5; volume=10 20 10 40 10 40 10 20; a = table(price,volume) windowLength = 3 select *, mwavg(iif(price>mlast(price, windowLength), price, 0), volume, windowLength, 1) from a
输出结果:
对窗口聚合计算,DolphinDB提供了形如 mfirst mlast 等 m* 开头的函数作为普通函数的滑动版本。希望能对您有帮助,更多信息可以参考: