risk-metrics-calculation
- Use it when:
- You're measuring portfolio risk, setting risk limits, or building a risk dashboard.
- It does:
- Defines each metric and when to use it, then its reference file implements them in Python with pandas and NumPy.
- You get:
- Risk code along these patterns; it adds no steps or files of its own.
- Covers:
- Volatility, beta, VaR (historical, parametric, Cornish-Fisher), CVaR, drawdowns, Sharpe/Sortino/Calmar/Omega, and historical, hypothetical and Monte Carlo stress tests.
TL;DR
A reference for portfolio risk measurement, not a workflow. The SKILL.md groups metrics into volatility, tail risk, drawdown and risk-adjusted categories and sets out do's and don'ts: use several metrics, don't lean on VaR alone, assume fat tails rather than normality, watch correlation in stress, and use long lookbacks. A reference file holds the Python: a RiskMetrics class (volatility, downside deviation, beta, three VaR methods, CVaR, drawdown series and durations, Sharpe, Sortino, Calmar, Omega, information ratio and a summary), a PortfolioRisk class (portfolio volatility, marginal and component risk contributions, risk-parity weights, diversification ratio, tracking error), rolling versions over a window, and a StressTester with named historical crises (2008, 2020 COVID, 2022 rate hikes, dot-com, flash crash), hypothetical shocks and Monte Carlo at elevated volatility.
Summarizes the skill at 4bde316.
npx skills add https://github.com/wshobson/agents --skill risk-metrics-calculation skills.sh pageSource on GitHubAll skills from wshobson/agents
Fewer weekly downloads than 63% of skills
Weekly values
| Week to | Installs |
|---|---|
| Sep 21 | 198 |
| Sep 28 | 220 |
| Oct 5 | 294 |
| Oct 12 | 236 |
| Oct 19 | 196 |
| Oct 26 | 203 |
| Nov 2 | 188 |
| Nov 9 | 182 |
More downloads than 58% of skills
More stars than 76% of repos
Older than 82% of skills
| Category |
Research reproduction, financial data, charts and diagrams. |
|---|---|
| Type |
Knowledge and rules the agent applies while it works: best practices, design principles, API references. |
| Effect |
Adds no side effects of its own. It shapes how the agent thinks, writes or reviews. Guidelines and routers are always effect:none, even when the task they support edits code. |
| Needs |
Instructions only. Works in any agent that supports skills. |
| Publisher |
Everyone else. Unverified vendor claims default to community. |
| Topics | |
| Stack |
SKILL.md
From wshobson/agents at 4bde316. Checked daily, last changed Nov 6, 2026.
Frontmatter
name: risk-metrics-calculation
description: Calculate portfolio risk metrics including VaR, CVaR, Sharpe, Sortino, and drawdown analysis. Use when measuring portfolio risk, implementing risk limits, or building risk monitoring systems.Risk Metrics Calculation
Comprehensive risk measurement toolkit for portfolio management, including Value at Risk, Expected Shortfall, and drawdown analysis.
When to Use This Skill
- Measuring portfolio risk
- Implementing risk limits
- Building risk dashboards
- Calculating risk-adjusted returns
- Setting position sizes
- Regulatory reporting
Core Concepts
1. Risk Metric Categories
| Category | Metrics | Use Case |
|---|---|---|
| Volatility | Std Dev, Beta | General risk |
| Tail Risk | VaR, CVaR | Extreme losses |
| Drawdown | Max DD, Calmar | Capital preservation |
| Risk-Adjusted | Sharpe, Sortino | Performance |
2. Time Horizons
Intraday: Minute/hourly VaR for day traders
Daily: Standard risk reporting
Weekly: Rebalancing decisions
Monthly: Performance attribution
Annual: Strategic allocation
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
Do's
- Use multiple metrics - No single metric captures all risk
- Consider tail risk - VaR isn't enough, use CVaR
- Rolling analysis - Risk changes over time
- Stress test - Historical and hypothetical
- Document assumptions - Distribution, lookback, etc.
Don'ts
- Don't rely on VaR alone - Underestimates tail risk
- Don't assume normality - Returns are fat-tailed
- Don't ignore correlation - Increases in stress
- Don't use short lookbacks - Miss regime changes
- Don't forget transaction costs - Affects realized risk