value-at-risk-calculator
Value at Risk (VaR) and related risk metrics calculation skill for financial and operational risk assessment
What this skill does
# Value at Risk Calculator
## Overview
The Value at Risk Calculator skill provides comprehensive capabilities for calculating VaR and related risk metrics using multiple methodologies. It supports financial risk assessment, operational risk quantification, and regulatory compliance through parametric, historical, and simulation-based approaches.
## Capabilities
- Historical simulation VaR
- Parametric VaR (variance-covariance)
- Monte Carlo VaR
- Conditional VaR (CVaR/Expected Shortfall)
- Incremental and component VaR
- Stress testing
- Backtesting and validation
- Regulatory reporting support
## Used By Processes
- Monte Carlo Simulation for Decision Support
- Risk Assessment
- Decision Quality Assessment
## Usage
### Historical Simulation VaR
```python
# Historical VaR configuration
historical_var_config = {
"method": "historical_simulation",
"data": {
"returns": portfolio_returns, # historical return series
"period": "daily",
"history_length": 252 # 1 year of trading days
},
"confidence_levels": [0.95, 0.99],
"holding_period": 1, # days
"options": {
"age_weighting": {
"enabled": True,
"decay_factor": 0.97
}
}
}
```
### Parametric VaR
```python
# Parametric (variance-covariance) VaR
parametric_var_config = {
"method": "parametric",
"portfolio": {
"positions": {
"Asset_A": {"value": 1000000, "weight": 0.4},
"Asset_B": {"value": 750000, "weight": 0.3},
"Asset_C": {"value": 750000, "weight": 0.3}
}
},
"parameters": {
"volatilities": {"Asset_A": 0.20, "Asset_B": 0.15, "Asset_C": 0.25},
"correlation_matrix": [
[1.0, 0.3, 0.2],
[0.3, 1.0, 0.5],
[0.2, 0.5, 1.0]
]
},
"confidence_level": 0.99,
"holding_period": 10 # days
}
```
### Monte Carlo VaR
```python
# Monte Carlo VaR configuration
monte_carlo_var_config = {
"method": "monte_carlo",
"simulations": 100000,
"model": {
"type": "geometric_brownian_motion",
"parameters": {
"drift": "historical",
"volatility": "garch"
}
},
"portfolio_valuation": "full_revaluation",
"confidence_levels": [0.95, 0.99],
"holding_period": 10
}
```
### Conditional VaR (Expected Shortfall)
CVaR represents the expected loss given that VaR is exceeded:
- CVaR at 95% = Average loss in worst 5% of scenarios
- Required by Basel III/IV for market risk capital
- More coherent risk measure than VaR
### Stress Testing
```python
# Stress test scenarios
stress_tests = {
"scenarios": [
{
"name": "2008 Financial Crisis",
"shocks": {"equity": -0.40, "credit_spreads": 0.03, "rates": -0.02}
},
{
"name": "COVID-19 March 2020",
"shocks": {"equity": -0.30, "volatility": 0.50, "credit_spreads": 0.02}
},
{
"name": "Interest Rate Spike",
"shocks": {"rates": 0.03, "equity": -0.15}
}
],
"output": ["portfolio_loss", "position_contributions"]
}
```
## Input Schema
```json
{
"method": "historical|parametric|monte_carlo",
"portfolio": {
"positions": "object",
"total_value": "number"
},
"data": {
"returns": "array or path",
"period": "string"
},
"parameters": {
"confidence_levels": ["number"],
"holding_period": "number",
"volatility_model": "string"
},
"stress_testing": {
"scenarios": ["object"]
},
"backtesting": {
"enabled": "boolean",
"test_period": "string"
}
}
```
## Output Schema
```json
{
"var_results": {
"confidence_level": {
"VaR": "number",
"VaR_percent": "number",
"CVaR": "number",
"CVaR_percent": "number"
}
},
"component_var": {
"position": {
"marginal_var": "number",
"component_var": "number",
"contribution_percent": "number"
}
},
"stress_test_results": {
"scenario_name": {
"portfolio_loss": "number",
"loss_percent": "number"
}
},
"backtesting": {
"exceptions": "number",
"exception_rate": "number",
"traffic_light": "green|yellow|red",
"kupiec_test": "object",
"christoffersen_test": "object"
},
"risk_attribution": "object"
}
```
## Best Practices
1. Use multiple methods and compare results
2. Validate with backtesting regularly
3. Include fat tails (t-distribution or historical for parametric)
4. Update parameters (volatility, correlations) frequently
5. Complement VaR with stress testing
6. Report CVaR alongside VaR for tail risk
7. Document all assumptions and limitations
## VaR Interpretation
| Metric | Meaning |
|--------|---------|
| VaR 95% = $1M | 95% confident loss won't exceed $1M |
| CVaR 95% = $1.5M | If loss exceeds VaR, average loss is $1.5M |
| Incremental VaR | Change in portfolio VaR from adding position |
| Component VaR | Position's contribution to total VaR |
## Backtesting Standards
| Exceptions (250 days) | Zone | Interpretation |
|----------------------|------|----------------|
| 0-4 | Green | Model is acceptable |
| 5-9 | Yellow | Model may have issues |
| 10+ | Red | Model needs review |
## Integration Points
- Receives simulations from Monte Carlo Engine
- Connects with Risk Register Manager for risk assessment
- Supports Risk Analyst agent
- Integrates with Decision Visualization for risk charts
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.