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.
- Under
LastRow, an asset is readable when it is active at the last row. - Under every other collapse, an asset is readable when it is active at one row of the window at least.
Arguments
alg: The collapse algorithm.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.
- Under
RefusePair, refuse. Name each pair and the two other rules. - Under
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. - Under
FeatureFallback, resolve the weights of the rule withcollapse_weights. Collapse each asset over its own active rows withactive_collapse, under the collapse and the weights of the rule, givingZf. - Then lay out the two rows of
Zfof each pair as the collapse ofdereads one asset, withfallback_features. Write theirpair_distancetoD[i, j]andD[j, i].
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.
Validation
pairis aFeatureFallback.RefusePairandDropFewerRowsraise anArgumentErrorthat names each pair ofE.
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 drops the asset with fewer active rows in the window from the first empty pair. 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.
Algorithm
The method that Julia selects is the algorithm.
- Under every rule but
DropFewerRows, returnkeep. - Under
DropFewerRows, count the active rows of each asset inA, givingn. - Find the first empty pair
(i, j)of the kept assets withfirst_empty_pair, givingp. - While
pis notnothing, dropjfromkeepwhenn[j] <= n[i], andiotherwise. Then find the next empty pair. - Return
keep.
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