Skip to content

Raise a clearer error when CLA receives a singular covariance matrix#741

Open
Whning0513 wants to merge 1 commit into
PyPortfolio:mainfrom
Whning0513:fix-issue-737
Open

Raise a clearer error when CLA receives a singular covariance matrix#741
Whning0513 wants to merge 1 commit into
PyPortfolio:mainfrom
Whning0513:fix-issue-737

Conversation

@Whning0513

Copy link
Copy Markdown

Fixes #737.

CLA.max_sharpe() currently lets singular covariance submatrices fall through to np.linalg.inv, which surfaces a raw LinAlgError: Singular matrix from NumPy.

This wraps the CLA matrix inversions in a small helper so the failure becomes a user-facing ValueError that explains the current CLA implementation needs an invertible covariance matrix. I also added a regression test covering a perfectly correlated two-asset covariance matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CLA crashes with LinAlgError on singular covariance matrices instead of raising a user-facing validation error

1 participant