Factors API¶
asrquant.factors ¶
Factor research, PCA decomposition, exposures, and portfolio factor risk.
The module is intentionally transparent: inputs and outputs are pandas objects, regression chronology remains explicit, and no factor is labelled economically without the researcher's interpretation.
PCAFactorResult
dataclass
¶
Bases: ResultMixin
Principal-component factor decomposition of a return or curve panel.
Source code in src/asrquant/factors.py
FactorExposureResult
dataclass
¶
Bases: ResultMixin
Multi-asset time-series factor exposures estimated one asset at a time.
Source code in src/asrquant/factors.py
FactorRiskResult
dataclass
¶
Bases: ResultMixin
Portfolio variance decomposition into factor and specific components.
Source code in src/asrquant/factors.py
pca ¶
pca(data: DataFrame, n_components: int = 3, *, standardize: bool = False, component_prefix: str = 'PC') -> PCAFactorResult
Extract orthogonal statistical factors using principal components.
standardize=False is usually appropriate for returns in common units.
Set standardize=True when columns have materially different scales and
the intended analysis is correlation-based rather than covariance-based.
Source code in src/asrquant/factors.py
exposures ¶
exposures(asset_returns: Series | DataFrame, factor_returns: Series | DataFrame, *, covariance: str = 'HAC', maxlags: int | None = None) -> FactorExposureResult
Estimate multi-asset factor betas with robust time-series regressions.
Source code in src/asrquant/factors.py
rolling_beta ¶
Rolling single-factor beta computed as cov(asset, factor) / var(factor).
Source code in src/asrquant/factors.py
risk_decomposition ¶
risk_decomposition(weights: Series | Sequence[float] | ndarray, betas: DataFrame | ndarray, factor_covariance: DataFrame | ndarray, specific_variance: Series | Sequence[float] | ndarray, *, asset_names: Sequence[str] | None = None, factor_names: Sequence[str] | None = None) -> FactorRiskResult
Decompose portfolio variance under a linear factor risk model.
The model is Sigma = B F B' + D where D is diagonal specific
variance. Factor variance contributions use the Euler decomposition of
b_p' F b_p with portfolio factor exposure b_p = B' w.