我想根据成交量加权平均价格(vwap)计算股票回报的成对相关性。
我的出发点是:
priceMatrix=pivot(wavg, [t.price,t.volume],t.trade_date,t.sym)这将创建一个vwap价格矩阵,其中交易时间作为行标签,股票符号作为列标签。
输出(实际输出有250+rows和1576列):
S1 S2 S3 S4
---- ---- ---- ----
2020.10.01 38.5 29.0 9.8 7.1
2020.10.02 38 29.1 10.4 7.2
2020.10.03 37.2 29.3 10.8 7.6
....我现在需要做的是对每一列进行成对关联,如下所示:
S1 S2 S3 S4
--- --- --- ---
S1 1 ** ** **
S2 ** 1 ** **
S3 ** ** 1 **
S4 ** ** ** 1有没有人知道一种在DolphinDB中获得成对相关矩阵的方法?谢谢!
发布于 2020-12-23 13:48:12
使用交叉函数计算成对相关,例如:
priceMatrix=pivot(avg, t.open,t.trade_date,t.ts_code)
t1=each(ratios,priceMatrix)-1;
pairwisecorr=cross(corr,t1,t1);https://stackoverflow.com/questions/65418647
复制相似问题