Feature request: Upgrade HRPOpt to prefer supplied covariance matrix
Is your feature request related to a problem?
I was looking at the source code for HRPOpt and noticed that it prefers to compute the covariance as opposed to using the constructor supplied covariance matrix. I read through the earlier discussion, and was reading the code because I was interested in the implementation.
Describe the feature you'd like
I believe the following change to HRPOpt.optimize would allow users to supply both returns and a pre-shrunk covariance matrix and get the expected results:
if self.cov_matrix is not None:
cov = self.cov_matrix
corr = risk_models.cov_to_corr(self.cov_matrix).round(6)
else:
corr, cov = self.returns.corr(), self.returns.cov()
I'm testing out this change locally and if I can get all your unit tests to pass I'd like to submit a pull request.
I don't think HRP should compute the covariance matrix at all. We will give access to a few methods to compute a Dendrogram. The covariance matrix is one such route.... Otherwise, we keep repeating the same functionality/code at different places in this package.