You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The parameter cov_matrix required to be pd.DataFrame, but matrix multiplier may be error due to the issue of matrix align. But if we pass the values of matrix to cov_matrix, the warnings show.
Expected behavior
No warnings, no errors.
Code sample
Just a little change could be useful
if not isinstance(cov_matrix, pd.DataFrame):
warnings.warn(
"If cov_matrix is not a dataframe, market cap index must be aligned to cov_matrix",
RuntimeWarning,
)
mcaps = pd.Series(market_caps)
mkt_weights = mcaps / mcaps.sum()
# Pi is excess returns so must add risk_free_rate to get return.
return risk_aversion * cov_matrix.values.dot(mkt_weights) + risk_free_rate # change here!
Also, the parameter risk_free_rate should be used with frequency. For example, if we use weekly data, then the extra parameter such as freq=52 should be provided by users, and the code should be added:
Describe the bug
The parameter
cov_matrix
required to bepd.DataFrame
, but matrix multiplier may be error due to the issue of matrix align. But if we pass the values of matrix tocov_matrix
, the warnings show.Expected behavior
No warnings, no errors.
Code sample
Just a little change could be useful
Also, the parameter
risk_free_rate
should be used with frequency. For example, if we use weekly data, then the extra parameter such asfreq=52
should be provided by users, and the code should be added:Operating system, python version, PyPortfolioOpt version
Win 11, python 3.8.15, PyPortfolioOpt 1.2.6
The text was updated successfully, but these errors were encountered: