I want to calculate the pairwise correlations of stock returns based on the volume-weighted average prices (vwap).
My starting point is :
priceMatrix=pivot(wavg, [t.price,t.volume],t.trade_date,t.sym)
This creates a vwap price matrix with the trade time as row label and the stock symbol as column label.
Output (the real one has 250+rows and 1576 columns):
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
....
What I need now is to do the pairwise correlations for each column like this:
S1 S2 S3 S4
--- --- --- ---
S1 1 ** ** **
S2 ** 1 ** **
S3 ** ** 1 **
S4 ** ** ** 1
Does anyone know of a way I can get a pairwise correlation matrix in DolphinDB? Thanks!