risk-metrics-calculation

Calculate portfolio risk metrics including VaR, CVaR, drawdowns, and risk-adjusted returns.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill risk-metrics-calculation-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: risk-metrics-calculation
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/risk-metrics-calculation
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill risk-metrics-calculation-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, scipy.

What problem does it solve? Quantifying portfolio risk requires implementing many statistical formulas correctly, from Value at Risk to drawdown analysis, and errors in these calculations lead to bad position sizing and regulatory issues. This Skill provides tested Python implementations of the full risk measurement toolkit. ## Core Features & Use Cases - Core Risk Metrics: Compute volatility, beta, historical and parametric VaR, Cornish-Fisher VaR, CVaR, Sharpe, Sortino, Calmar, and Omega ratios from a return series. - Portfolio-Level Risk: Calculate portfolio volatility, marginal and component risk contributions, risk parity weights, and diversification ratios across multiple assets. - Rolling & Stress Analysis: Track rolling volatility, Sharpe, VaR, and drawdowns over time, plus run historical crisis scenarios and Monte Carlo stress tests. - Use Case: A portfolio manager needs a daily risk dashboard. Feed daily returns into the RiskMetrics class, call summary() to get VaR, max drawdown, and Sharpe ratio, then run StressTester against the 2008 financial crisis scenario to check tail exposure. ## Quick Start Ask the AI to calculate VaR, CVaR, Sharpe ratio, and maximum drawdown for your portfolio return series using the risk metrics patterns.

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 Value at Risk (VaR) in Python?

Calculate VaR in Python using historical, parametric, or Cornish-Fisher methods on a return series. Historical VaR takes the percentile of past returns, parametric VaR assumes a normal distribution with scipy stats, and Cornish-Fisher adjusts for skewness and kurtosis.

What is the difference between VaR and CVaR?

VaR gives the loss threshold at a confidence level, while CVaR (Expected Shortfall) averages all losses beyond that threshold. CVaR better captures tail risk, so use both together rather than relying on VaR alone.

How do I calculate maximum drawdown from returns?

Compute the cumulative product of returns, track the running maximum, and measure the percentage decline from each peak. The minimum of that drawdown series is the maximum drawdown, and you can also derive drawdown duration statistics.

Does this work with multi-asset portfolio returns?

Yes, the PortfolioRisk class accepts a DataFrame of asset returns and weights to compute portfolio volatility, marginal and component risk contributions, correlation matrices, and risk parity weights via scipy optimization.

What are the limitations of parametric VaR?

Parametric VaR assumes normally distributed returns, but real returns are fat-tailed, so it underestimates extreme losses. Use Cornish-Fisher expansion or historical VaR with CVaR, and run stress tests for crisis scenarios.