risk-metrics-calculation

Calculate portfolio risk metrics including VaR, CVaR, drawdowns, and risk-adjusted ratios in Python.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/listentomi/Orcajack --skill risk-metrics-calculation-listentomi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: risk-metrics-calculation
Source: https://github.com/listentomi/Orcajack/tree/main/skills/finance/risk-metrics-calculation
Command: npx skills add https://github.com/listentomi/Orcajack --skill risk-metrics-calculation-listentomi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Quantifying portfolio risk requires implementing many statistical formulas correctly, from Value at Risk to drawdown analysis, and ad-hoc implementations often mishandle annualization, non-normal distributions, or portfolio-level aggregation. ## Core Features & Use Cases - Core Risk Metrics: Compute volatility, downside deviation, beta, historical/parametric/Cornish-Fisher VaR, CVaR, Sharpe, Sortino, Calmar, and Omega ratios from a returns series. - Portfolio-Level Risk: Calculate portfolio volatility, marginal and component risk contributions, risk parity weights, diversification ratio, and tracking error from asset returns and weights. - Rolling & Stress Analysis: Generate rolling volatility, Sharpe, VaR, and drawdown series, plus historical scenario stress tests (2008 crisis, COVID crash) and Monte Carlo stress simulations. - Use Case: A risk analyst needs a daily risk report for a multi-asset portfolio; they feed return series into RiskMetrics and PortfolioRisk to produce VaR, max drawdown, and per-asset risk contributions for a dashboard. ## Quick Start Ask the AI to calculate the Sharpe ratio, 95% VaR, and maximum drawdown for your portfolio's daily returns series using this risk metrics skill.

Frequently Asked Questions about risk-metrics-calculation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate VaR and CVaR for a portfolio in Python?▼

Create a RiskMetrics instance with a pandas Series of periodic returns, then call var_historical(confidence) for historical VaR and cvar(confidence) for expected shortfall. Parametric and Cornish-Fisher VaR variants are also available for different distribution assumptions.

How to compute risk parity weights for a multi-asset portfolio?▼

Use the PortfolioRisk class with a DataFrame of asset returns and call risk_parity_weights(). It minimizes the squared difference between each asset's risk contribution and an equal risk budget using scipy's SLSQP optimizer with weights constrained to sum to one.

What is the difference between Sharpe and Sortino ratio?▼

The Sharpe ratio divides excess return over the risk-free rate by total volatility, while the Sortino ratio divides it by downside deviation only. Sortino penalizes only harmful volatility below a threshold, making it preferable when return distributions are asymmetric.

Does historical VaR assume returns are normally distributed?▼

No, historical VaR uses empirical percentiles of the return series and makes no distribution assumption. The parametric VaR method assumes normality, while the Cornish-Fisher variant adjusts for skewness and kurtosis in the data.

Why is VaR alone not enough for tail risk measurement?▼

VaR gives only a loss threshold at a confidence level and says nothing about losses beyond it. CVaR (expected shortfall) averages losses in the tail, and stress testing against historical crises captures regime behavior that VaR misses.