home / skills / xfstudio / skills / 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-calculationReview the files below or copy the command above to add this skill to your agents.
---
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.
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.
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.
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.