Feature distance active rows
PortfolioOptimisers.feature_readable — Function
feature_readable(alg, A::AbstractMatrix{Bool}) -> BitVectorMark 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.
LastObservationforwards to its rule.LastRow: an asset is readable when it is active at the last row.- 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 aLastObservation.A: The active mask of the window,observations × assets.
Returns
r::BitVector: One entry per asset,truewhere the collapse can read the asset.
Related
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.
RefusePair: refuse, and name each pair and the two other rules.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.FeatureFallback: collapse each asset over its own active rows withactive_collapse, under the weights of the rule. Fill the distance of each pair withpair_distanceof the two collapsed vectors, laid out byfallback_featuresas the collapse ofdereads a row.
Arguments
D: The distance matrix,assets × assets, written in place at each pair ofE.pair: The rule for an empty pair.E: The empty pairs,(i, j)withi < j.de: The feature distance estimator.win: The window, aNamedTupleofZ,dims,Aandnx.
Returns
D::MatNum: Distance matrixassets x assets, in the units the distance algorithm defines.
Related
PortfolioOptimisers.drop_empty_pairs! — Function
drop_empty_pairs!(keep::BitVector, pair, A::AbstractMatrix{Bool}) -> BitVectorDrop, 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, ornothingfor a collapse that reads no pair.A: The active mask of the window,observations × assets.
Returns
keep::BitVector: The kept assets.
Related