Weight Constraints
PortfolioOptimisers.w_neg_flag Function
w_neg_flag(_::Nothing) -> BoolReturn true when the weight bound wb contains at least one negative value, indicating a long-short strategy is required.
Arguments
wb: Weight bound. Acceptsnothing, a scalarNumber, or aVecNum.
Returns
flag::Bool:falsewhenwbisnothing;wb < 0whenwbis a scalar;any(x -> x < 0, wb)whenwbis a vector.
Related
sourcePortfolioOptimisers.w_finite_flag Function
w_finite_flag(_::Nothing) -> BoolReturn true when wb contains at least one finite value, meaning a bound constraint should be added to the model.
Arguments
wb: Weight bound. Acceptsnothing, a scalarNumber, or aVecNum.
Returns
flag::Bool:falsewhenwbisnothing;isfinite(wb)whenwbis a scalar;any(isfinite, wb)whenwbis a vector.
Related
sourcePortfolioOptimisers.set_weight_constraints! Function
set_weight_constraints!(args...)Add weight bound constraints to the JuMP optimisation model.
The fall-through method does nothing. The concrete method adds lower-bound and upper-bound constraints on the portfolio weight vector w, handles long-short decomposition when negative bounds are present via lw/sw variables, and delegates budget constraints to set_budget_constraints!.
Mathematical definition
Where:
: Portfolio weights vector . : Budget scaling / homogenisation variable. , : Lower and upper bound vectors from wb.
Arguments
model::JuMP.Model: The JuMP optimisation model.wb::WeightBounds: Weight bound specification containing lower and upper bounds.bgt: Optional total budget constraint (number orBudgetRange).sbgt: Optional short-side budget constraint.gbgt: Optional gross (leverage) budget constraint, applied only when the weight bounds admit shorts. Seeset_gross_budget_constraints!.long::Bool = false: Whentrue, raises an error if any bound is negative.
Note
The budgets set here bound the realised exposures rather than pinning them, because lw and sw are upper bounds on the parts of w. Pinning them is the xbgt option of short_mip_threshold_constraints, applied later by set_mip_constraints!.
Validation
- Raises an error when
long = trueand any bound is negative.
Returns
nothing.
Related
sourcePortfolioOptimisers.non_zero_real_or_vec Function
non_zero_real_or_vec(_::Nothing) -> BoolReturn true when x is non-zero.
Arguments
x: Value to check. Acceptsnothing, a scalarNumber, or aVecNum.
Returns
flag::Bool:falsewhenxisnothing;!iszero(x)for a scalar;any(!iszero, x)for a vector.
Related
sourcePortfolioOptimisers.set_linear_weight_constraints! Function
set_linear_weight_constraints!(args...)Add linear inequality and equality weight constraints to the JuMP optimisation model.
The fall-through method does nothing. The concrete method iterates over the collection of LinearConstraint objects lcms and adds A * w ≤ k * B (inequality) and A * w = k * B (equality) constraints for each entry.
Mathematical definition
Where:
: Portfolio weights vector . : Budget scaling / homogenisation variable. , : Constraint coefficient matrices for inequality and equality constraints. , : Constraint response vectors for inequality and equality constraints.
Arguments
model::JuMP.Model: The JuMP optimisation model.lcms: Collection ofLinearConstraintobjects defining the linear constraints.key_ineq::Symbol: Base key for naming inequality constraints in the model.key_eq::Symbol: Base key for naming equality constraints in the model.
Returns
nothing.
Related
source