algo-risk-var

Solid

"Calculate Value at Risk to estimate maximum portfolio loss at a given confidence level. Use this skill when the user needs to quantify downside risk, set risk limits, or report regulatory risk measures — even if they say 'worst case loss', 'portfolio risk', or 'how much could we lose'.".

AI & Automation 22 stars 8 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
45
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Value at Risk (VaR) ## Overview VaR estimates the maximum loss a portfolio can suffer over a given time horizon at a specified confidence level. Example: "95% 1-day VaR of $1M" means there's a 5% chance of losing more than $1M in one day. Three methods: parametric (normal), historical simulation, Monte Carlo. ## When to Use **Trigger conditions:** - Quantifying portfolio downside risk for risk management - Setting trading limits and capital reserves - Regulatory reporting (Basel III requires VaR-based capital) **When NOT to use:** - When you need to know how bad losses CAN get beyond VaR (use CVaR/Expected Shortfall) - For illiquid assets with no price history (VaR needs return data) ## Algorithm ``` IRON LAW: VaR Does NOT Tell You How Bad It Gets BEYOND the Threshold VaR says "95% of the time, losses won't exceed $X." It says NOTHING about the 5% worst case. A portfolio can have low VaR but catastrophic tail losses. Always supplement with Expected Shortfall (CVaR) which measures the average loss in the tail. ``` ### Phase 1: Input Validation Collect: portfolio positions, historical returns (min 250 days for 1Y), confidence level (typically 95% or 99%), time horizon (1 day or 10 days). **Gate:** Sufficient return history, positions valued at current market. ### Phase 2: Core Algorithm **Parametric VaR:** VaR = -μ + zα × σ (assumes normal returns). For portfolio: use covariance matrix for portfolio σ. **Historical Simulation:** 1. Compute daily P&L from historical ...

Details

Author
charlieviettq
Repository
charlieviettq/awesome-agent-skill
Created
2 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category