Professional risk managers monitor dozens of metrics across their portfolios every day. Most individual investors check their brokerage app and hope for the best. This series closes that gap โ five automation pipelines that give you institutional-quality portfolio intelligence using mostly free data sources. Daily P&L, volatility alerts, correlation drift, VaR, Sharpe ratio, and rebalancing triggers โ all automated, all running while you're not watching.
Data Sources
| Source | What it provides | Cost |
|---|---|---|
| yfinance | Daily and historical price data | Free |
| FRED API | Risk-free rate for Sharpe ratio | Free |
| Alpaca Markets | Real-time quotes, paper trading | Free tier |
| Alpha Vantage | Historical OHLCV backup | Free (25 req/day) |
| positions.yaml | Your portfolio configuration | Free โ you maintain it |
What You'll Build
๐ Part 1: Portfolio Tracker
Load positions from a YAML file. Fetch daily prices. Calculate P&L, cost basis, unrealized gains, and daily moves. Get automated end-of-day briefs.
๐ Part 2: Volatility & Drawdown
Rolling volatility (20-day and 60-day). Current and max drawdown. VIX as a macro risk gauge. Know when your portfolio is under stress.
๐ Part 3: Correlation & Concentration
Correlation matrix between positions. Sector concentration via HHI score. Portfolio beta vs SPY. Identify hidden concentration and correlation drift.
๐งฎ Part 4: Risk Metrics Dashboard
Historical and parametric Value-at-Risk (95% and 99% confidence). Sharpe ratio and Sortino ratio using FRED's risk-free rate. Portfolio beta.
โ๏ธ Part 5: Rebalancing & Alerts
Drift detection when allocations exceed target by threshold. Stop-loss monitoring. Tax-loss harvesting candidates with wash-sale warnings.
Honest Framing
These are mathematical models. VaR does not predict losses โ it estimates probability distributions based on historical data. Sharpe ratio is backward-looking. Correlation breaks down in crises. Use these as systematic inputs to your process, not as certainties. When markets move beyond historical patterns, these metrics can be dangerously misleading.