Portfolio optimization and US macro analysis tool powered by Claude. Provide your holdings, get optimized allocation recommendations grounded in current economic conditions.
- Parses your portfolio from CSV (E-Trade, Schwab, or generic format), Excel, or plain text
- Downloads historical price data via Yahoo Finance
- Calculates optimal allocation using 3 expected return methods (CAPM, Mean Historical, EMA) with Ledoit-Wolf covariance shrinkage
- Fetches key US economic indicators from FRED (interest rates, unemployment, inflation, GDP, corporate profits, S&P 500)
- Validates all outputs with Pydantic schemas
- Generates 6 charts and a markdown report with rebalancing recommendations and macro-portfolio synthesis
- Python 3.10+
- Claude Desktop (Cowork mode) or Claude Code
npx add-skill sk2977/PortfolioAnalysis-Public --skill portfolio-analysisThen install Python dependencies:
pip install -r .claude/skills/portfolio-analysis/scripts/requirements.txtgit clone https://github.com/sk2977/PortfolioAnalysis-Public.git
cd PortfolioAnalysis-Public
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
pip install -r requirements.txt- Open Claude Desktop and switch to the Cowork tab
- Select "Work in a folder" and choose the project directory
- Upload your CSV/XLSX file or describe your holdings in plain text
- Type: "Run portfolio analysis" and Claude handles the rest
- Run
claudefrom the project directory - Tell Claude about your portfolio (file path, or describe in text)
- Claude walks you through configuration and runs the full pipeline
Use the sample portfolio:
"Run portfolio analysis using the sample portfolio"
Provide your own CSV:
"Analyze my portfolio from my_holdings.csv"
Describe holdings in plain text:
"Analyze my portfolio: 40% VTI, 25% QQQ, 15% BND, 10% SCHD, 10% VYM"
The simplest format:
Symbol,Shares,Price
AAPL,50,175.00
MSFT,30,380.00
VTI,100,220.00E-Trade and Schwab CSV/Excel exports are also auto-detected.
The portfolio-analysis skill orchestrates a 7-phase pipeline:
- Portfolio Input -- Parses holdings from CSV, Excel, or text. Auto-detects broker format.
- Configuration -- Asks 6 questions one at a time: risk tolerance, max/min allocation, guaranteed tickers, benchmark, exclusions. (Or runs with moderate defaults in auto-run mode.)
- Data Download -- Fetches historical prices from Yahoo Finance with local pickle caching (4-hour TTL).
- Analysis -- Runs macro analysis (8 FRED indicators) and mean-variance optimization (3 return methods weighted 34/33/33).
- Validation -- Pydantic schemas normalize numpy/pandas types and catch structural issues.
- Visualization -- Generates 6 charts: allocation comparison, efficient frontiers (4-panel), correlation matrix, price history, and two macro dashboards.
- Narrative & Report -- Claude generates qualitative commentary (macro interpretation, holding-level analysis, macro-portfolio synthesis, confidence warnings), then assembles a markdown report.
No API keys required -- Claude provides the AI layer directly.
PortfolioAnalysis-Public/
├── CLAUDE.md # Points Claude to the skill
├── README.md # This file
├── requirements.txt # Python dependencies
├── .claude/
│ └── skills/
│ └── portfolio-analysis/ # The skill (source of truth)
│ ├── SKILL.md # Full workflow instructions
│ ├── scripts/ # All Python source code
│ ├── assets/ # Sample portfolio CSV
│ ├── evals/ # Skill evaluation definitions
│ └── references/ # Narrative generation guide
├── scripts/ # Import proxy for tests
├── tests/ # Test suite (pytest)
├── data_cache/ # (gitignored) Pickle cache for API data
└── output/ # (gitignored) Generated reports and charts
pip install pytest
python -m pytest tests/ -vThis tool is for educational and informational purposes only. It does not constitute financial advice. Past performance does not guarantee future results. Always consult a qualified financial advisor before making investment decisions.
