- Home
- Skills
- Finance & Accounting
- portfolio-construction-optimization
Works with the AI Agents you already use
Portfolio Construction Optimization
by BanditXBT
Build and rebalance portfolios with shrinkage covariance, HRP, risk parity, Black-Litterman and cost-aware rules.
$29
About this skill
Optimizers amplify estimation error; test weight stability before trusting output. Educational analysis, not investment advice; state assumptions and data sources.
-
MVO is an error maximizer: it overweights assets with overestimated mu and underestimated risk. Weights are often corner solutions and swing with small input changes.
-
Expected returns are the weakest input (se of mean ~ sigma/sqrt(T); a 5-year sample cannot distinguish 5% from 10% annual mean for a 20% vol asset). Prefer approaches that need no mu (min-variance, risk parity, HRP) or that anchor mu to a prior (Black-Litterman).
-
Ill-conditioning: condition number of Sigma in the thousands or more (heuristic) signals unstable inverses. With N assets and T observations, the sample covariance is singular if N >= T, and eigenvalues are spread (Marchenko-Pastur) when N/T is not small. Check
N/T; as a heuristic, shrink or denoise when it is above ~0.2 (no authoritative cutoff). -
Test: bootstrap inputs; report weight dispersion and out-of-sample Sharpe vs 1/N (DeMiguel, Garlappi, Uppal 2009 found sample MVO often fails to beat it).
-
Ledoit-Wolf shrinkage:
Sigma_hat = (1-d) S + d * mu_I * I(scaled identity target, mu_I = trace(S)/N) with data-driven intensity d. Verified in scikit-learn docs:sklearn.covariance.LedoitWolf(centers data by default; attributescovariance_,shrinkage_);OAS(Oracle Approximating Shrinkage) is a sibling for small samples. Nonlinear shrinkage (Ledoit-Wolf, 2012/2020 papers; not in sklearn) is aimed at large N/T. -
Single-factor or constant-correlation targets suit a dominant common factor (crypto: BTC beta). Denoising/detoning (López de Prado): clip eigenvalues inside the Marchenko-Pastur bulk.
-
Use returns at a frequency matching the rebalance horizon; with asynchronous trading or illiquid tokens, high-frequency data can understate correlation (Epps effect, stale prices); use lagged/Dimson-type adjustments or lower-frequency data.
-
EWMA covariance (half-life e.g. 30-90 days, heuristic) adapts faster but is noisier; blend with a shrunk long-run estimate (regime-detection-volatility).
-
Min variance / max diversification: needs only Sigma; long-only and max-weight constraints act as implicit shrinkage.
-
Risk parity (equal risk contribution): solve
w_i (Sigma w)_i = w_j (Sigma w)_j. Needs leverage for a return target; fragile to correlation breakdown. Inverse-vol is the cheap variant. -
HRP (López de Prado, 2016, J. Portfolio Management): cluster on correlation distance
sqrt((1-rho)/2)(from the paper; not re-verified here), quasi-diagonalize, recursive bisection splitting capital inversely to cluster variance. No matrix inversion, so works with singular Sigma; ignores expected returns; sensitive to linkage and universe. Verified implementations: PyPortfolioOptHRPOpt(default single linkage), Riskfolio-LibHCPortfolio(default single), skfolioHierarchicalRiskParity(default Ward). Defaults differ, so state linkage. -
Black-Litterman (Black and Litterman, 1992, Financial Analysts Journal; earlier 1991 J. Fixed Income): prior = equilibrium returns
pi = delta Sigma w_mkt; posterior blends views(P, Q, Omega)with confidencetau. Pitfalls: Omega and tau choices dominate; a common convention (He-Litterman) sets Omega proportional toP Sigma P'; keep views few and test sensitivity. In crypto a market-cap prior is a proxy dominated by BTC/ETH. -
Resampled / robust optimization: bootstrap-averaged or uncertainty-set weights; more stable, less transparent.
-
Failure modes: leverage and margin on risk-parity weights, stale inputs after regime shifts, optimizing on in-sample factors also used for selection (double dipping), rebalancing into illiquid names.
-
Across strategies: use vol-scaled net returns; check duplicated factor bets (factor-exposure-attribution); sizing per bet in position-sizing-kelly.
Educational analysis, not investment advice. Heuristic thresholds (N/T, bands, caps) are not authoritative cutoffs.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Software
Python 3numpyscikit-learn
- Optional
- PyPortfolioOptRiskfolio-Libskfolio
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
New in Finance & Accounting
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Finance & Accounting.