markowitz.views.view_specs¶
markowitz.views.view_specs
¶
User-facing view specifications and the :class:Views container.
A Black-Litterman investor expresses subjective opinions as a collection of views. Each view is either
- an absolute view on a single asset (
E[r_i] = q), or - a relative view that pits one basket of assets against another
(
sum(P_long) * r - sum(P_short) * r = q).
The :class:Views class collects a sequence of these dataclasses, validates
them against the asset universe, and assembles the (P, Q) matrices used
downstream by the Theil mixed-estimation form.
AbsoluteView(asset: str, expected_return: float, confidence: float | None = None)
dataclass
¶
A point estimate on a single asset's expected excess return.
RelativeView(long_leg: Mapping[str, float], short_leg: Mapping[str, float], spread: float, confidence: float | None = None)
dataclass
¶
A spread view between a long and a short basket of assets.
The basket weights specify how each leg is constructed: long_leg maps
asset names to non-negative coefficients and likewise short_leg. The
resulting pick row is long_leg - short_leg and must sum to zero (this
is verified at construction time).
Views(views: Sequence[ViewSpec], assets: Sequence[str])
¶
Container that validates and serialises a list of :class:ViewSpec.
Source code in src/markowitz/views/view_specs.py
build_omega_he_litterman(tau: float, cov: np.ndarray) -> np.ndarray
¶
Return the He-Litterman diagonal Omega = diag(P tau Sigma P^T).
Source code in src/markowitz/views/view_specs.py
build_pq() -> tuple[np.ndarray, np.ndarray]
¶
Return the (P, Q) matrices for the current view set.
Source code in src/markowitz/views/view_specs.py
confidences() -> np.ndarray | None
¶
Return per-view confidences as an array, or None if unspecified.