Portfolio Analyzer
CautionAnalyze investment portfolios with performance attribution, risk metrics, correlation matrices, benchmark comparison, and rebalancing recommendations.
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
Claude
Freemium
Anthropic's AI assistant built for thoughtful analysis and safe, nuanced conversations
- 200K token context window for massive document processing
- Artifacts — interactive side-panel for code, docs, and visualizations
- Projects with persistent context and custom instructions
Perplexity
Freemium
AI-powered search engine that answers questions with cited sources
- Real-time web search with inline source citations
- Pro Search multi-step deep research automation
- Multiple model options (Sonar, GPT-4o, Claude)
Claude Code
Paid
Anthropic's agentic CLI for autonomous terminal-native coding workflows
- Terminal-native autonomous coding agent
- Full file system and shell access for multi-step tasks
- Deep codebase understanding via repository indexing
Related Skills
Stay Updated on Agent Skills
Get weekly curated skills + safety alerts
每周精选 Skills + 安全预警