Asset sets matrix: private API
PortfolioOptimisers.MatNum_ASetMatE — Type
const MatNum_ASetMatE = Union{<:AssetSetsMatrixEstimator, <:MatNum}Alias for an asset sets matrix estimator or a numeric matrix.
Matches either an AssetSetsMatrixEstimator or a plain numeric matrix. Used internally in constraint generation that accepts a pre-computed membership matrix or an estimator.
Related
PortfolioOptimisers.MatNum_ASetMatE_VecMatNum_ASetMatE — Type
const MatNum_ASetMatE_VecMatNum_ASetMatE = Union{<:MatNum_ASetMatE, <:VecMatNum_ASetMatE}Alias for a single or vector of asset sets matrix estimators or numeric matrices.
Matches either a single MatNum_ASetMatE or a vector of them. Used for dispatch in asset set matrix operations that accept one or many estimators or matrices.
Related
PortfolioOptimisers.VecMatNum_ASetMatE — Type
const VecMatNum_ASetMatE = AbstractVector{<:MatNum_ASetMatE}Alias for a vector of asset sets matrix estimators or numeric matrices.
Represents a collection of MatNum_ASetMatE elements, enabling batch processing.
Related
PortfolioOptimisers.taxonomy_column — Function
taxonomy_column(
sets::UniverseSets,
key::AbstractString,
need::AbstractString
) -> Any
Read the taxonomy column sets.dict[key], checking that the key exists.
The sibling of factor_universe for a group name key, and written for the same reason: one shared helper whose message names the key and says what to do about it, so every consumer of a caller-supplied taxonomy key fails the same way. A bare sets.dict[key] raises a KeyError carrying the key alone, which says nothing about which of the two producers asked for it, and offers no help with a typo.
need names the consumer. The suggestion comes from suggest_declared_key, the looser configuration shared by every declaration-key suggestion: the candidates here are sets.dict keys the caller authored, not asset names, so the info-leak-safe boundary does not apply.
Arguments
sets: AUniverseSetsobject specifying the asset universe and groupings.key: The group name key to read.need: Names the consumer in the error message.
Validation
haskey(sets.dict, key). Raises aKeyErrornamingkey, namingneedas the consumer that asked for it, and carrying asuggest_declared_keysuggestion. The exception stays aKeyError, asfactor_universedoes, because a missing key is what it is — only the message improves.
Returns
col: The value ofsets.dict[key], one group per asset.
Related
PortfolioOptimisers.panel_input_name — Function
panel_input_name(sets::UniverseSets, key::AbstractString) -> StringName the Panel Field a UniverseSets key becomes: the key with the asset prefix stripped.
Every Panel Field of an AssetPanel is asset-parallel by construction, so the xkey prefix that marks a key as asset-length says nothing there and comes off, with its separating underscore: "nx_sector" becomes "sector". A key that carries no prefix keeps its name.
Algorithm
- Return the key unchanged when it does not start with
sets.xkeyfollowed by an underscore. - Otherwise return the key with that prefix and the underscore removed.
Arguments
sets: The universe sets, read forxkey.key: The key to name.
Returns
name::String: The Panel Field name.
Related
PortfolioOptimisers.panel_input_kind — Function
panel_input_kind(vals::AbstractVector, key::AbstractString) -> TypeChoose the raw Panel Field input type a UniverseSets key's values ask for.
The element type is the whole rule: a string-valued key is a classification and a number-valued key is a quantity. A mixed element type is refused, because a taxonomy that carries both in one key describes two things.
Algorithm
- Return
CategoricalPanelInputwhen every value is a string. - Return
NumericPanelInputwhen every value is a number. - Otherwise raise, naming the key and the two forms that resolve it.
Arguments
vals: The key's values.key: The key, named in the message.
Validation
- Every value is a string, or every value is a number. Raises an
ArgumentError.
Returns
- The input type.
Related
PortfolioOptimisers.panel_input_build — Function
panel_input_build(::Type{CategoricalPanelInput}, sets, key, vals, name, levels, alg)
panel_input_build(::Type{NumericPanelInput}, sets, key, vals, name, levels, alg)Build the raw Panel Field input panel_input resolved to.
Algorithm
The method that Julia selects is the algorithm. Each builds its own input type from the key's values, named by panel_input_name unless name overrides it. levels reaches the categorical form alone; the numeric form has no levels to declare and refuses one rather than ignoring it.
Arguments
- The first positional: the input type to build.
sets: The universe sets, read forxkey.key: The key the values came from.vals: The key's values.name: Panel Field name, ornothingto derive it.levels: Category levels, ornothing.alg: Fill policy.
Validation
levelsisnothingon the numeric form. Raises anArgumentError.
Returns
- One
AbstractPanelFieldInput.
Related