Portfolio risk measurement and stress testing. Activate when the user mentions VaR, CVaR, expected shortfall, drawdown, Sharpe ratio, Sortino, tracking error, stress test, Monte Carlo, scenario analysis, risk budget, volatility, correlation, tail risk, counterparty risk, factor risk decomposition, risk parity, hedging, downside protection, or asks about portfolio risk, worst-case scenarios, or risk reporting.
Ships in alpha-stack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
I'm Claude, running the risk-analytics skill from Alpha Stack. I measure, decompose, and stress-test portfolio risk using quantitative frameworks spanning market risk, credit risk, and tail risk.
I do NOT provide real-time risk monitoring or live P&L tracking. I produce risk analytics, scenario analysis, and hedging frameworks -- you apply them to your own portfolio and risk management process.
What this skill DOES:
What this skill does NOT do:
Use a different skill when:
/portfolio/attribution/derivatives/creditBefore starting any risk analysis, I need to determine:
If the user doesn't specify, ask:
What type of risk analysis do you need?
- Portfolio risk report (VaR, volatility, Sharpe, drawdown)
- Stress test (historical scenarios or hypothetical shocks)
- Factor risk decomposition (what is driving the risk?)
- Tail risk assessment (extreme downside analysis)
- Fixed income risk (duration, convexity, spread sensitivity)
- Credit risk (default probability, distance to default)
Before computing anything, validate the return data:
Decision Gate: If the history is less than 2 years of monthly data, warn that risk estimates will be unreliable. VaR with fewer than 50 observations has wide confidence intervals.
Run the portfolio risk tool:
python3 tools/portfolio_risk.py \
--returns 0.02,-0.01,0.03,0.01,-0.02,0.04,0.01,-0.03,0.02,0.01,-0.04,0.05,0.02,-0.01,0.03,-0.02,0.01,0.04,-0.01,0.02,0.03,-0.05,0.01,0.02 \
--rf 0.05 --freq 12
This produces:
If a benchmark is provided, compute relative risk:
python3 tools/portfolio_risk.py \
--returns 0.02,-0.01,0.03,0.01,-0.02,0.04,0.01,-0.03,0.02,0.01,-0.04,0.05 \
--benchmark 0.01,-0.02,0.02,0.01,-0.01,0.03,0.02,-0.02,0.01,0.02,-0.03,0.04 \
--rf 0.05 --freq 12
This adds:
Interpretation guide:
| Information Ratio | Assessment |
|---|---|
| > 1.0 | Exceptional (top decile of managers) |
| 0.5 - 1.0 | Very good (top quartile) |
| 0.2 - 0.5 | Decent (above median) |
| 0.0 - 0.2 | Marginal (not clearly skilled) |
| < 0.0 | Negative alpha (underperforming) |
Present results in a structured risk report:
### Risk Report: [Portfolio Name]
Period: [Start] to [End] | Frequency: [Monthly/Daily] | Observations: N
**Return Metrics:**
| Metric | Value |
|--------|-------|
| Annualized Return | X.XX% |
| Cumulative Return | X.XX% |
| Best Period | +X.XX% |
| Worst Period | -X.XX% |
**Risk Metrics:**
| Metric | Value |
|--------|-------|
| Annualized Volatility | X.XX% |
| Max Drawdown | -X.XX% |
| VaR (95% Historical) | X.XX% |
| VaR (95% Parametric) | X.XX% |
| CVaR (95%) | X.XX% |
**Risk-Adjusted Returns:**
| Metric | Value |
|--------|-------|
| Sharpe Ratio | X.XX |
| Sortino Ratio | X.XX |
| Calmar Ratio | X.XX |
Strengths: No distributional assumptions, captures fat tails and skewness. Weaknesses: Requires long history, assumes past represents future, single-period only.
Strengths: Simple, fast, works with portfolio-level covariance matrix. Weaknesses: Assumes normal distribution (underestimates tail risk), ignores skewness and kurtosis.
Correction for fat tails (Cornish-Fisher expansion):
python3 tools/monte_carlo.py \
--initial 10000000 --return 0.08 --vol 0.16 \
--years 1 --sims 10000 --seed 42
Strengths: Flexible distribution assumptions, handles non-linear positions (options), multi-period. Weaknesses: Computationally intensive, model-dependent, requires distribution specification.
Always present all three VaR estimates together:
| Method | 95% VaR (1-day) | 99% VaR (1-day) |
|---|---|---|
| Historical | X.XX% | X.XX% |
| Parametric | X.XX% | X.XX% |
| Monte Carlo | X.XX% | X.XX% |
Decision Gate: If parametric VaR is significantly lower than historical VaR, the return distribution has fat tails. Flag this and recommend using CVaR or Monte Carlo VaR for risk management.
CVaR answers: "Given that we are in the worst alpha% of outcomes, what is the average loss?"
Interpretation: If 95% VaR = 3% and 95% CVaR = 5%, this means:
A drawdown at time t = (Portfolio_t - Peak_t) / Peak_t
Key metrics:
Identify the top 5 drawdowns by depth:
| Rank | Start Date | Trough Date | Recovery Date | Depth | Duration | Recovery |
|------|-----------|-------------|---------------|-------|----------|----------|
| 1 | ... | ... | ... | -XX% | N months | N months |
| 2 | ... | ... | ... | -XX% | N months | N months |
For each major drawdown, diagnose:
Calmar ratio context:
| Calmar Ratio | Assessment |
|---|---|
| > 2.0 | Excellent drawdown-adjusted returns |
| 1.0 - 2.0 | Good |
| 0.5 - 1.0 | Acceptable |
| < 0.5 | Poor -- drawdown severity is too high relative to returns |
Common factor models:
Total portfolio risk = Systematic (factor) risk + Idiosyncratic (specific) risk
For each factor:
| Risk Source | Typical % of Total | Implication |
|---|---|---|
| Market (beta) | 60-90% | Dominated by broad market moves |
| Sector tilts | 5-15% | Industry bets contribute to active risk |
| Style factors | 5-20% | Value/momentum/quality tilts |
| Idiosyncratic | 5-30% | Stock-specific risk (diversifiable) |
Decision Gate: If idiosyncratic risk exceeds 30% of total, the portfolio is concentrated. This is acceptable for a concentrated stock picker but a red flag for a diversified mandate.
Replay the portfolio against known crisis periods:
| Scenario | Period | S&P 500 | 10Y UST | Credit (HY) | Key Driver |
|---|---|---|---|---|---|
| Black Monday | Oct 1987 | -20.5% | +3.8% | -8.0% | Market structure, portfolio insurance |
| LTCM / Russia | Aug-Oct 1998 | -19.3% | +5.2% | -12.0% | Leverage unwind, contagion |
| Dot-com Bust | Mar 2000 - Oct 2002 | -49.1% | +25.0% | -5.0% | Tech valuation collapse |
| GFC | Oct 2007 - Mar 2009 | -56.8% | +20.0% | -35.0% | Housing, leverage, systemic |
| Euro Crisis | Apr-Oct 2011 | -19.4% | +12.0% | -10.0% | Sovereign debt, banking |
| Taper Tantrum | May-Aug 2013 | -5.8% | -8.0% | -5.0% | Rate expectations |
| COVID Crash | Feb-Mar 2020 | -33.9% | +8.0% | -20.0% | Pandemic shock |
| 2022 Rate Shock | Jan-Oct 2022 | -25.4% | -18.0% | -15.0% | Inflation, rate hikes |
Procedure:
Design custom scenarios for current risks:
Scenario template:
Scenario: [Name]
Narrative: [What happens and why]
Shocks:
- Equity: [X]%
- Interest rates: [+/- Y] bps
- Credit spreads: [+/- Z] bps
- Currency (USD): [+/- W]%
- Volatility (VIX): [move to level]
- Commodity (oil): [X]%
Portfolio impact: [calculated]
Example hypothetical scenarios to consider:
For probabilistic stress testing, run Monte Carlo with stressed parameters:
python3 tools/monte_carlo.py \
--initial 10000000 --return -0.05 --vol 0.30 \
--years 1 --sims 10000 --seed 42
This uses a negative expected return and elevated volatility to simulate a crisis period.
Compute pairwise correlations across all portfolio positions or asset classes. Key diagnostics:
Correlations are not stable. They change dramatically between normal and crisis periods:
| Asset Pair | Normal Correlation | Crisis Correlation | Change |
|---|---|---|---|
| US Eq / Intl Eq | +0.65 | +0.90 | +0.25 |
| US Eq / US Bond | -0.20 | -0.40 (or +0.30) | Unstable |
| US Eq / Gold | +0.05 | -0.30 | -0.35 |
| US Eq / HY Credit | +0.60 | +0.85 | +0.25 |
Decision Gate: If the portfolio relies on equity/bond diversification, warn that in 2022-style rate shock scenarios, stocks and bonds can fall simultaneously. The negative correlation is not guaranteed.
Diversification ratio = (Sum of weighted individual volatilities) / Portfolio volatility
Run the Merton model:
python3 tools/merton_model.py \
--assets 1000 --debt 600 --vol 0.25 --rate 0.04 --maturity 5
| Distance to Default | Default Probability | Credit Quality |
|---|---|---|
| > 4.0 | < 0.01% | AAA/AA |
| 3.0 - 4.0 | 0.01% - 0.1% | A |
| 2.0 - 3.0 | 0.1% - 2% | BBB |
| 1.0 - 2.0 | 2% - 15% | BB/B |
| 0.5 - 1.0 | 15% - 30% | CCC |
| < 0.5 | > 30% | CC/C (distressed) |
Always run the Merton model across a range of assumptions:
Run the bond analytics tool:
python3 tools/bond_yield.py \
--face 1000 --coupon 0.05 --price 980 --years 10 --freq 2 \
--benchmark-yield 0.04
| Yield Change | Price Change (approx) |
|---|---|
| -100 bps | +Duration% + 0.5Convexity0.01^2 |
| -50 bps | +Duration*0.5% |
| +50 bps | -Duration*0.5% |
| +100 bps | -Duration% + 0.5Convexity0.01^2 |
| +200 bps | -Duration2% + 0.5Convexity*0.02^2 |
| +300 bps | -Duration3% + 0.5Convexity*0.03^2 |
| When you need... | Run this | Example |
|---|---|---|
| Full risk metrics | python3 tools/portfolio_risk.py | --returns 0.02,-0.01,0.03 --rf 0.05 --freq 12 |
| Benchmark-relative risk | python3 tools/portfolio_risk.py | --returns 0.02,-0.01,0.03 --benchmark 0.01,0.00,0.02 --rf 0.05 |
| Monte Carlo VaR/stress | python3 tools/monte_carlo.py | --initial 10000000 --return 0.07 --vol 0.16 --years 1 --sims 10000 |
| Bond duration/convexity | python3 tools/bond_yield.py | --face 1000 --coupon 0.05 --price 980 --years 10 |
| Credit default probability | python3 tools/merton_model.py | --assets 1000 --debt 600 --vol 0.25 --rate 0.04 --maturity 5 |
For every risk analysis, output a structured report with:
### Risk Report: [Portfolio/Position Name]
**Executive Summary:**
[1-2 sentences: What is the key risk finding?]
**Risk Dashboard:**
| Metric | Value | Assessment |
|--------|-------|-----------|
| ... | ... | ... |
**Stress Test Results:**
| Scenario | Portfolio Impact | Benchmark Impact | Relative |
|----------|-----------------|------------------|----------|
| ... | ... | ... | ... |
**Key Risks Identified:**
1. [Risk 1 with quantification]
2. [Risk 2 with quantification]
**Recommended Actions:**
1. [Action 1]
2. [Action 2]
Success metric: A risk officer reading the report should be able to assess whether the portfolio's risk profile is within acceptable bounds and identify the primary sources of risk.
Escalation triggers:
Treating VaR as a worst case: VaR is a threshold, not a maximum loss. A 95% VaR of 5% means there is a 5% chance of losing MORE than 5%. The actual loss in that tail could be 10%, 20%, or total. --> Always report CVaR alongside VaR.
Using parametric VaR for non-normal distributions: Financial returns have fat tails. Parametric VaR at 99% can underestimate true risk by 30-50%. --> Use historical or Monte Carlo VaR, or apply Cornish-Fisher corrections.
Backtesting without regime changes: A risk model built on 2012-2019 data (low vol, steady growth) will dramatically underestimate risk during a crisis. --> Always include at least one crisis period in the estimation window.
Ignoring correlation instability: Correlations spike during crises -- exactly when diversification matters most. A portfolio that looks diversified in normal times may behave like a concentrated bet in a crash. --> Always analyze crisis-period correlations separately.
Confusing tracking error with risk: Low tracking error means the portfolio behaves like its benchmark. It does NOT mean the portfolio has low absolute risk. An enhanced index fund with 1% tracking error still has full market beta. --> Report both absolute and relative risk.
Stress testing only historical scenarios: The next crisis will not be identical to 2008 or 2020. Historical scenarios are necessary but not sufficient. --> Always include hypothetical scenarios based on current risk factors.
Ignoring liquidity risk in VaR: VaR assumes positions can be liquidated at current prices. In a crisis, bid-ask spreads widen and some markets freeze. --> Apply liquidity haircuts to VaR for illiquid positions.
/portfolio/attribution/long-short/derivatives/credit/wealthWhat SKILL.md sets; muted values are Claude Code's defaults
/alpha-stack:risk-analyticsfrom alpha-stack
alpha-stack@fin-skills is listed by howard-lynn-ye/fin-rsi — review the source before installing
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin alpha-stack47 skills in this plugin
/accountingAccounting analysis — journal entries, chart of accounts, accruals, and closing process.
Activate when the user mentions journal entry, adjusting entry, closing entry, accrual,
deferral, chart of accounts, trial balance, general ledger, accounts receivable,
accounts payable, depreciation entry, amortization entry, revenue recognition,
ASC 606, lease accounting, ASC 842, intercompany, consolidation, or asks about
recording transactions, month-end close, or accounting treatment for a specific event.
/attributionPerformance attribution analysis. Activate when the user mentions Brinson attribution,
Brinson-Fachler, allocation effect, selection effect, interaction effect, performance
decomposition, active return attribution, sector attribution, factor attribution,
currency attribution, fixed income attribution, multi-period attribution, or asks
why a portfolio outperformed or underperformed its benchmark.
/Other plugins' skills for the same job