Linear algebra utilities for portfolio optimization
Project description
cvx-linalg
Linear algebra utilities for portfolio optimization, part of the jebel-quant ecosystem.
Installation
pip install cvx-linalg
Usage
from cvx.linalg import (
a_norm, cholesky, ewm_covariance,
inv, inv_a_norm, is_positive_definite, lstsq, pca, rand_cov, solve, valid,
)
Functions
a_norm(vector, matrix=None)— Euclidean norm or NaN-aware matrix normcholesky(cov, rhs=None)— Upper triangular Cholesky factor R such that R.T @ R = cov; when rhs is given, solves cov @ x = rhs (falls back to LU for non-positive-definite matrices)cond(matrix, p=None)— Condition number of a matrix (NaN-aware); accepts the samepnorm values asnumpy.linalg.conddet(matrix, cond_threshold=1e12)— Determinant of a square matrix with NaN-aware submatrix handling; emitsIllConditionedMatrixWarningwhen near-singulareigvals(matrix)— Eigenvalues of a general square matrix (supports complex output for non-symmetric matrices)eigh(matrix)— Eigenvalues/eigenvectors of the valid symmetric/Hermitian submatrix in ascending eigenvalue ordereigvalsh(matrix)— Eigenvalues-only convenience wrapper aroundeighewm_covariance(data, assets, index_col, window, is_halflife, warmup)— Exponentially weighted covariance matrices from a Polars DataFrameinv(matrix, cond_threshold=1e12)— Invert a matrix restricted to valid rows/columns; NaN rows/columns are returned for invalid positionsinv_a_norm(vector, matrix=None)— Euclidean norm or inverse NaN-aware matrix normlstsq(matrix, rhs, cond_threshold=1e12)— Solve a least-squares system with NaN-aware row filtering; returns(x, residuals, rank, sv)consistent withnumpy.linalg.lstsqis_positive_definite(matrix)— Return True if the matrix is symmetric positive-definitepca(returns, n_components)— Principal Component Analysis via SVDqr(matrix)— Reduced QR decomposition, matchingnp.linalg.qr(mode='reduced')rand_cov(n, seed)— Random positive semi-definite covariance matrixsolve(matrix, rhs, cond_threshold=1e12)— Solve a linear system restricted to valid rows/columns; NaN entries are returned for invalid positionssvd(matrix)— Raw compact singular value decomposition vianp.linalg.svd(full_matrices=False)valid(matrix)— Return a boolean mask and valid submatrix by removing rows/columns with non-finite diagonal entries
Exceptions & Warnings
DimensionMismatchError— Raised when vector length does not match matrix dimensionIllConditionedMatrixWarning— Emitted when the condition number exceeds a configurable thresholdNegativeWarmupError— Raised when a negative warmup period is passed toewm_covarianceNonSquareMatrixError— Raised when a square matrix is required but the input is not squareSingularMatrixError— Raised when a matrix is numerically singularcheck_and_warn_condition(matrix, threshold)— EmitIllConditionedMatrixWarningwhen the condition number exceeds the threshold
Types
Matrix— Type alias fornumpy.ndarraywithfloat64dtype
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cvx_linalg-0.6.0.tar.gz.
File metadata
- Download URL: cvx_linalg-0.6.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bfc4fef9eb28925153519f77260f866a7478a51a28e1ed547e98b66fd32d2a1
|
|
| MD5 |
7a8074f3816e5226fa3bdeba4270d0a6
|
|
| BLAKE2b-256 |
c41b281a688feb6394930a793987a3bc098f290fddfc4bc304903ff5aa3c8bf0
|
Provenance
The following attestation bundles were made for cvx_linalg-0.6.0.tar.gz:
Publisher:
rhiza_release.yml on Jebel-Quant/linalg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cvx_linalg-0.6.0.tar.gz -
Subject digest:
6bfc4fef9eb28925153519f77260f866a7478a51a28e1ed547e98b66fd32d2a1 - Sigstore transparency entry: 1571740627
- Sigstore integration time:
-
Permalink:
Jebel-Quant/linalg@def458d84e9f6c34b3b41eb8aab275d4dd00fedb -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/Jebel-Quant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rhiza_release.yml@def458d84e9f6c34b3b41eb8aab275d4dd00fedb -
Trigger Event:
push
-
Statement type:
File details
Details for the file cvx_linalg-0.6.0-py3-none-any.whl.
File metadata
- Download URL: cvx_linalg-0.6.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
603d5ad27d9fddfdafe10698abb95abd73f40c0cc977438dd99c697d78c0a7f5
|
|
| MD5 |
12cee19510a756b3f337c42cda9e0c04
|
|
| BLAKE2b-256 |
e638b6e59a539ff7e41053ddce35b2d727cc2c3255cdaa80442f25588ebe5193
|
Provenance
The following attestation bundles were made for cvx_linalg-0.6.0-py3-none-any.whl:
Publisher:
rhiza_release.yml on Jebel-Quant/linalg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cvx_linalg-0.6.0-py3-none-any.whl -
Subject digest:
603d5ad27d9fddfdafe10698abb95abd73f40c0cc977438dd99c697d78c0a7f5 - Sigstore transparency entry: 1571740648
- Sigstore integration time:
-
Permalink:
Jebel-Quant/linalg@def458d84e9f6c34b3b41eb8aab275d4dd00fedb -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/Jebel-Quant
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rhiza_release.yml@def458d84e9f6c34b3b41eb8aab275d4dd00fedb -
Trigger Event:
push
-
Statement type: