Base cross-sectional factor Prior

The systematic repair rule of a CrossSectionalFactorPrior says which steps of its matrix processing run on the systematic block of the asset covariance before the prior adds the idiosyncratic block. The default nothing runs every step except the :pdm step, and SystematicRepair runs every step.

PortfolioOptimisers.AbstractSystematicRepair — Type
abstract type AbstractSystematicRepair <: AbstractAlgorithm

Abstract supertype for the Systematic Repair rule of a CrossSectionalFactorPrior, the rule that says whether the lift repairs the systematic block before it adds the idiosyncratic block.

cross_sectional_lift projects the factor covariance onto the investable assets. The result is the systematic block, whose rank is at most the number of factors. So the block is not positive definite when the investable assets outnumber the factors, and a repair under mp.pdm moves it by round-off alone. The lift then adds the idiosyncratic block and repairs the sum under the estimator that matrix_processing_posdef gives for mp, under every rule. The rule decides only which steps of mp run on the systematic block before the sum. nothing in the place of a rule is the default, and it does not repair the systematic block: it runs every step of mp except the :pdm step, as systematic_processing! states.

Interfaces

In order to implement a new concrete type that works seamlessly with the library, subtype AbstractSystematicRepair and implement the following method:

systematic_processing!

  • systematic_processing!(srep::MySystematicRepair, mp::AbstractMatrixProcessingEstimator, sigma::MatNum, X::MatNum, T::Real; kwargs...) -> MatNum: Processes the systematic block sigma in place under mp, and returns it. A denoising step reads the ratio of T to the number of columns of X.

Arguments

  • srep: The member of the family.
  • mp: The matrix processing estimator of the prior.
  • sigma: The systematic block, investable assets × investable assets.
  • X: The asset return scenarios of the investable assets, scenarios × investable assets.
  • T: The effective number of observations of the factor covariance that the block projects.
  • kwargs...: Additional keyword arguments passed to the steps of mp.

Returns

  • sigma::MatNum: The systematic block, modified in place.

Related

source

The carry rule of a CrossSectionalFactorPrior says whether the carry fold accepts a part whose step cost grows with the stream. FoldOrRefit, the default, and FoldOnly are its two members.

PortfolioOptimisers.AbstractCarryRule — Type
abstract type AbstractCarryRule <: AbstractAlgorithm

Abstract supertype for the Carry Rule of a CrossSectionalFactorPrior, the rule that says whether the carry fold accepts a part whose step cost grows with the stream.

The carry fold folds each part that has a fold of its own. It fits every other part again at each step, over every row that the part reads. That refit is exact, but its cost grows with the number of folded observations. Five kinds of part do that, as carry_growing_parts states: a factor with no finite look-back, a Return Forecast with no bounded fold, a ve that does not fold, a factor prior pe that does not fold, and the idiosyncratic correlation under th > 0 with a ce that does not fold. Every test reads the configuration alone, so the constructor of the prior applies the rule. A batch fit and the refit under Online ignore it.

Interfaces

A rule is a marker for dispatch, and it holds no data. In order to implement a new rule, subtype AbstractCarryRule and implement the following method:

assert_carry_rule

  • assert_carry_rule(carry::MyCarryRule, cfg) -> Nothing: Applies the rule to the configuration of the prior. The constructor of CrossSectionalFactorPrior calls it.

Arguments

  • carry: The concrete subtype instance.
  • cfg: The prior, or a NamedTuple of its fields factors, pe, ve, rfe, th, ce, choice and families.

Returns

  • nothing. The method raises an ArgumentError for a configuration that the rule refuses.

The carry fold runs the same step under every rule, so a rule that changes the step needs its own method of the step too.

Related

source

The leverage-one rule of a CrossSectionalFactorPrior says how the prior reads the residual of an asset that is the only member of its level at an observation, when it scales the idiosyncratic returns. MaskedLeverageOne, the default, reads it as a gap, and UnmaskedLeverageOne reads it as it stands.

PortfolioOptimisers.AbstractLeverageOneMask — Type
abstract type AbstractLeverageOneMask <: AbstractAlgorithm

Abstract supertype for the Leverage-One Mask rules of a CrossSectionalFactorPrior.

A Leverage-One Pair, which the h1 field of CrossSectionalRegression marks, has a residual that is zero by construction. A rule of this family states how the prior reads that residual when it standardises the idiosyncratic returns into the standardised residuals S of the scenarios and the residuals with no fill of the idiosyncratic correlation. The variance history vs of the prior does not change under either rule.

Interfaces

A rule is a marker for dispatch, and it holds no data. The prior holds it in its l1mask field. In order to implement a new rule, subtype AbstractLeverageOneMask and implement the following method:

leverage_one_residuals

  • leverage_one_residuals(l1mask::MyLeverageOneMask, h1::Option{<:AbstractMatrix{Bool}}, eps::MatNum) -> MatNum: The idiosyncratic returns that the prior standardises. The batch fit and the carry fold both call it before cross_sectional_standardised_residuals.

Arguments

  • l1mask: The concrete subtype instance.
  • h1: The leverage-one mask of CrossSectionalRegression, observations × assets, or nothing.
  • eps: Idiosyncratic returns, observations × assets.

Returns

  • eps::MatNum: The idiosyncratic returns that the prior standardises.

Related

source
PortfolioOptimisers.MaskedLeverageOne — Type
struct MaskedLeverageOne <: AbstractLeverageOneMask

Read the residual of a Leverage-One Pair as a gap in the standardised idiosyncratic returns.

This is the default Leverage-One Mask of a CrossSectionalFactorPrior. The residual of a marked pair is not an observation of its idiosyncratic return, so the prior writes NaN over it with leverage_one_nan before the standardisation. The scenarios then give the pair the average standardised return of its observation, and the idiosyncratic correlation leaves the pair out, as every other reader of a marked pair does. The rule does not depend on the history of the variance of the pair.

Related

source
PortfolioOptimisers.UnmaskedLeverageOne — Type
struct UnmaskedLeverageOne <: AbstractLeverageOneMask

Read the residual of a Leverage-One Pair as it stands.

The prior standardises the zero residual of a marked pair by its variance. Where the variance is positive, which happens when the asset had a sibling in its level before, the standardised return is zero, and the scenarios and the idiosyncratic correlation read it as data. Where the variance is zero, the ratio is not finite, and the pair takes the average standardised return of its observation. This is the form of the oracle that the library is measured against. It stays one keyword away.

Related

source
PortfolioOptimisers.leverage_one_residuals — Function
leverage_one_residuals(l1mask::MaskedLeverageOne, h1::Option{<:AbstractMatrix{Bool}},
                       eps::MatNum) -> MatNum
leverage_one_residuals(l1mask::UnmaskedLeverageOne, h1::Option{<:AbstractMatrix{Bool}},
                       eps::MatNum) -> MatNum

Return the idiosyncratic returns that a Cross-Sectional Factor Prior standardises, under its Leverage-One Mask.

Algorithm

The method that Julia selects is the algorithm.

  1. MaskedLeverageOne: return eps with NaN at every pair that h1 marks, through leverage_one_nan.
  2. UnmaskedLeverageOne: return eps.

Arguments

  • l1mask: The Leverage-One Mask of the prior.
  • h1: The leverage-one mask of CrossSectionalRegression, observations × assets, or nothing.
  • eps: Idiosyncratic returns, observations × assets.

Validation

Returns

  • eps::MatNum: The idiosyncratic returns that the prior standardises.

Related

source

Every other name of this topic is private. The private page documents them.