Agent skill

Portfolio Risk Metrics

by wshobson in wshobson/agents

Covers portfolio risk measurement with VaR, CVaR, Sharpe, Sortino and drawdown, plus guidance on limits, stress tests and tail risk.

MITAuto-check passedBusiness, Finance & HR

Install Portfolio Risk Metrics

skills CLI
$ npx skills add wshobson/agents --skill risk-metrics-calculation -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install wshobson/agents risk-metrics-calculation --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/wshobson/agents.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/quantitative-trading/skills/risk-metrics-calculation .claude/skills/risk-metrics-calculation && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
risk-metrics-calculation
GitHub stars
40k
Used in
12 other repos
Token cost
~502 tokens
SKILL.md length
168 words
Files
2 (incl. references)
Skills in repo
142
Repo updated
First seen
Licence
MIT

At a glance

Covers portfolio risk measurement with VaR, CVaR, Sharpe, Sortino and drawdown, plus guidance on limits, stress tests and tail risk.

  • Works in 2 steps: Risk Metric Categories → Time Horizons
  • Measuring the risk of an investment portfolio
  • SKILL.md covers When to Use This Skill, Core Concepts, Detailed patterns and worked… and Best Practices
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Risk is grouped into four metric families: volatility (standard deviation and beta), tail risk (VaR and CVaR), drawdown (maximum drawdown and Calmar) and risk-adjusted return (Sharpe and Sortino). The skill is a reference for choosing and calculating them for a portfolio, and lists use cases from setting risk limits and position sizes to dashboards and regulatory reporting.

It also lays out time horizons, from intraday VaR for day traders to daily reporting and weekly rebalancing decisions, and keeps its worked patterns in references/details.md for when the overview is not enough.

Its guidance favors using several metrics instead of one, treating CVaR as a complement to VaR because VaR understates tail risk, running rolling analysis and stress tests, and writing down assumptions such as the distribution and lookback. It warns against assuming normal returns, ignoring correlation in stress periods, using short lookbacks and forgetting transaction costs. It describes measurement methods, not investment advice.

When your agent uses it

  • Measuring the risk of an investment portfolio
  • Setting risk limits or position sizes with VaR and CVaR
  • Building a risk dashboard with drawdown and Sharpe or Sortino ratios
  • Preparing risk figures for regulatory reporting

Example prompts

  • “Calculate VaR and CVaR for the daily returns in portfolio_returns.csv and explain the difference.”
  • “Compute the Sharpe and Sortino ratios and the maximum drawdown for this equity curve.”
  • “Design a risk dashboard that tracks drawdown and tail risk over rolling windows.”

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Risk Metric Categories
  2. Time Horizons

What it can do on your machine

Read from SKILL.md and the folder at commit 46891e7. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Portfolio Risk Metrics loads about 502 tokens when it runs, and up to ~4.7k if it reads all its reference files. Until then it costs about 54 tokens; SKILL.md has 168 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~502
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from wshobson/agents at commit 46891e7, republished under its MIT licence (© wshobson). 168 words, ~502 tokens.

Download SKILL.mdSave it as .claude/skills/risk-metrics-calculation/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
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
CategoryMetricsUse Case
VolatilityStd Dev, BetaGeneral risk
Tail RiskVaR, CVaRExtreme losses
DrawdownMax DD, CalmarCapital preservation
Risk-AdjustedSharpe, SortinoPerformance
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

© wshobson, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in plugins/quantitative-trading/skills/risk-metrics-calculation of wshobson/agents.

  • SKILL.md
  • references/details.md

Open the folder on GitHubat commit 46891e7

Used in 12 other repositories

We found 23 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 12 other GitHub owners. This page covers the copy in wshobson/agents, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Portfolio Risk Metrics next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Portfolio Risk Metrics compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Portfolio Risk Metrics this skillwshobson/agents40k12 repos~502Automated safety check: PassMIT
Risk Measurement and Stress TestingHKUDS/Vibe-Trading35k—~3.8kAutomated safety check: PassMIT
Correlation and Cointegration AnalysisHKUDS/Vibe-Trading35k—~10kAutomated safety check: PassMIT
Correlation Regime DetectionHKUDS/Vibe-Trading35k—~5.4kAutomated safety check: PassMIT
Gplay Reports Downloadhanamizuki/solopreneur152—~2.2kAutomated safety check: PassMIT
Eastmoney Market DataHKUDS/Vibe-Trading35k—~1kAutomated safety check: PassMIT

Similar skills

  • Measures portfolio and backtest risk with VaR, CVaR, maximum drawdown, Monte Carlo simulation, tail modeling and stress tests, using one tested risk module.

    35k GitHub stars~3.8k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Finds co-moving assets and tests them for cointegration, with workflows for correlation studies, sector clustering, hedge ratios and pair-trading signals.

    35k GitHub stars~10k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Detects when markets fuse into one correlated bloc, adds regime context to risk, and attributes crises to first movers, as monitoring tools rather than trade signals.

    35k GitHub stars~5.4k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Gplay Reports Download

    hanamizuki/solopreneur

    Financial and statistics report listing and downloading from Google Play Console via GCS.

    152 GitHub stars~2.2k tokensUpdated 14 days ago
    Data & AnalyticsAuto-check passed
  • Eastmoney Market Data

    HKUDS/Vibe-Trading

    Index of Eastmoney's free, no-token market data interfaces for China A-shares and Hong Kong stocks: fund flows, dragon-tiger lists, margin trading, reports and news.

    35k GitHub stars~1k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • OKX Market Data

    HKUDS/Vibe-Trading

    Retrieves public OKX cryptocurrency market data such as spot prices, candlesticks, funding rates and open interest through the OKX V5 REST API, with no authentication.

    35k GitHub stars~1.3k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed

More from wshobson/agents

All 142 skills in this repo
  • Cuts cloud spend across AWS, Azure, GCP and OCI with cost tagging, rightsizing, commitment and spot pricing models, and architecture changes.

    40k GitHub starsUsed in 14 repos~1.7k tokens
    Auto-check passed
  • Billing Automation

    wshobson/agents

    Covers building subscription billing: billing cycles, subscription states, invoice generation, proration, tax handling and dunning for failed payments.

    40k GitHub starsUsed in 13 repos~473 tokens
    Auto-check passed
  • Profiles slow Python code with cProfile and memory profilers, then applies targeted fixes for CPU, memory, I/O and query bottlenecks.

    40k GitHub starsUsed in 13 repos~814 tokens
    Auto-check passed
  • Writes unit tests for shell scripts with Bats: error-condition tests, fixtures and mocks, cross-shell checks, parallel runs, helper files and CI integration.

    40k GitHub starsUsed in 12 repos~1.3k tokens
    Auto-check passed
  • Distributed Tracing

    wshobson/agents

    Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks.

    40k GitHub starsUsed in 12 repos~527 tokens
    Auto-check passed
  • Reference for designing and tuning production LLM prompts: few-shot examples, chain-of-thought, structured outputs, templates and system prompts.

    40k GitHub stars~1.3k tokensUpdated 6 days ago
    Auto-check passed

Questions about Portfolio Risk Metrics

What does Portfolio Risk Metrics do?

Covers portfolio risk measurement with VaR, CVaR, Sharpe, Sortino and drawdown, plus guidance on limits, stress tests and tail risk. Risk is grouped into four metric families: volatility (standard deviation and beta), tail risk (VaR and CVaR), drawdown (maximum drawdown and Calmar) and risk-adjusted return (Sharpe and Sortino). The skill is a reference for choosing and calculating them for a portfolio, and lists use cases from setting risk limits and position sizes to dashboards and regulatory reporting.

When should I use Portfolio Risk Metrics?

Portfolio Risk Metrics fits situations like: measuring the risk of an investment portfolio; setting risk limits or position sizes with VaR and CVaR; building a risk dashboard with drawdown and Sharpe or Sortino ratios; preparing risk figures for regulatory reporting.

How do I install Portfolio Risk Metrics in Claude Code?

Run `npx skills add wshobson/agents --skill risk-metrics-calculation -a claude-code`. Or copy the skill folder (plugins/quantitative-trading/skills/risk-metrics-calculation in wshobson/agents) into .claude/skills/risk-metrics-calculation in your project. Claude Code loads it when a task matches its description.

How do I install Portfolio Risk Metrics in Codex?

Run `npx skills add wshobson/agents --skill risk-metrics-calculation -a codex`. Or copy the skill folder (plugins/quantitative-trading/skills/risk-metrics-calculation in wshobson/agents) into .agents/skills/risk-metrics-calculation in your project. Codex loads it when a task matches its description.

Can I use Portfolio Risk Metrics in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add wshobson/agents --skill risk-metrics-calculation -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/risk-metrics-calculation, .gemini/skills/risk-metrics-calculation, .github/skills/risk-metrics-calculation and .opencode/skills/risk-metrics-calculation in your project.

What does Portfolio Risk Metrics need to run?

SKILL.md names no scripts, command-line tools or credentials: Portfolio Risk Metrics is instructions for the agent only.

Does Portfolio Risk Metrics access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Portfolio Risk Metrics safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Portfolio Risk Metrics use?

Portfolio Risk Metrics is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Portfolio Risk Metrics use?

About 502 tokens (SKILL.md is roughly 2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.2k tokens, read only when the agent opens those files.

What are the alternatives to Portfolio Risk Metrics?

Skills that share tags, products or a category with Portfolio Risk Metrics: Risk Measurement and Stress Testing (HKUDS/Vibe-Trading, 35k stars), Correlation and Cointegration Analysis (HKUDS/Vibe-Trading, 35k stars), Correlation Regime Detection (HKUDS/Vibe-Trading, 35k stars) and Gplay Reports Download (hanamizuki/solopreneur, 152 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Portfolio Risk Metrics?

wshobson (a GitHub user) maintains it in wshobson/agents, which has 40,314 GitHub stars. The repository holds 142 skills in this directory. The repository was last updated on October 5, 2026.

Source: wshobson/agents on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.