mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 23:47:46 +00:00
fix: also catch ValueError in mean_variance for dimension mismatch
This commit is contained in:
@@ -26,7 +26,7 @@ class PortfolioOptimizer:
|
||||
try:
|
||||
w = np.linalg.inv(cov.values) @ exp_ret.values
|
||||
return w / np.sum(w)
|
||||
except np.linalg.LinAlgError:
|
||||
except (np.linalg.LinAlgError, ValueError):
|
||||
return np.ones(len(exp_ret)) / len(exp_ret)
|
||||
|
||||
def risk_parity(self, cov: pd.DataFrame, max_iter: int = 100) -> np.ndarray:
|
||||
|
||||
Reference in New Issue
Block a user