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.AssetSelectorResultType
struct AssetSelectorResult{__T_nx} <: AbstractReturnsPreprocessingResult

Fitted 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

source

Functions

PortfolioOptimisers.select_assetsFunction
select_assets(sel::AbstractAssetSelector, rd::AbstractReturnsResult) -> BitVector

Return 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: true for each asset column to retain, length(keep) == size(rd.X, 2), over the reduced window.

Related

source
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

  1. Score every asset column of rd.X with the selector's score, using asset_scores.
  2. Read the orientation of the score with bigger_is_better.
  3. Return the keep-mask rule_keep admits for those scores under the selector's rule.

Arguments

  • sel: The score selector.
  • rd: The returns result to use.

Returns

  • keep::BitVector: Mask assets × 1 that is true for every asset the rule admits.

Related

source
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

  1. 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: Mask assets × 1 that is true at every column of the reduced window.

Related

source
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

  1. When the selector carries no score, set scores to nothing and bib to false. The algorithm then uses its own survivor rule.
  2. Otherwise score every asset column of rd.X with asset_scores, and read bib from bigger_is_better of that score.
  3. Return the keep-mask redundancy_keep admits for the selector's alg.

Arguments

  • sel: The redundancy selector.
  • rd: The returns result to use.

Returns

  • keep::BitVector: Mask assets × 1 that is true for every surviving asset.

Related

source