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.1.tar.gz (34.2 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.1-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cvx_linalg-0.9.1.tar.gz
  • Upload date:
  • Size: 34.2 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.1.tar.gz
Algorithm Hash digest
SHA256 fb8026a17066544861f50d1c17229ff3fae64102f4facb7d0a2f88d242d6a1e9
MD5 7515a56a4d3ba754eb0cab14a20131f1
BLAKE2b-256 efb69fd50f5079529b8d5220e1d16e30abac2f52dba36cca49a809753ff7815d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvx_linalg-0.9.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: cvx_linalg-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 39.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 094ab976fce5b22cc3c01a1237ef7f6ec87dad6bc1b8282cb01dd2c0ea1a0729
MD5 b973eba82ee17a7d5fc3ec3eef552d89
BLAKE2b-256 9600c8ae5179557b42a439479cbd1dd93944f83653b5771f5369abc29f4dedaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvx_linalg-0.9.1-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