markowitz.estimators¶
markowitz.estimators
¶
Estimators for expected returns and asset covariance matrices.
AmbiguousFrequencyError
¶
Bases: EstimatorError
Raised when annualization is requested but periods-per-year is undetermined.
CAPMReturns(*, risk_free_rate: float = 0.0, market_premium: float | None = None, annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseMean
CAPM-implied expected returns from per-asset OLS betas.
Source code in src/markowitz/estimators/means.py
CovarianceEstimator
¶
Bases: Protocol
Protocol for an estimator that produces a covariance matrix.
DimensionMismatchError
¶
Bases: EstimatorError
Raised when input arrays have incompatible shapes.
EWMACovariance(*, halflife_years: float | None = None, lam: float | None = None, burn_in: int | Literal['auto'] = 'auto', annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseCov
Exponentially weighted covariance (RiskMetrics recursion).
Source code in src/markowitz/estimators/covariance.py
EWMAMean(*, halflife_years: float | None = None, lam: float | None = None, annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseMean
Exponentially weighted mean using RiskMetrics-style decay.
Source code in src/markowitz/estimators/means.py
EstimatorConfigError
¶
Bases: EstimatorError
Raised when an estimator is constructed with an invalid configuration.
EstimatorError
¶
Bases: Exception
Base class for all estimator-related errors.
ImpliedReturns(*, delta: float = 2.5)
¶
JorionBayesStein(*, base_cov: np.ndarray | None = None, annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseMean
Bayes-Stein shrinkage of the sample mean toward the minimum-variance mean.
Source code in src/markowitz/estimators/means.py
LedoitWolfShrinkage(*, target: Literal['identity', 'constant_corr'] = 'identity', annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseCov
Ledoit-Wolf shrinkage covariance, sklearn-compatible for the identity target.
Source code in src/markowitz/estimators/covariance.py
MeanEstimator
¶
Bases: Protocol
Protocol for an estimator that produces an expected-returns vector.
NotFittedError
¶
Bases: EstimatorError
Raised when accessing fitted attributes before calling .fit.
SampleCovariance(*, annualize: bool = True, periods_per_year: int | None = None, ddof: int = 1)
¶
Bases: _BaseCov
Plain sample covariance np.cov(returns.T, ddof=ddof).
Source code in src/markowitz/estimators/covariance.py
SampleMean(*, annualize: bool = True, periods_per_year: int | None = None)
¶
Bases: _BaseMean
Plain sample mean μ̂ = mean(returns, axis=0).