Modeling portfolio risk decomposition is an AI agent skill from the GitHub repository CaseMark/skills. Decomposes portfolio risk with factor attribution, idiosyncratic risk, and marginal contribution to risk analysis. Use when decomposing portfolio risk, attributing risk sources, or analyzing factor risk contribution.
Computing marginal contribution to risk (MCTR) and component contribution to risk (CCTR) for position-level decisions
Evaluating whether portfolio risk budget aligns with intended factor tilts
Preparing risk reports for investment committees, risk oversight, or investor communications
Stress-testing factor exposure drift after rebalancing or new allocations
Inputs To Gather
Position-level holdings: Weights (w_i) for each security or asset in the portfolio
Factor exposure matrix (B): Security-level loadings on each factor (from regression, fundamental model, or vendor such as Barra/Axioma/Northfield)
Factor covariance matrix (F): Covariance among systematic factors over the chosen estimation window
Idiosyncratic variance matrix (D): Diagonal matrix of security-specific residual variances
Return series (if estimating from scratch): Daily or monthly total returns for holdings and candidate factor proxies
Benchmark (optional): Benchmark weights for active risk decomposition
Lookback window and frequency: e.g., 252 trading days daily, 60 months monthly — confirm consistency with factor model vintage [VERIFY]
Workflow
Assemble the covariance structure
Total portfolio covariance: V = B F Bᵀ + D
Confirm dimensions match (n securities × k factors)
If using a vendor model, verify the factor covariance vintage date matches the holdings date [VERIFY]
Compute total portfolio variance
σ²_p = wᵀ V w
Report as annualized volatility: σ_p = √(σ²_p × annualization scalar)
Typical annualization: ×252 for daily, ×12 for monthly returns
Decompose into systematic and idiosyncratic
Systematic variance: σ²_sys = wᵀ (B F Bᵀ) w
Idiosyncratic variance: σ²_idio = wᵀ D w
Report the ratio σ²_sys / σ²_p — well-diversified equity portfolios typically show 85–95% systematic; significantly lower values signal concentrated idiosyncratic bets
Active risk panel (if applicable): Tracking error, factor-active vs. stock-specific-active decomposition
Stress scenario results: Portfolio impact under specified factor shocks and regime covariance matrices
Reconciliation checks: Confirm variance decomposition sums match total; flag discrepancies >0.1%
Quality Checks
Factor contributions sum to systematic variance within rounding tolerance
CCTR values sum to total portfolio volatility (Euler identity holds)
No negative idiosyncratic variances (indicates data or model error)
Lookback window is consistent across factor model, covariance estimation, and holdings snapshot [VERIFY]
Factor model covers ≥90% of portfolio NAV by weight; flag uncovered positions and their assumed treatment (benchmark proxy, peer mapping, or exclusion)
Cross-check volatility estimate against realized rolling volatility — deviations >30% warrant investigation
If using third-party risk model, confirm model version and release date match intended analysis period [VERIFY]
Use this skill with your AI agent:Open on Skill Issue to copy, download, or add to your library.
Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.