Feature distance active rows

PortfolioOptimisers.feature_readable — Function
feature_readable(alg, A::AbstractMatrix{Bool}) -> BitVector

Mark the assets that a collapse can read in a window, from the active mask of the window.

Algorithm

The method that Julia selects is the algorithm.

  1. LastObservation forwards to its rule.
  2. LastRow: an asset is readable when it is active at the last row.
  3. Every other rule and collapse: an asset is readable when it is active at one row of the window at least.

Arguments

  • alg: The collapse algorithm, or the rule of a LastObservation.
  • A: The active mask of the window, observations × assets.

Returns

  • r::BitVector: One entry per asset, true where the collapse can read the asset.

Related

source
PortfolioOptimisers.empty_pair_distance! — Function
empty_pair_distance!(D::MatNum, pair::AbstractEmptyPairAlgorithm, E, de::FeatureDistance, win)

Give the distance of each pair of assets in E, which share no active row, by the rule pair.

Algorithm

The method that Julia selects is the algorithm.

  1. RefusePair: refuse, and name each pair and the two other rules.
  2. DropFewerRows: refuse, because the rule drops an asset at the entry of a fit, and a direct call has none. Name each pair and the remedy.
  3. FeatureFallback: collapse each asset over its own active rows with active_collapse, under the weights of the rule. Fill the distance of each pair with pair_distance of the two collapsed vectors, laid out by fallback_features as the collapse of de reads a row.

Arguments

  • D: The distance matrix, assets × assets, written in place at each pair of E.
  • pair: The rule for an empty pair.
  • E: The empty pairs, (i, j) with i < j.
  • de: The feature distance estimator.
  • win: The window, a NamedTuple of Z, dims, A and nx.

Returns

  • D::MatNum: Distance matrix assets x assets, in the units the distance algorithm defines.

Related

source
PortfolioOptimisers.drop_empty_pairs! — Function
drop_empty_pairs!(keep::BitVector, pair, A::AbstractMatrix{Bool}) -> BitVector

Drop, under DropFewerRows, one asset of each pair with no shared active row, until no pair of the kept assets is empty.

Each pass finds the first empty pair (i, j) of the kept assets, with i < j, and drops the asset with fewer active rows in the window. On a tie it drops j, the asset that comes later in the universe. Every other rule keeps keep unchanged: RefusePair refuses in the kernel, and FeatureFallback measures the pair there.

Arguments

  • keep: The assets kept so far, changed in place.
  • pair: The rule for an empty pair, or nothing for a collapse that reads no pair.
  • A: The active mask of the window, observations × assets.

Returns

  • keep::BitVector: The kept assets.

Related

source