Factor risk contribution: private API

PortfolioOptimisers.factor_risk_contribution_td_defaults — Function
factor_risk_contribution_td_defaults(

) -> @NamedTuple{re::StepwiseRegression{PValue{Float64}, ForwardSelection, LinearModel{@NamedTuple{}}, BatchChoice, Nothing, Nothing}, r::Variance{RiskMeasureSettings{Float64, Nothing, Bool}, Nothing, Nothing, Nothing, SquaredSOCRiskExpr, EigenFallbackSquareRoot, SquareRootRatio, Nothing}, obj::MinimumRisk}

Return the static defaults of the FactorRiskContribution fields that can hold a TimeDependent.

The constructor reads them to check each schedule, and time_dependent_field_defaults returns them, so the value of a field outside a fold is written once. A field whose static default is nothing is not in the tuple.

Related

source
PortfolioOptimisers.set_factor_risk_contribution_constraints! — Method
set_factor_risk_contribution_constraints!(model, re, rd, pr, flag, wi; hedge = false)

Create the factor weights of a model, and register the asset weights w as their image in the asset basis.

The # Mathematical definition of FactorRiskContribution states the two forms of the map, which flag selects.

When flag and hedge are both true, the rows $\mathbf{B}_2^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{0}$ fix the off-factor weights at the minimum-variance hedge of the factor exposures $\boldsymbol{w}_1$. They are the first-order condition of $\boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w}$ in $\boldsymbol{w}_2$. So the off-factor weights take no risk contribution under the variance, and $\boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{w}_1^\intercal (\mathbf{B}^\intercal \mathbf{\Sigma}^{-1} \mathbf{B})^{-1} \boldsymbol{w}_1$. The weights then lie in a subspace of dimension $N_f$, so a bound that the free off-factor weights meet can make the model infeasible.

resolve_factor_regression picks the loadings, in the order that the value-level factor_risk_contribution uses: a precomputed Regression in re, then the rr of the prior, then a fit on rd. The prior comes before the fit, so the basis of the decision variable is the basis through which the prior projected its moments.

Warning

A prior that carries loadings comes before a regression estimator in re. To replace the loadings of a factor prior, pass them as a precomputed Regression in re.

Algorithm

  1. Pick the loadings rr with resolve_factor_regression.
  2. Form Bt, the transpose of the loadings, and b1, the pseudoinverse of Bt. Nf is the number of columns of b1.
  3. When flag is true, form b2 from an orthonormal basis of the null space of Bt, create w1 and w2, and register w. When hedge is also true, add the hedge rows.
  4. When flag is false, set b2 = nothing, create w1, and register w.
  5. Set the start values of w1 from wi with set_initial_w!.

JuMP formulation

Variables

  • w1: Created, $N_f$ entries.
  • w2: Created when flag = true, one entry for each column of $\mathbf{B}_2$.

Expressions

  • w: $\mathbf{B}_1 \boldsymbol{w}_1$, or $\mathbf{B}_1 \boldsymbol{w}_1 + \mathbf{B}_2 \boldsymbol{w}_2$ when flag = true.

Constraints

  • cfrb_hedge: $s_c \mathbf{B}_2^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{0}$, when flag = true and hedge = true.

Where:

  • $\boldsymbol{w}_1$: Factor weights of FactorRiskContribution, one entry for each of the $N_f$ factors. The asset weights are $\mathbf{B}_1 \boldsymbol{w}_1$, with $\mathbf{B}_1$ the pseudoinverse of $\mathbf{B}^\intercal$, plus an off-factor block when flag = true.
  • $\boldsymbol{w}_2$: Off-factor weights, one entry for each direction of the null space of $\mathbf{B}^\intercal$. There are $N - N_f$ of them when $\mathbf{B}$ has full column rank.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\mathbf{B}_1$: The factor basis, $(\mathbf{B}^\intercal)^{+}$.
  • $\mathbf{B}_2$: The off-factor basis, an orthonormal basis of the null space of $\mathbf{B}^\intercal$, $N \times (N - \operatorname{rank}\mathbf{B})$.
  • $\mathbf{B}$: Loading matrix, of size $N \times N_{f}$.
  • $\mathbf{\Sigma}$: The covariance matrix of the prior, pr.sigma.
  • $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.

Arguments

  • model: JuMP model.
  • re: Regression result or estimator (RegE_Reg).
  • rd: Returns result that carries X and F. The method reads it only to fit the loadings.
  • pr: Prior result. The method reads its loadings, and sigma for the hedge rows.
  • flag: true adds the off-factor weights.
  • wi: Start values of the factor weights, or nothing.
  • hedge: true adds the hedge rows. The method reads it only when flag is true, and then pr must carry sigma.

Returns

  • b1, b2, rr: The factor basis, the off-factor basis, and the loadings of both. b2 is nothing when flag is false.

Related

source