Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/risk-modeling-guide
Financial risk modeling including VaR, stress testing, and credit risk
Passed 17 of 23 test cases with the skill, and 16 of 23 without it.
1 fixed16 passed either way6 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
A test case the skill fixed. Same model, same prompt, with and without the skill.
We are setting up a credit risk pipeline in Python to analyze default probabilities and exposure risk. Could you provide a function that fits a logistic regression model on borrower credit features against a default indicator, returning a dictionary with the ROC AUC score, intercept, and coefficient odds ratios? Additionally, provide a helper function that takes individual probability of default, loss given default, and exposure at default values, returning a dictionary with the calculated expected loss and 99% unexpected loss.
| Checked | Without skill | With skill |
|---|---|---|
| Sets LogisticRegression parameter class_weight to balanced | Missed | Passed |
| Computes 99% unexpected loss using multiplier factor 2.33 times square root of PD times one minus PD | Missed | Passed |
| Includes key Expected_Loss in returned dictionary formatted to 2 decimal places | Missed | Passed |
The instructions your model reads when the skill loads.
A skill for quantitative financial risk modeling, covering Value at Risk, Expected Shortfall, credit risk, stress testing, and Monte Carlo simulation methods. Essential for financial engineering research and regulatory risk analysis.
| Method | Description | Pros | Cons |
|---|---|---|---|
| Historical simulation | Replay past returns | No distributional assumption | Assumes past repeats |
| Variance-covariance | Assume normal returns | Fast, analytical | Underestimates tail risk |
| Monte Carlo simulation | Simulate from fitted model | Flexible distributions | Computationally expensive |
| Filtered historical simulation | GARCH + historical innovations | Captures volatility clustering | More complex |
import numpy as np
import pandas as pd
from scipy.stats import norm, t as t_dist
def historical_var(returns: np.ndarray, confidence: float = 0.99,
horizon_days: int = 1) -> dict:
"""
Compute Value at Risk using historical simulation.
returns: array of daily log returns
confidence: confidence level (e.g., 0.99 for 99% VaR)
horizon_days: risk horizon in days
"""
# Scale returns to horizon
if horizon_days > 1:
# Rolling sum for overlapping returns
scaled_returns = pd.Series(returns).rolling(horizon_days).sum().dropna().values
else:
scaled_returns = returns
alpha = 1 - confidence
var = -np.percentile(scaled_returns, alpha * 100)
es = -np.mean(scaled_returns[scaled_returns <= -var])
test cases passed, vs 16 / 23 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.