Skip to main content

Linear algebra utilities for portfolio optimization

Project description

cvx-linalg

PyPI version Python Downloads License CodeFactor Rhiza Coverage

Linear algebra utilities for portfolio optimization, part of the jebel-quant ecosystem.

Installation

pip install cvx-linalg

The ewm_covariance function requires the optional Polars dependency:

pip install 'cvx-linalg[ewm]'

Usage

from cvx.linalg import (
    a_norm, cholesky, cholesky_solve,
    inv, inv_a_norm, is_positive_definite, lstsq, pca, rand_cov, solve, valid,
)
from cvx.linalg.covariance.ewm_cov import ewm_covariance  # requires the 'ewm' extra (polars)

Functions

Exceptions & Warnings

All exceptions and warnings live in exceptions.py:

  • DimensionMismatchError — Raised when vector length does not match matrix dimension
  • IllConditionedMatrixWarning — Emitted when the condition number exceeds a configurable threshold
  • InvalidComponentsError — Raised when pca is asked for fewer than 1 or more components than the data supports
  • NegativeWarmupError — Raised when a negative warmup period is passed to ewm_covariance
  • NonIntegerWarmupError — Raised when a non-integer warmup is passed to ewm_covariance
  • NonSquareMatrixError — Raised when a square matrix is required but the input is not square
  • NotAMatrixError — Raised when a 2-D matrix is required but the input has different dimensionality
  • SingularMatrixError — Raised when a matrix is numerically singular
  • check_and_warn_condition(matrix, threshold) — Emit IllConditionedMatrixWarning when the condition number exceeds the threshold

Types

  • Matrix — Type alias for a 2-D numpy.ndarray with float64 dtype
  • Vector — Type alias for a 1-D numpy.ndarray with float64 dtype

The package ships a py.typed marker; all public signatures are precisely annotated and verified with ty in CI.

Stability policy

This package follows semantic versioning. The public API is everything importable from cvx.linalg (plus cvx.linalg.covariance.ewm_cov):

  • Breaking changes only occur in major releases.
  • Deprecations are announced at least one minor release before removal and emit a DeprecationWarning in the meantime (currently: the two-argument cholesky(cov, rhs) form — use cholesky_solve — slated for removal in 1.0).
  • Supported environments: Python 3.11–3.14, NumPy ≥ 2.0. The optional ewm extra requires Polars ≥ 1.40.

Numerical conventions (NaN handling, condition-number warnings, dtype contract) are documented in Numerical Behavior.

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

cvx_linalg-0.9.6.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvx_linalg-0.9.6-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file cvx_linalg-0.9.6.tar.gz.

File metadata

  • Download URL: cvx_linalg-0.9.6.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cvx_linalg-0.9.6.tar.gz
Algorithm Hash digest
SHA256 b8f7d72168f21144da2c76ce9938c363aaeff6050a089c056f1be367bf327d31
MD5 b81e58290aa29042e5092b2b57ae6d44
BLAKE2b-256 f46eb2597a1076fc3362e2fa56ab50e1ed65a1e5913edcea0dfe1cdb5d17a826

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvx_linalg-0.9.6.tar.gz:

Publisher: rhiza_release.yml on Jebel-Quant/linalg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cvx_linalg-0.9.6-py3-none-any.whl.

File metadata

  • Download URL: cvx_linalg-0.9.6-py3-none-any.whl
  • Upload date:
  • Size: 49.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cvx_linalg-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 91dd415c895830c1e3e6327aa97be18663ae65d006361b640c7c75d2923b2b5a
MD5 e66ea91d98a70811a0f65d4ec8073a97
BLAKE2b-256 b4eb7187c59413dccb49723c01bfd99be9afca422a5a195c8fb7fb0ade1ed22d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvx_linalg-0.9.6-py3-none-any.whl:

Publisher: rhiza_release.yml on Jebel-Quant/linalg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page