Skip to content

Portfolio Analyzer

Caution

Analyze investment portfolios with performance attribution, risk metrics, correlation matrices, benchmark comparison, and rebalancing recommendations.

By community 4,500 v1.4.0 Updated 2026-03-08

Install

Claude Code

Copy the SKILL.md file to .claude/skills/portfolio-analyzer.md

About This Skill

Portfolio Analyzer generates quantitative analysis scripts for investment portfolios using Python with pandas, numpy, scipy, and matplotlib/plotly.

Performance Metrics

Calculates: total return, annualized return (CAGR), volatility (annualized std dev), Sharpe ratio, Sortino ratio, Calmar ratio, max drawdown with drawdown duration, and Value at Risk (VaR) at 95% and 99% confidence levels.

Benchmark Comparison

Downloads benchmark data (S&P 500, MSCI World, BTC) via yfinance. Computes: beta, alpha (Jensen's alpha), R-squared, tracking error, and information ratio against the chosen benchmark.

Correlation Analysis

Correlation and covariance matrices for multi-asset portfolios. Rolling 90-day correlation heatmaps to identify regime changes. Diversification ratio (portfolio volatility / weighted average volatility).

Monte Carlo Simulation

10,000-path geometric Brownian motion simulation with historical volatility and return inputs. Outputs: probability of reaching target value, 10th/50th/90th percentile paths, and worst-case scenario analysis.

Rebalancing

Drift detection from target allocations. Generates optimal trade list to restore targets with minimum transaction count, respecting lot sizes and tax-lot awareness (avoid selling appreciated positions unnecessarily).

Output

Matplotlib/Plotly charts, PDF summary report, and JSON metrics for programmatic consumption.

Use Cases

  • Computing Sharpe ratio, max drawdown, and beta against S&P 500 for a stock portfolio
  • Building correlation matrices to identify over-concentration in correlated assets
  • Running Monte Carlo simulations to estimate probability of retirement goal achievement
  • Generating rebalancing trade lists when allocations drift beyond tolerance bands

Pros & Cons

Pros

  • + Industry-standard risk metrics (Sharpe, Sortino, VaR) computed correctly
  • + Monte Carlo simulation quantifies uncertainty rather than assuming single outcome
  • + Rebalancing considers tax-lot implications, not just allocation drift
  • + yfinance integration provides free historical data for most assets

Cons

  • - Historical metrics are backward-looking and cannot predict future returns
  • - yfinance data may have gaps for less liquid or international securities

Related AI Tools

Related Skills

Stay Updated on Agent Skills

Get weekly curated skills + safety alerts

每周精选 Skills + 安全预警