Step execution

PortfolioOptimisers.constraint_step_value — Function
constraint_step_value(
    ce::AbstractWeightBoundsEstimator,
    ctx::PipelineContext
) -> WeightBounds

Compute the value a constraint step contributes to the constraints slot.

One method per constraint family, each calling that family's constraint-generation verb. The value is paired with its routing target by run_step; this method decides only what is computed, never where it lands.

A family that reads the returns reads them from the source that its own reader states, as it does in the slot of an optimiser. The phylogeny and centrality families pass ctx.returns to their verb, which reads the x_src of the estimator. An exposure constraint refits through the regression of its FactorSpace, which states its own source. An estimator of weight bounds gets ctx.returns as rd, as it does in the wb field of an optimiser, so a ScoreWeightBounds scores the assets of the window of the step. A WeightBoundsEstimator ignores rd.

Arguments

  • ce: The constraint estimator.
  • ctx: The pipeline context.

Returns

  • The computed value, nothing, or a vector of either.

Related

source
constraint_step_value(
    ce::ExposureConstraintEstimator,
    ctx::PipelineContext
) -> Any

Compute an ExposureConstraintEstimator step's value: re-base its rows through the loadings of the pipeline's prior into an asset-space LinearConstraint.

This is the one constraint step that reads a computed slot other than :returns. The basis is ctx.prior.rr, so a prior step must come earlier; a prior that carries no regression makes constraint_space_basis throw, which is the intended failure — see ExposureConstraintEstimator.

ctx.returns is passed as well, so a space that names a regression estimator refits the loadings here rather than throwing. That is the one arrangement in which a prior carrying no factor block still admits a factor mandate — see FactorSpace. The refit reads the returns from the source that the regression of the space states, as it does in the lcse field of an optimiser.

Warning

The constraint is pinned to the pipeline's prior. Its rows were projected through the loadings this step saw, and a downstream optimiser that refits its own prior does not re-project them. Passing the estimator to the optimiser's lcse field instead recomputes the projection with the optimiser's own prior, per fold, which is what a cross-validated factor mandate needs.

Related

source