Token导航 LogoToken导航TokenDH.com
待分类需要联网github未标认证来源可访问许可证需确认审计通过

algo-risk-var算法风险变量

Agent Skill

algo-risk-var 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

371

周安装

15

GitHub Stars

125

下载量

116
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:algo-risk-var(算法风险变量)
来源仓库:https://github.com/asgard-ai-platform/skills
仓库路径:skills/algo-risk-var
安装命令:
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-risk-var
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-risk-var

简介

algo-risk-var 估算投资组合在指定时间与置信水平下的最大可能损失。

  • 适用于风控限额设定、资本储备计算与监管报告准备。
  • 支持正态法、历史模拟与蒙特卡洛三种计算方法。
  • 安装命令:npx skills add https://github.com/asgard-ai-platform/skills --skill algo-risk-var
  • 不反映尾部极端损失,需配合CVaR等补充指标使用

SKILL.md

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 returns. 2. Sort P&L ascending. 3. VaR = the (1-α) percentile loss.

Monte Carlo: 1. Fit return distribution (or use historical). 2. Simulate 10,000+ portfolio paths. 3. VaR = (1-α) percentile of simulated losses.

Phase 3: Verification

Backtest: count how often actual losses exceed VaR over the past year. At 95% confidence, exceedances should be ~5%. Use Kupiec or Christoffersen test. Gate: Backtest exceedance rate within acceptable bounds.

Phase 4: Output

Return VaR estimate with backtest results.

Output Format

{
  "var": {"amount": 1250000, "confidence": 0.95, "horizon_days": 1, "currency": "TWD"},
  "cvar": {"amount": 1800000},
  "backtest": {"exceedances": 13, "expected": 12.5, "days_tested": 250, "pass": true},
  "metadata": {"method": "historical_simulation", "portfolio_value": 50000000}
}

Examples

Sample I/O

Input: Portfolio value = $1,000,000. Last 20 sorted daily returns (descending loss):

[-0.050, -0.040, -0.035, -0.030, -0.025, -0.020, -0.015, -0.010, -0.005, 0.000,
  0.005,  0.010,  0.015,  0.020,  0.025,  0.030,  0.035,  0.040,  0.045,  0.050]

Confidence = 95%, horizon = 1 day.

Expected (Historical Simulation):

  • 5th percentile index = floor(20 × 0.05) = 1 → return[1] = -0.040
  • VaR = $1,000,000 × 0.040 = $40,000
  • CVaR (Expected Shortfall) = mean of returns worse than VaR = (-0.050) × $1M = $50,000

Verify: VaR ≤ CVaR always (tail loss ≥ threshold loss). Count of losses > VaR should be ≤ 5% of observations (1 of 20).

Edge Cases

InputExpectedWhy
Normal market conditionsVaR looks adequateBut misses tail events
2008-like crisis in historyHigher VaR from historical methodCaptures fat tails if crisis is in window
Very short history (30 days)Unreliable VaRInsufficient data for tail estimation

Gotchas

  • Normality assumption: Parametric VaR assumes normal returns. Financial returns have fat tails — parametric VaR UNDERESTIMATES tail risk.
  • Historical window: Historical simulation is only as good as the history. If the past 250 days were calm, VaR will be low even if a crisis is coming.
  • Time scaling: VaR scales with √T only under independence and normality. For volatile or trending markets, this approximation is poor.
  • Diversification illusion: VaR from correlated assets using normal-times correlations understates risk. Correlations spike during crises (correlation breakdown).
  • Gaming VaR: Traders can structure positions that look safe under VaR but have catastrophic tail risk. This is why regulators also require stress testing.

References

  • For Expected Shortfall (CVaR) calculation, see references/expected-shortfall.md
  • For VaR backtesting methods, see references/backtesting.md

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.26%
按下载量换算40

Claude

31.38%
按下载量换算36

Cursor

17.42%
按下载量换算20

Gemini CLI

9.87%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills