home / skills / xfstudio / skills / risk-metrics-calculation

risk-metrics-calculation skill

/risk-metrics-calculation

This skill helps you calculate portfolio risk metrics such as VaR, CVaR, Sharpe, and drawdown analysis for robust risk monitoring.

npx playbooks add skill xfstudio/skills --skill risk-metrics-calculation

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.1 KB
---
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.

## Use this skill when

- Measuring portfolio risk
- Implementing risk limits
- Building risk dashboards
- Calculating risk-adjusted returns
- Setting position sizes
- Regulatory reporting

## Do not use this skill when

- The task is unrelated to risk metrics calculation
- You need a different domain or tool outside this scope

## Instructions

- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open `resources/implementation-playbook.md`.

## Resources

- `resources/implementation-playbook.md` for detailed patterns and examples.

Overview

This skill calculates portfolio risk metrics including Value at Risk (VaR), Conditional VaR (CVaR / Expected Shortfall), Sharpe and Sortino ratios, and drawdown analysis. It is designed to quickly produce risk summaries and inputs for limits, sizing, and monitoring systems. Results are numeric and framed for integration into reporting or automated risk checks.

How this skill works

The skill ingests time series of portfolio returns or asset-level P&L and computes statistical risk measures using historical and parametric methods. It estimates VaR at configurable confidence levels, computes CVaR as the tail average, derives Sharpe and Sortino risk-adjusted returns, and identifies peak-to-trough drawdowns and recovery periods. Outputs include point estimates, confidence parameters, and time-indexed drawdown series for visualization or alerting.

When to use it

  • Measuring portfolio downside risk before position sizing or allocation changes
  • Implementing or validating risk limits and margin triggers
  • Building risk dashboards or automated monitoring pipelines
  • Preparing risk inputs for regulatory or internal reporting
  • Comparing risk-adjusted performance across strategies

Best practices

  • Clarify return frequency (daily, weekly) and align confidence intervals before calculation
  • Use both historical and parametric VaR to cross-check model assumptions
  • Bootstrap or Monte Carlo for small samples or non-normal return distributions
  • Report CVaR alongside VaR to capture tail exposure
  • Include realized drawdown durations and recovery dates in governance reports

Example use cases

  • Compute 1% and 5% VaR and CVaR for a daily-return portfolio to set intraday limits
  • Generate Sharpe and Sortino ratios over rolling windows to compare strategy skill
  • Produce a drawdown table with peak, trough, depth, and days to recovery for monthly board reporting
  • Integrate VaR triggers into an automated position-sizing workflow
  • Validate risk model outputs by comparing historical stress period VaR against realized losses

FAQ

What inputs are required?

Time series of portfolio returns or P&L, frequency of returns, chosen confidence levels, and optional volatility or factor model parameters.

Which VaR method should I pick?

Use historical VaR for empirical assessment, parametric VaR for speed and when returns are near-normal, and simulation for non-linear or path-dependent exposures.