Cross-Sectional Factor Axis

Functions

PortfolioOptimisers.cross_sectional_factor_axisFunction
cross_sectional_factor_axis(
    factors::AbstractVector{<:Pair},
    rd::ReturnsResult
) -> @NamedTuple{nf::Vector{String}, fam::Vector{String}}

Return the cross-sectional factor axis a set of Factor Exposures produces, before any fit.

The axis is fixed by the Asset Panel's field index, so it is the same in every fold. A caller who writes a FactorSpace mandate reads it before a prior exists, and the fitted CrossSectionalFactorModel stores the same answer in its nf and fam.

Algorithm

  1. Take the Pairs in the order the caller wrote them, which is the column order of the exposures.
  2. Expand each Pair through exposure_axis_names, so a one-hot member contributes one name per level.
  3. Refuse a repeated factor name.

Arguments

  • factors: Pairs of factor name => Exposure Estimator.
  • rd: Returns data carrying the Asset Panel the one-hot levels are read from.

Validation

  • factors is not empty.
  • No factor name appears twice.

Returns

  • nf::Vector{String}: The raw factor names, in column order.
  • fam::Vector{String}: The Factor Family label of each name.

Related

source
cross_sectional_factor_axis(
    pe::CrossSectionalFactorPrior,
    rd::ReturnsResult
) -> @NamedTuple{nf::Vector{String}, fam::Vector{String}}

Return the cross-sectional factor axis a CrossSectionalFactorPrior will produce, before any fit.

The method forwards pe.factors to the Pairs method of cross_sectional_factor_axis, so a caller who holds the estimator reads the axis off it rather than copying the Pairs. A one-hot member's levels are read off the Asset Panel rd carries, so the answer is fixed by the panel's field index and is the same in every fold.

Arguments

  • pe: Cross-Sectional Factor Prior estimator.
  • rd: Returns data carrying the Asset Panel the one-hot levels are read from.

Validation

Returns

  • nf::Vector{String}: The raw factor names, in column order.
  • fam::Vector{String}: The Factor Family label of each name.

Related

source
PortfolioOptimisers.cross_sectional_factor_setsFunction
cross_sectional_factor_sets(factors::AbstractVector{<:Pair}, rd::ReturnsResult,
                            sets::Option{<:UniverseSets} = nothing) -> UniverseSets

Declare the cross-sectional factor axis and its Factor Family groups on a UniverseSets.

Algorithm

  1. Read the axis with cross_sectional_factor_axis.
  2. Write the names under sets.cfkey, so factor_axis_key finds them from a CrossSectionalFactorModel.
  3. Write one plain group per Factor Family label, holding that family's member names. A plain group carries no axis prefix, so a constraint generator reads it as a group of names rather than as a partition of an axis.
  4. Build the widened UniverseSets, which re-runs every guard of the constructor.

Arguments

  • factors: Pairs of factor name => Exposure Estimator.
  • rd: Returns data carrying the Asset Panel the one-hot levels are read from, and the asset names a new sets declares.
  • sets: A declared universe to widen. When it is nothing, a new one is built over rd.nx with the default key prefixes.

Validation

  • The rules of cross_sectional_factor_axis.
  • A new sets needs rd.nx, because the asset axis is the one mandatory axis of a UniverseSets.
  • A Factor Family label equal to a factor name is refused, unless the family holds that one factor and nothing else. Two different lists would otherwise answer to one name.
  • A widened universe that already declares the cross-sectional axis, or a group under a Factor Family label, must declare the same list. A different one is refused rather than replaced, through cross_sectional_sets_write!.
  • The rules of UniverseSets.

Returns

  • sets::UniverseSets: The declared universe, carrying the cross-sectional factor axis and one group per Factor Family.

Related

source
cross_sectional_factor_sets(pe::CrossSectionalFactorPrior, rd::ReturnsResult,
                            sets::Option{<:UniverseSets} = nothing) -> UniverseSets

Declare the cross-sectional factor axis a CrossSectionalFactorPrior will produce, and its Factor Family groups, on a UniverseSets.

The method forwards pe.factors to the Pairs method of cross_sectional_factor_sets. A caller who writes a FactorSpace mandate against the estimator — in a Pipeline step, or a fold of a cross-validation — declares the universe from the estimator it will fit, so the one-hot level list is never hand-typed.

Arguments

  • pe: Cross-Sectional Factor Prior estimator.
  • rd: Returns data carrying the Asset Panel the one-hot levels are read from, and the asset names a new sets declares.
  • sets: A declared universe to widen. When it is nothing, a new one is built over rd.nx with the default key prefixes.

Validation

Returns

  • sets::UniverseSets: The declared universe, carrying the cross-sectional factor axis and one group per Factor Family.

Related

source