Base asset selection
Asset selection infrastructure
Asset selectors are the returns-level preprocessing subfamily that restricts the asset universe. The universe chosen on the training window is the selector's fitted state, so a selector is safe inside cross-validation. The concrete selectors live in Asset selection; this is the seam they share.
Types
PortfolioOptimisers.AssetSelectorResult — Type
struct AssetSelectorResult{__T_nx} <: AbstractReturnsPreprocessingResultFitted result of any AbstractAssetSelector.
Carries the asset universe selected on the training window. One result type serves the whole family: every selector differs in how it chooses the universe, never in what it stores.
Fields
nx: Names of the assets that survived the training window, in their original column order (the fitted universe).
Related
Functions
PortfolioOptimisers.select_assets — Function
select_assets(sel::AbstractAssetSelector, rd::AbstractReturnsResult) -> BitVectorReturn the keep-mask over the asset columns of rd.
This is the single method a concrete AbstractAssetSelector must implement. It is called by fit_preprocessing on the Coverage Universe of the training window only; the resulting universe is then replayed on every later window by apply_preprocessing.
rd is the reduced carrier, so every column it carries is finite at every row and active at every row of the panel. A selector ranks among live assets alone, and it needs no finiteness guard: a non-finite score computed from a live column is a defect of the measure, which is why asset_scores keeps its refusal.
rd is read for nx and an observations × assets X; the funnel itself reads rd.pnl, and ClusterGroups reads it too, so the implicit contract of the family is {nx, X, pnl} (see AbstractReturnsResult). A selector is fitted from returns data alone and never sees a prior result, so it reads the data carrier and nothing else.
Arguments
sel: The asset selector.rd: The training-window returns data.
Returns
keep::BitVector:truefor each asset column to retain,length(keep) == size(rd.X, 2), over the reduced window.
Related
select_assets(
sel::ScoreSelector,
rd::AbstractReturnsResult
) -> BitVector
Select the assets a ScoreSelector keeps: score every asset, then apply the rule.
fit_preprocessing reduces the training window to its Coverage Universe first, so the ranking is among live assets alone and a dead column never takes a place in it. asset_scores keeps its refusal: a non-finite score computed from a live column is a defect of the measure, not a gap in the data.
Algorithm
- Score every asset column of
rd.Xwith the selector'sscore, usingasset_scores. - Read the orientation of the score with
bigger_is_better. - Return the keep-mask
rule_keepadmits for those scores under the selector'srule.
Arguments
sel: The score selector.rd: The returns result to use.
Returns
keep::BitVector: Maskassets × 1that istruefor every asset the rule admits.
Related
select_assets(
_::CompleteAssetSelector,
rd::AbstractReturnsResult
) -> BitVector
Select the assets a CompleteAssetSelector keeps: every asset column of the reduced window.
This selector is the identity on the Coverage Universe. fit_preprocessing reduces the training window before it calls this method, so the columns that reach here are already the ones that are finite at every row and active at every row of the AssetPanel. The dropping is the funnel's, and this selector is the explicit step that asks for it and for nothing else.
Reading the panel's active mask is what the reduction adds: a stale finite price during an inactive spell leaves the asset out, where the released selector, which read finiteness alone, kept it.
Algorithm
- Return a keep-mask of
size(rd.X, 2)trues.
Arguments
- The selector is taken by type alone. It carries no field, so nothing is read from it.
rd: The returns result to use.
Returns
keep::BitVector: Maskassets × 1that istrueat every column of the reduced window.
Related
select_assets(
sel::RedundancySelector,
rd::AbstractReturnsResult
) -> BitVector
Select the assets a RedundancySelector keeps: score every asset when a score is given, then apply the redundancy algorithm.
fit_preprocessing reduces the training window to its Coverage Universe first, so the correlation, the clustering and the survivor rule all read live columns alone, and a dead column never joins a group nor wins one.
Algorithm
- When the selector carries no
score, setscorestonothingandbibtofalse. The algorithm then uses its own survivor rule. - Otherwise score every asset column of
rd.Xwithasset_scores, and readbibfrombigger_is_betterof that score. - Return the keep-mask
redundancy_keepadmits for the selector'salg.
Arguments
sel: The redundancy selector.rd: The returns result to use.
Returns
keep::BitVector: Maskassets × 1that istruefor every surviving asset.
Related