cov_pred_finance
cov_pred_finance copied to clipboard
Calling `cov_pred_finance` from `cvx_portfolio`?
Hello @tschm and @kasperjo. I've been looking at this repository and your paper and I think it would be easy to write a class that wraps the functionality you provide to integrate in cvxportfolio
. In the simplest case it would be something like
class CvxCovariance(BaseForecast):
def __init__(self, **all_your_hyperparameters):
# save the hyperparameters
...
def _pre_evaluation(self, universe, *args):
# initialize your objects knowing the size of the universe
...
def _values_in_time(self, past_returns, **kwargs):
# do the computation for covariance at time t knowing past returns (up to time t-1)
...
return sqrt_Sigma # so that Sigma = sqrt_Sigma.T @ sqrt_Sigma
It would be invoked simply by the user and operate completely independently, so the user doesn't have to worry about passing data in the right format, .... (See the examples to see what I mean.) All the cvxpy operations are done from cvxportfolio, and it also takes care of adding and removing assets from the universe as IPOs and bankruptcies happen.
I'm not sure if your method is safe against missing values (past_returns
could have nan
at the top of some of the columns) but if not you can just throw an error if the user provides such data.
This could even just be in your examples (or cvxportfolio
's) and not in any package proper, to not change dependencies.
If you want I can help you to interface with some more of the more advanced facilities, like multi-period forecasting (provide forecast at time t for covariance at time t+tau), on- and off-line caching (which saves on disk expensive computation, safely against parallel execution), ....