I want to estimate the covariance matrix using high-frequency data in Julia. I wish to start with using the realized covariance estimator. Thus, is there any available Julia code to estimate using rcov?
Asked
Active
Viewed 61 times
1 Answers
2
I don't think you need a package for this. Realized covariance is a very simple estimator. Let pmat
denote a matrix of high-frequency prices, where columns correspond to assets, and rows correspond to the time-index. The high frequency returns can be obtained via:
rmat = log.(pmat[2:end,:] ./ pmat[1:end-1,:])
Note, you could speed up this computation by using a loop instead to avoid temporary allocations. Or as Oscar points out in the comments:
rmat = @views log.(pmat[2:end,:] ./ pmat[1:end-1,:])
will also reduce temporaries while preserving the neat one-liner.
Given rmat
, the realized covariance estimator spanning the first to last time index is just:
realizedcov = rmat' * rmat

Colin T Bowers
- 18,106
- 8
- 61
- 89
-
1`@views log.(pmat[2:end,:] ./ pmat[1:end-1,:])` will have 2 less copies. – Oscar Smith Apr 22 '21 at 01:51
-
@OscarSmith I've adjusted the answer thanks. – Colin T Bowers Apr 23 '21 at 06:17