calculating-value-at-risk

Computes VaR using parametric, historical simulation, and Monte Carlo methods with backtesting validation. Use when calculating VaR, comparing risk methodologies, or backtesting risk models.

11 stars

Best use case

calculating-value-at-risk is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Computes VaR using parametric, historical simulation, and Monte Carlo methods with backtesting validation. Use when calculating VaR, comparing risk methodologies, or backtesting risk models.

Teams using calculating-value-at-risk should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/calculating-value-at-risk/SKILL.md --create-dirs "https://raw.githubusercontent.com/CaseMark/skills/main/skills/finance/calculating-value-at-risk/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/calculating-value-at-risk/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How calculating-value-at-risk Compares

Feature / Agentcalculating-value-at-riskStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Computes VaR using parametric, historical simulation, and Monte Carlo methods with backtesting validation. Use when calculating VaR, comparing risk methodologies, or backtesting risk models.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Calculating Value At Risk

## When To Use

- Computing portfolio VaR at specified confidence levels (typically 95% or 99%) and holding periods (1-day, 10-day)
- Comparing risk estimates across parametric (variance-covariance), historical simulation, and Monte Carlo approaches
- Backtesting an existing VaR model against realized P&L to assess model adequacy
- Supporting regulatory capital calculations under Basel framework internal models approach [VERIFY: Basel III/IV applicability for jurisdiction]
- Producing risk reports for portfolio managers, risk committees, or regulators

## Inputs To Gather

- **Portfolio composition**: Asset classes, positions, notional values, currency denominations
- **Market data**: Historical returns series (minimum 1 year for historical simulation; 3-5 years preferred), closing prices, FX rates, yield curves
- **Parameters**: Confidence level (e.g., 99% for regulatory, 95% for internal), holding period, lookback window length
- **Correlation/covariance data**: Correlation matrix or raw return series for parametric method; decay factor if using exponentially weighted moving average (EWMA)
- **Distribution assumptions**: Normal, Student-t, or empirical for parametric; number of simulations and random seed for Monte Carlo
- **Benchmark P&L**: Realized daily P&L series for backtesting (minimum 250 trading days)

## Workflow

### 1. Data Preparation
- Collect and align time series to consistent trading calendar (handle holidays, missing data)
- Compute log returns or arithmetic returns (state choice and rationale)
- Check for stale prices, outliers, and corporate actions; flag gaps with [VERIFY]
- Convert multi-currency positions to base currency using consistent FX rates

### 2. Methodology Selection
- **Parametric (Variance-Covariance)**: Best for linear portfolios (equities, FX). Compute portfolio variance as w'Σw. VaR = z_α × σ_p × √(holding period). Note: assumes normal returns — underestimates tail risk for fat-tailed distributions
- **Historical Simulation**: Rank historical portfolio P&L; VaR = the (1-α) percentile loss. No distributional assumption required. Sensitive to lookback window choice — shorter windows react faster to regime changes
- **Monte Carlo**: Fit stochastic model to risk factors, simulate N paths (10,000+ recommended), revalue portfolio on each path, extract percentile. Required for portfolios with options or path-dependent instruments. Specify random number generator and variance reduction technique (antithetic variates, importance sampling)

### 3. VaR Calculation
- Run selected method(s); compute VaR at each requested confidence level and holding period
- For 10-day VaR from 1-day: use square-root-of-time scaling only if returns are i.i.d. [VERIFY: whether autocorrelation or volatility clustering invalidates scaling rule]
- Calculate Component VaR and Marginal VaR to attribute risk to individual positions or asset classes
- If running multiple methods, present side-by-side comparison table

### 4. Backtesting
- Compare realized P&L breaches against VaR predictions over the test window
- **Kupiec POF test**: Binomial test on number of exceptions vs. expected count — report p-value
- **Christoffersen test**: Check for independence of exceptions (clustered breaches indicate model failure)
- Classify model in Basel traffic-light zones: Green (0-4 exceptions at 99%/250 days), Yellow (5-9), Red (10+) [VERIFY: current regulatory thresholds for applicable regime]
- Document exception dates and magnitudes; investigate any breach exceeding 2× VaR

### 5. Stress & Sensitivity Analysis
- Compute Conditional VaR (Expected Shortfall / CVaR) as the average loss beyond VaR threshold
- Run sensitivity on key parameters: vary lookback window (250, 500, 750 days), confidence level, and decay factor
- Report how VaR changes under stressed correlation assumptions (e.g., correlations → 1 in crisis)

## Output

Produce a **VaR Calculation Worksheet** containing:

- **Summary table**: VaR figures by method, confidence level, and holding period
- **Component VaR breakdown**: Top 10 risk contributors by position or asset class
- **Backtest results**: Exception count, Kupiec p-value, Christoffersen p-value, traffic-light classification
- **CVaR / Expected Shortfall**: For each method and confidence level
- **Sensitivity table**: VaR under alternative parameter choices
- **Assumptions log**: Every distributional, data, and modeling assumption stated explicitly
- **Methodology narrative**: Plain-language explanation of approach suitable for risk committee review

## Quality Checks

- VaR at 99% must exceed VaR at 95% for the same method and holding period — flag if violated
- Component VaR values should sum approximately to diversified portfolio VaR (exact for parametric; approximate for simulation methods)
- Monte Carlo VaR should converge as simulation count increases — run at 10K and 50K and confirm difference < 5%
- Backtest exception rate should fall within 2 standard deviations of expected rate — otherwise flag model inadequacy
- Confirm holding-period scaling is appropriate: if significant autocorrelation exists in returns, do not apply square-root-of-time rule without adjustment
- Cross-check: historical simulation VaR should be broadly consistent with parametric VaR for linear portfolios with near-normal returns; large divergence signals fat tails or non-linearity
- All market data sources and observation dates must be cited; any interpolated or proxy data marked [VERIFY]

Related Skills

managing-risk-management-healthcare

11
from CaseMark/skills

Structures healthcare risk management with incident investigation, claims analysis, and loss prevention strategies. Use when managing healthcare risk, investigating incidents, or developing loss prevention programs.

managing-risk-adjustment-coding

11
from CaseMark/skills

Captures HCC codes for risk adjustment with annual assessment and documentation requirements. Use when coding for risk adjustment, capturing HCC conditions, or managing RAF scores.

managing-high-risk-pregnancies

11
from CaseMark/skills

Guides management of preeclampsia, gestational diabetes, and other high-risk conditions with monitoring protocols. Use when managing high-risk pregnancies, monitoring preeclampsia, or managing GDM.

managing-critical-laboratory-values

11
from CaseMark/skills

Tracks critical value notification with documentation requirements and clinical correlation. Use when reporting critical lab values, verifying notification, or documenting critical result acknowledgment.

managing-cardiac-risk-preoperative

11
from CaseMark/skills

Applies ACC/AHA perioperative cardiac evaluation algorithm with functional capacity and risk indices. Use when performing cardiac preop evaluation, calculating RCRI, or assessing perioperative cardiac risk.

calculating-performance-status

11
from CaseMark/skills

Documents ECOG and Karnofsky performance status with treatment eligibility implications. Use when assessing performance status, documenting ECOG scores, or evaluating treatment candidacy.

calculating-emergency-risk-scores

11
from CaseMark/skills

Computes validated risk scores (HEART, PERC, Wells, Ottawa, CURB-65) from clinical data. Use when calculating clinical decision scores, risk-stratifying ED patients, or applying clinical prediction rules.

assessing-suicide-risk

11
from CaseMark/skills

Applies Columbia Suicide Severity Rating Scale and structured risk assessment frameworks. Use when assessing suicide risk, documenting safety evaluations, or creating safety plans.

risk-assessment

11
from CaseMark/skills

Generates structured legal risk assessment reports with categorized risks, 5x5 scoring matrices, and mitigation strategies. Use when preparing risk assessments, due diligence reports, transaction risk reviews, venture analysis, or board-level risk summaries.

risk-analysis

11
from CaseMark/skills

Generates structured risk analysis summaries for legal matters, identifying and evaluating risks by severity and likelihood with quantified exposures and mitigation strategies. Use when preparing risk assessments, exposure analyses, liability summaries, or pre-filing risk evaluations across litigation, regulatory, contractual, reputational, and operational domains.

bsa-risk-assessment

11
from CaseMark/skills

Drafts a BSA/AML Risk Assessment for U.S. financial institutions per FinCEN, FFIEC, and OCC standards. Evaluates inherent risks (customer, product, geographic, transaction, third-party), control adequacy, and residual risk. Use when preparing annual BSA compliance assessments, post-acquisition integration reviews, or when business changes trigger reassessment under 31 U.S.C. § 5318(h).

managing-value-creation-plans

11
from CaseMark/skills

Structures 100-day and long-term value creation plans with initiative tracking and KPI targets. Use when building value creation plans, tracking improvement initiatives, or managing post-acquisition integration.