QD1.04-e02 implements the global minimum-variance portfolio: w_gmv = Σ⁻¹1 / (1′Σ⁻¹1), four lines of numpy (Sinv = np.linalg.inv(Sigma), ones = np.ones(n), then the ratio). Run it on Bharat Family Office's matrix and you get Equity 9.32%, Debt 86.94%, Gold 9.73%, REIT −5.99%. AA1.01's own Worked Example 2 numbers, to the decimal. The function's hidden tests also verify the first-order condition AA1.01 insists on: at the true GMV point, Sigma @ w must be a constant vector (every asset's marginal contribution to variance is identical, or you could still trade one asset for another and reduce risk further), running it on the Bharat weights returns 31.54, 31.54, 31.54, 31.54 (%², to two decimals) in every entry, confirmed to machine precision. Hold onto the fact this proves: the GMV formula never references μ. Revise every asset's assumed return by any amount and the GMV weights do not move by a single basis point, the frontier's one genuinely stable landmark, and the reason QD1.04-e08 has to attack GMV's stability from a completely different angle (the covariance estimate itself, not the return assumption) to demonstrate that even Σ-only decisions are not immune to naive-optimizer blow-up.
Advertisement
What is the tangency portfolio?
QD1.04-e03 implements the unconstrained tangency (maximum-Sharpe) portfolio: w_tan ∝ Σ⁻¹(μ − Rf·1), renormalized to sum to 1. On Bharat's menu at Rf = 4.5%, this reproduces AA1.01 Worked Example 3's Equity 24.51%, Debt 70.60%, Gold 12.26%, REIT −7.37%, Sharpe 0.578. Unlike GMV, this portfolio depends directly on μ, and μ, per AA1.01 section 9, is by a wide margin the least reliable input in the whole exercise. That dependency is exactly where QD1.04-e05's demonstration lives.
{
"skill": "Drafting a mean-variance optimization scaffold (Sigma construction, GMV, tangency) quickly with an AI coding assistant",
"use": "Have a coding assistant draft the numpy linear algebra for build_covariance/gmv_weights/tangency_weights so your own time goes to verifying the output against a known case, not to debugging matrix-shape syntax from scratch.",
"tools": ["A coding-focused chat assistant or IDE copilot (Claude, GitHub Copilot, Cursor)", "This module's own code pack, run locally, as your ground truth"],
"prompt": "Write three Python functions using numpy: build_covariance(sigma, corr) returning Sigma[i][j] = sigma[i]*sigma[j]*corr[i][j]; gmv_weights(Sigma) returning the closed-form global-minimum-variance weights; tangency_weights(Sigma, mu, rf) returning the closed-form maximum-Sharpe weights, renormalized to sum to 1. Include an assertion that Sigma @ w_gmv is a constant vector.",
"verify": "Never trust the assistant's matrix algebra unchecked (Guardrail #3 Recompute) -- run the result against AA1.01's own hand-verified Bharat Family Office numbers (GMV: [9.32%, 86.94%, 9.73%, -5.99%]; tangency: [24.51%, 70.60%, 12.26%, -7.37%]) before you trust a single downstream computation. A silently transposed matrix, a forgotten renormalization, or Sigma^-1 applied to the wrong vector all produce a plausible-looking but wrong weight vector -- exactly QD1.04-e04's choose-impl distractors.",
"diy": "You must already be able to state the GMV and tangency closed forms from AA1.01 Sec 4-5 before delegating the numpy syntax to a tool -- otherwise you cannot tell a correct scaffold from a subtly broken one.",
"market": "IN"
}