# portfolio-construction-optimization

> Build and rebalance portfolios with shrinkage covariance, HRP, risk parity, Black-Litterman and cost-aware rules.

portfolio-construction-optimization is a paid AI agent skill on Agensi by BanditXBT, in Finance & Accounting. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $29 (one-time purchase)
- Creator: [BanditXBT](https://www.agensi.io/creators/banditxbt)
- Category: [Finance & Accounting](https://www.agensi.io/skills/finance-accounting)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/portfolio-construction-optimization
- Tags: trading-investing, finance, research-analysis

## 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; attributes `covariance_`, `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: PyPortfolioOpt `HRPOpt` (default single linkage), Riskfolio-Lib `HCPortfolio` (default single), skfolio `HierarchicalRiskParity` (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 confidence `tau`. Pitfalls: Omega and tau choices dominate; a common convention (He-Litterman) sets Omega proportional to `P 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.

## Requires

- Python 3
- numpy
- scikit-learn
- Optional: PyPortfolioOpt
- Optional: Riskfolio-Lib
- Optional: skfolio

## Known limitations

Educational analysis, not investment advice. Heuristic thresholds (N/T, bands, caps) are not authoritative cutoffs.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the portfolio-construction-optimization skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does portfolio-construction-optimization do?

Build and rebalance portfolios with shrinkage covariance, HRP, risk parity, Black-Litterman and cost-aware rules.

### Which AI agents support portfolio-construction-optimization?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use portfolio-construction-optimization?

Connect your AI agent to Agensi through MCP, then ask it to use portfolio-construction-optimization on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
