qis.compute_portfolio_breadth¶
- qis.compute_portfolio_breadth(returns, weights, *, covar_dict=None, span=36, position_threshold=0.0001, cash_columns=None)[source]¶
Compute point-in-time universe, capital and risk breadth on target-weight dates.
The function does not forward-fill target weights: every row in
weightsis an evaluation point and is measured as supplied. It does use the latest covariance or return observation at or before that date. Provided covariance matrices take precedence over return-based risk estimation. Their strictly positive finite diagonal variances define investability; returns are used only to establish the common asset universe in that case.Without
covar_dict, the native rows ofreturnsfeed QIS’s unadjusted EWM covariance recursion using a second moment about zero andNanBackfill.ZERO_FILL.spancounts those rows, so the caller controls the economic horizon by supplying returns at the intended frequency. Availability is cumulative and point-in-time: an asset is available from its first finite return, never before it.- Parameters:
returns (DataFrame) – Asset return observations. Columns define the complete investment universe.
weights (DataFrame) – Target portfolio weights. Its dates define the evaluation dates and its columns must be contained in
returns. NaN targets are treated as zero; infinite targets are rejected.covar_dict (Mapping[Timestamp, DataFrame] | None) – Optional dated covariance matrices. At each evaluation date the latest matrix at or before the date is used. Matrices may contain NaN rows for unavailable assets, but the positive-variance available submatrix must be finite, symmetric and positive semidefinite up to numerical tolerance.
span (int) – Positive EWM span in native return observations, used only when
covar_dictis absent. For example,span=36means 36 months only whenreturnsis monthly.position_threshold (float) – Non-negative absolute target weight below which a position is treated as immaterial. The comparison is strict:
abs(weight) > position_threshold.cash_columns (Sequence[str] | None) – Optional explicit columns to remove before all counts and calculations. QIS never infers cash from an asset name or covariance.
- Returns:
A
PortfolioBreadthResultwith metrics and aligned audit panels.- Raises:
TypeError – If returns, weights, covariance matrices or parameters have invalid types.
ValueError – If labelled axes, dates, asset coverage or numerical inputs are invalid.
- Return type: