liveBook · Manning

Infinity norm

As explained in Build a Robo-Advisor with Python (From Scratch)

The infinity norm of a vector is the maximum of the absolute values of its components.

The infinity norm of a vector is the maximum absolute value among its entries. For portfolio weights, it limits the magnitude of the largest position. section 10.2.2 section 10.3.2

Capping every portfolio position

The constraint cp.norm_inf(w) <= 0.5 ensures that every weight has magnitude at most 0.5. A 25% cap similarly prevents any asset from exceeding 0.25, helping reduce concentration. section 10.2.2 section 10.3.2

Listing 10.10 Maximum position size constraint
class GlobalMaxWeightConstraint(Constraint):
    def __init__(self, upper_bound: float):
        """ Constraint to enforce an upper bound on the magnitude of every
        asset in the portfolio

        :param upper_bound: Magnitude of every position will be constrained
          to be at most this value
        """
        self.upper_bound = upper_bound

    def generate_constraint(self, variables: Dict):
        return cp.norm_inf(variables['w']) <= self.upper_bound

Inspect the reusable GlobalMaxWeightConstraint implementation, which generates an infinity-norm bound for portfolio weights. section 10.3.2

Applying an infinity-norm position cap involves practical trade-offs:

  • Adding a 25% cap shifts weight from emerging-market equities into other equity classes and can move bond weights to zero. section 10.3.2
  • Combining the cap with a 5% volatility bound can make the feasible set empty, causing cvxpy to return NaN. section 10.3.2

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Defines the norm, implements it as a cvxpy constraint, and evaluates its effects alongside volatility limits.
Examples
Demonstrates uniform 50% and 25% caps, optimized ETF weights, and infeasibility under a tighter volatility bound.
What it assumes
Assumes portfolio weights and optimization constraints, while defining the infinity norm explicitly.
What you can do after
Apply it via cvxpy to cap portfolio positions and diagnose infeasible combinations of allocation constraints.
How it connects
Connects portfolio weights with diversification, portfolio optimization, volatility constraints, cvxpy, and feasible sets.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.