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 an AssetSetsMatrixEstimator or a precomputed numeric membership matrix. A JuMP optimiser checks smtx and sgmtx against it when the sub-group cardinality or threshold that reads the matrix is a scalar.
Related
PortfolioOptimisers.MatNum_ASetMatE_VecMatNum_ASetMatE — Type
const MatNum_ASetMatE_VecMatNum_ASetMatE = Union{MatNum_ASetMatE, VecMatNum_ASetMatE}Alias for one asset sets matrix estimator or numeric matrix, or a vector of them.
Matches a MatNum_ASetMatE or a VecMatNum_ASetMatE. The smtx and sgmtx fields of JuMPOptimiser and ProgrammeAllocationSet take it.
Related
PortfolioOptimisers.VecMatNum_ASetMatE — Type
const VecMatNum_ASetMatE = AbstractVector{<:MatNum_ASetMatE}Alias for a vector of asset sets matrix estimators or numeric matrices.
Each entry is a MatNum_ASetMatE. asset_sets_matrix and port_opt_view return one result for each entry, in the order of the vector.
Related
PortfolioOptimisers.taxonomy_column — Function
taxonomy_column(
sets::UniverseSets,
key::AbstractString,
need::AbstractString
) -> Any
Read the taxonomy column sets.dict[key], and check that the key exists.
It does for a group name key what factor_universe does for the factor universe key. asset_sets_matrix and panel_input read a Universe Sets key through it, so a missing key gives the same message in both. A bare sets.dict[key] raises a KeyError that holds the key alone. That error does not tell which function asked for the key, and it suggests no correction for a typo.
need names the caller. suggest_declared_key gives the suggestion, with the configuration that admits more matches than the global default. The global default is strict so that a message does not show a real asset name. The candidates here are sets.dict keys that the caller wrote, so that risk does not apply.
Arguments
sets: AUniverseSetsthat holds the asset universe and the groups.key: The group name key to read.need: The name of the caller, which the error message gives.
Validation
haskey(sets.dict, key). Raises aKeyError. The message nameskeyandneed, and ends with asuggest_declared_keysuggestion. The exception stays aKeyError, as infactor_universe, because the key is missing. The message is the only change.
Returns
col: The value ofsets.dict[key], with one group for each asset.
Related
PortfolioOptimisers.panel_input_name — Function
panel_input_name(sets::UniverseSets, key::AbstractString) -> StringName the Panel Field that a UniverseSets key becomes, which is the key without its asset prefix.
Every Panel Field of an AssetPanel is indexed by asset. The xkey prefix marks a Universe Sets key as asset-length, so it gives no information on a Panel Field. The function removes the prefix and the underscore after it, so "nx_sector" becomes "sector". A key with 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: TheUniverseSets, which givesxkey.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 from the values of a UniverseSets key.
A key of strings is a classification, and a key of numbers is a quantity. The function refuses a key that holds both, because such a key describes two things.
Algorithm
- Return
CategoricalPanelInputwhen every value is a string. - Return
NumericPanelInputwhen every value is a number. - Otherwise raise an
ArgumentError. The message names the key and the twoPairforms that force a type.
Arguments
vals: The values of the key.key: The key, which the error message names.
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 of the type that panel_input chose.
Algorithm
The method that Julia selects is the algorithm. Each method builds its own input type from the values of the key. panel_input_name names the input, unless name overrides it. Only the categorical method passes levels on. A numeric input has no levels, so the numeric method refuses levels and does not ignore it.
Arguments
- The first positional argument: The input type to build.
sets: TheUniverseSets, which givesxkey.key: The key that holds the values.vals: The values of the key.name: The Panel Field name, ornothingto derive it.levels: The category levels, ornothing.alg: The fill policy.
Validation
levelsisnothingon the numeric form. Raises anArgumentError.
Returns
- One
AbstractPanelFieldInput.
Related