The Analyst's Path

Mean-variance optimization with constraints

Mean-variance optimization with constraints is the same search for the lowest-variance portfolio, with limits on the weights such as no shorting or a cap on illiquid assets. Once a bound is added there is no closed form, so a numerical solver does the work. Analysts use it to price each limit: a constrained portfolio can only match or fall short of the unconstrained Sharpe ratio, and the gap is the price of the constraint.

5 min readPart of MVO, the Efficient Frontier, SAA vs TAAOpen in course mode

Advertisement

No real mandate lets you run the unconstrained solution above. Regulation, mandate language, and plain common sense forbid most institutional pools from shorting a domestic REIT sleeve to fund a bigger debt position; illiquid buckets (private markets, real assets) routinely carry a policy cap for liquidity reasons regardless of what the unconstrained math wants. The instant you add a bound like 0 ≤ w_i ≤ cap, the elegant closed form is gone and you are solving a numerical quadratic program, precisely the scipy.optimize.minimize call in the mean-variance optimization callout.

What does a portfolio constraint cost?

One structural fact is worth stating and then verifying: a constrained frontier can only match or lie inside the unconstrained one. Constraints can never improve the best achievable Sharpe ratio; they can only cost you some of it, because the unconstrained solution was already the best the covariance and return assumptions could produce. Running Bharat Family Office's tangency portfolio under increasingly realistic constraints traces exactly this:

Advertisement

ConstraintEquityDebtGoldREITSharpevs. unconstrained
None (short allowed)24.51%70.60%12.26%−7.37%0.578:
Long-only (w ≥ 0)21.60%66.11%12.29%0.00%0.571−1.2%
Long-only + 50% single-asset cap29.37%50.00% (binding)20.63%0.00%0.5535−4.2%

Each row is a strictly more realistic (and more restrictive) mandate, and each costs a little more Sharpe ratio, a real, quantified price of the constraint, not a hand-wave. The third row's 50% cap binds exactly on Debt (the unconstrained optimum "wanted" 70.60% there); capping it forces the freed-up weight into Equity and Gold instead, and the portfolio gives up 4.2% of its unconstrained Sharpe ratio for the privilege of being a mandate a trustee would actually approve. This exact pattern recurs for Northfield Endowment with a different, more realistic constraint: an illiquidity cap of 20% on the Alts sleeve (a common institutional liquidity-policy bound, since Alts cannot be sold to meet a spending call the way public equity can). The unconstrained tangency wants 30.72% in Alts; capped at 20%, the portfolio reallocates to Equity (28.36%) and Bonds (51.64%), and the Sharpe ratio falls from 0.317 to 0.3132, a much smaller relative cost (1.2%) than Bharat's Debt cap, because Alts here was doing comparatively less of the unconstrained portfolio's diversification work than Debt was doing in the Indian case. The lesson generalizes: the Sharpe cost of a constraint tells you how much diversification value that specific sleeve was providing, a genuinely useful diagnostic for deciding which policy constraints are expensive and which are nearly free. QD1.04 builds the production version of this exact solve with real-world constraint sets (turnover budgets, sector limits, ESG screens); this node's job is that you understand what the solver is doing and can price a constraint's cost yourself before trusting a vendor's black box to do it for you.

{
  "skill": "Drafting and stress-testing a capital-market-assumptions (CMA) table with AI, without letting the tool become the source",
  "use": "Have a chat assistant propose a starter CMA table (expected returns, volatilities, correlations) for a stated asset menu, flag which correlations are most regime-unstable, and suggest a plausible published anchor for each figure — then you verify every number against the cited primary source and confirm the resulting correlation matrix is valid before computing anything from it.",
  "tools": ["Chat assistants — Claude, ChatGPT, Gemini", "A code-execution-enabled assistant that can actually run the eigenvalue/PSD check for you and show the result"],
  "prompt": "I'm building a capital-market-assumptions table for <ASSET MENU> in <India/US>. For each asset, propose an expected return, a volatility, and pairwise correlations with the others. For every figure, name a specific, checkable published source (an index factsheet, an asset manager's published long-term CMA set, a central-bank data series) rather than stating a number with no anchor. Then tell me which correlation you are least confident in and why.",
  "verify": "Trace every proposed figure to the named primary source before it enters your build (Guardrail #1 Trace, #2 Match on period/currency/scale); never accept the assistant's own arithmetic (Guardrail #3 Recompute) — run the frontier, the GMV, and the tangency portfolio yourself in Python and confirm the correlation matrix passes numpy.linalg.eigvalsh before trusting a single downstream number. An AI-fabricated 'these assets correlate at 0.4' looks identical to a correctly sourced one until you check it.",
  "diy": "You must already be able to build Sigma from (sigma, rho) by hand, solve for the GMV and tangency weights, and read whether a result is economically sensible (this node's §3-5) — the assistant only accelerates finding candidate anchors and drafting the starting table; it never owns whether the final assumptions are defensible.",
  "market": "IN"
}

Advertisement

Part of the course

This page is part of MVO, the Efficient Frontier, SAA vs TAA (AA1.01), in Phase 12: Finance Plus, AI and the quant-code track. The module's flashcards and its quiz are in the app.