Cross-Sectional Factor Axis: private API

Functions

PortfolioOptimisers.exposure_axis_names — Function
exposure_axis_names(
    nm::AbstractString,
    xe::AbstractExposureEstimator,
    _::ReturnsResult
) -> Tuple{Vector{String}, Vector}

Return the raw factor names and the Factor Family label of one Factor Exposure.

A OneHotExposure expands to one "<field>=<level>" name per level of the Panel Field it reads, so the name that the caller pairs with it names the block and not a column. A CurrencyExposure expands the same way, less its base currency. Any other member of AbstractObservedExposureEstimator takes the name the caller pairs with it when it gives one factor, as an ObservedExposure does, and names each factor by its series of the Exogenous Series when it gives several, under its own family label. Every other Exposure Estimator produces one factor, and that factor takes the name of the caller.

Arguments

  • nm::AbstractString: The name that the caller pairs with the estimator. The one-hot and the currency methods ignore it.
  • xe: An Exposure Estimator.
  • rd: Returns data that carries the Asset Panel. The one-hot and the currency methods read the levels of their Panel Field, and every other method ignores it.

Returns

  • nf::Vector{String}: The raw factor names the estimator produces, in column order.
  • fam::Vector{String}: The estimator's Factor Family label, repeated once per name.

Related

source
PortfolioOptimisers.cross_sectional_sets_dict — Function
cross_sectional_sets_dict(
    rd::ReturnsResult,
    _::Nothing
) -> Dict{String}

Return the dictionary that cross_sectional_factor_sets writes a cross-sectional factor axis into.

The method for a declared universe copies its dictionary, so every axis that the universe declares stays in the result. The copy is shallow, and the caller only adds keys to it, so the declared universe does not change. The method for nothing declares the asset axis alone, under the default xkey, "nx".

Arguments

  • rd: Returns data carrying the asset names.
  • sets: The declared universe to widen, or nothing.

Validation

  • rd.nx is set when sets is nothing.

Returns

  • dict::Dict{String}: The dictionary to write the axis into. Its value type is the typejoin of the type of the values that it copies and Vector{String}, the type of the lists that cross_sectional_factor_sets writes into it.

Related

source
PortfolioOptimisers.cross_sectional_sets_write! — Function
cross_sectional_sets_write!(
    dict::AbstractDict,
    key::AbstractString,
    val::AbstractVector
)

Write one entry of a cross-sectional factor axis into a universe dictionary, and refuse to replace a different one.

A widened universe carries every entry that the caller declared. A Factor Family label is a plain group name, so a group of the caller can have the same name. A silent replacement of that group would change the meaning of every constraint written against it. So the function refuses a key that holds a different list, and the error names the key. A key that holds the same list keeps its value.

Arguments

  • dict: The dictionary that the caller builds.
  • key: The key to write.
  • val: The list to write under it.

Validation

  • dict holds no entry under key, or holds val there.

Returns

  • nothing.

Examples

julia> d = Dict("style" => ["a"]);julia> PortfolioOptimisers.cross_sectional_sets_write!(d, "style", ["a"]);julia> PortfolioOptimisers.cross_sectional_sets_write!(d, "industry", ["b", "c"]);julia> d["industry"]2-element Vector{String}: "b" "c"

Related

source