Communitygithub.com

风险投资组合管理器 - AI驱动风险控制

AI驱动的投资组合风险管理和优化。用于仓位规模管理、投资组合配置、风险指标计算(VaR、夏普比率)、再平衡以及实施防御策略。涵盖:仓位规模确定、相关性分析、回撤管理、动态再平衡、紧急停止机制。

风险投资组合管理器 - AI驱动风险控制 是什么?

该技能是一个系统化风险管理层,位于信号生成和交易执行之间。它利用数据驱动的方法来优化仓位规模、管理投资组合风险,并自动执行防御性操作,例如基于预设阈值(每日亏损限制、回撤限制、相关性峰值)的紧急停止。技能支持多种仓位规模计算方法(如凯利准则修正版)、风险调整后规模矩阵、以及基于信号强度的动态调整。它提供实时投资组合风险仪表盘,包含VaR、夏普比率、最大回撤、相关性矩阵和集中度风险指标。动态再平衡功能可根据目标配置对偏差和集中度进行自动调整。防御性操作包括可配置的紧急停止系统,当达到亏损或回撤限制时,自动暂停交易或清仓。该技能还支持情景分析和压力测试,以评估极端市场事件下的投资组合影响。与 meme 交易员、执行器、流量跟踪器和数据编排器等系统集成,确保风险控制贯穿整个交易流程。CLI 脚本提供仓位规模计算、风险指标、再平衡、压力测试和紧急停止检查的功能。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/majiayu000/claude-skill-registry-data/tree/HEAD/business/risk-portfolio-manager

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

风险投资组合管理器 - AI驱动风险控制 是做什么的?

系统化风险管理层,位于信号生成和交易执行之间。使用数据驱动方法优化仓位规模、管理投资组合风险,并自动执行防御性操作。

核心原则

仓位规模和风险管理决定长期生存。没有任何一笔交易应该威胁到整个投资组合。

激活触发器

核心能力

1. 仓位规模引擎

<position_sizing> 规模计算方法:

interface PositionSizeRequest {
  signal_strength: number;    // 0-1 来自 meme 交易员
  token_risk_score: number;   // 1-10 来自 rug 检测
  current_portfolio: Portfolio;
  market_regime: 'bull' | 'bear' | 'sideways' | 'volatile';
  risk_tolerance: 'conservative' | 'moderate' | 'degen';
}

interface PositionSizeResult {
  recommended_size_pct: number;  // 投资组合百分比
  recommended_size_usd: number;
  max_allowed_size: number;
  reasoning: string[];
  risk_warnings: string[];
}

凯利准则(修正版):

最优规模 = (胜率 * 平均赢利 - (1 - 胜率) * 平均亏损) / 平均赢利
调整后规模 = 凯利 * 分数乘数 (安全起见 0.25-0.5)

风险调整后规模矩阵:

风险容忍度基础规模最大单一持仓最大相关敞口
保守0.5-1%2%5%
中等1-2%4%10%
激进2-5%10%25%

基于信号的调整:

最终规模 = 基础规模 * 信号强度 * (1 - 代币风险 / 20) * 市场乘数

其中:
- 信号强度: 0.5-1.5(弱到强)
- 代币风险: 1-10(越低越安全)
- 市场乘数: 0.5(波动)到 1.2(趋势)

输出格式:

仓位规模建议

代币:$MEME
信号强度:8/10
代币风险评分:4/10
市场状态:牛市

建议规模:
├─ 百分比:投资组合的 2.3%
├─ 金额:$460(投资组合 $20,000)
├─ 最大允许:$800(4% 限制)
└─ 风险调整后:在限制内

理由:
1. 强劲信号 (8/10) 支持高于平均的规模
2. 低-中等风险代币 (4/10) 允许全额配置
3. 牛市市场状态允许激进规模
4. 与现有持仓无相关性

警告:
- 考虑分批建仓(3 批)而非一次性入场
- 设置止损在 -25%(最大亏损 $345)

</position_sizing>

2. 投资组合风险指标

<risk_metrics> 实时投资组合仪表盘:

投资组合风险仪表盘
═══════════════════════════════════════

持仓(5 个活跃):
代币      | 规模     | 盈亏      | 风险  | 权重
$BONK      | $4,200   | +$840     | 5/10  | 21%
$MEME      | $3,100   | +$620     | 4/10  | 15.5%
$DOGE      | $2,800   | -$140     | 3/10  | 14%
$WIF       | $2,500   | +$1,250   | 6/10  | 12.5%
SOL        | $7,400   | +$2,220   | 2/10  | 37%
───────────────────────────────────────
总计      | $20,000  | +$4,790   |       | 100%

风险指标:
├─ 每日 VaR (95%): -$1,240 (-6.2%)
├─ 最大回撤 (30天): -18.3%
├─ 当前回撤: 0% (历史最高点)
├─ 夏普比率 (30天): 2.14
├─ 索提诺比率: 2.87
├─ 对 SOL 的 Beta: 1.34

相关性矩阵:
        BONK   MEME   DOGE   WIF    SOL
BONK    1.00   0.82   0.71   0.78   0.65
MEME    0.82   1.00   0.68   0.85   0.61
DOGE    0.71   0.68   1.00   0.59   0.54
WIF     0.78   0.85   0.59   1.00   0.72
SOL     0.65   0.61   0.54   0.72   1.00

集中度风险:
├─ 最大持仓:37%(SOL)- 在限制内
├─ 前三大持仓:72.5% - 高
├─ 赫芬达尔指数:0.23 - 中等
└─ Meme 敞口:63% - 高

警报:
⚠️ MEME 和 WIF 之间高度相关 (0.85)
⚠️ Meme 板块集中度超过 50%

风险计算:

interface PortfolioRisk {
  // 在险价值
  var_95: number;       // 95% 置信度每日 VaR
  var_99: number;       // 99% 置信度每日 VaR
  cvar_95: number;      // 条件 VaR(预期亏损)

  // 绩效风险
  sharpe_ratio: number;
  sortino_ratio: number;
  max_drawdown: number;
  current_drawdown: number;

  // 相关性风险
  avg_correlation: number;
  max_correlation: number;
  correlation_cluster: string[]; // 高度相关的组

  // 集中度风险
  herfindahl_index: number;
  top_position_pct: number;
  sector_concentrations: Record<string, number>;
}

function calculateVaR(
  positions: Position[],
  confidence: number = 0.95,
  horizon_days: number = 1
): number {
  // 使用过去 30 天的收益率计算历史 VaR
  const returns = getHistoricalReturns(positions, 30);
  const portfolio_returns = calculatePortfolioReturns(returns, positions);
  const sorted = portfolio_returns.sort((a, b) => a - b);
  const index = Math.floor((1 - confidence) * sorted.length);
  return sorted[index] * getPortfolioValue(positions) * Math.sqrt(horizon_days);
}

</risk_metrics>

3. 动态再平衡

目标配置框架:

interface AllocationTarget {
  core_holdings: {
    SOL: { target: 30, min: 20, max: 50 };
    stablecoins: { target: 20, min: 10, max: 40 };
  };
  satellite_holdings: {
    memes: { target: 30, min: 0, max: 50 };
    defi: { target: 15, min: 0, max: 30 };
    other: { target: 5, min: 0, max: 15 };
  };
  rebalance_threshold: 5; // 触发再平衡的偏差百分比
}

再平衡输出:

再平衡建议

当前 vs 目标配置:
类别       | 当前    | 目标    | 偏差   | 操作
SOL        | 37%     | 30%     | +7%    | 卖出 $1,400
Memes      | 63%     | 50%     | +13%   | 卖出 $2,600
稳定币     | 0%      | 20%     | -20%   | 买入 $4,000

建议交易:
1. 卖出 BONK 仓位的 15%($630)→ USDC
2. 卖出 WIF 仓位的 20%($500)→ USDC
3. 卖出 SOL 仓位的 10%($740)→ USDC
4. 保留 MEME 和 DOGE 仓位
5. 将出售所得转换为 USDC 稳定币缓冲

再平衡后预测:
├─ SOL:31%(目标:30%)
├─ Memes:48%(目标:50%)
├─ 稳定币:21%(目标:20%)
└─ VaR 降低:-18%(风险状况改善)

4. 自动防御性操作

<defensive_actions> 紧急停止系统:

interface KillSwitchConfig {
  daily_loss_limit: number;      // 投资组合百分比
  weekly_loss_limit: number;     // 投资组合百分比
  position_loss_limit: number;   // 每笔持仓百分比
  drawdown_limit: number;        // 从峰值的百分比
  correlation_spike_action: 'alert' | 'reduce' | 'exit';
  auto_execute: boolean;
}

const defaultKillSwitch: KillSwitchConfig = {
  daily_loss_limit: 10,      // 日亏损 -10% 时暂停新交易
  weekly_loss_limit: 20,     // 周亏损 -20% 时暂停所有活动
  position_loss_limit: 30,   // 持仓亏损 -30% 时自动平仓
  drawdown_limit: 25,        // 从峰值回撤 -25% 时进入紧急模式
  correlation_spike_action: 'alert',
  auto_execute: false,       // 第一阶段需确认
};

触发的操作:

触发条件操作严重性
持仓 -25%止损警告中等
持仓 -30%自动平仓(如启用)高
每日 -10%暂停新交易高
每周 -20%退出至稳定币严重
回撤 -25%紧急清算严重
相关性 > 0.95减少一个仓位中等

警报输出:

🚨 风险警报:接近每日亏损限制

当日盈亏:-8.7%($-1,740)
每日限制:-10%($-2,000)
剩余缓冲:$260

触发的操作:
1. ⏸️ 新交易执行已暂停
2. ⚠️ 审查所有未平仓持仓
3. 📊 增加监控频率

建议:
- 审查表现最差的持仓(WIF:-15%)
- 如果趋势持续,考虑部分退出
- 不要摊平成本

输入 RESUME 重新启用交易
输入 EXIT_ALL 清空所有持仓

</defensive_actions>

5. 情景分析

<scenario_analysis> 压力测试:

interface StressScenario {
  name: string;
  market_move: {
    sol: number;      // 百分比变化
    memes: number;    // 相对于 SOL 的百分比变化
    correlation_shift: number;
  };
  probability: number;
}

const stressScenarios: StressScenario[] = [
  {
    name: 'SOL -30% 闪崩',
    market_move: { sol: -30, memes: -50, correlation_shift: 0.2 },
    probability: 0.05,
  },
  {
    name: 'Meme 轮动退出',
    market_move: { sol: 0, memes: -40, correlation_shift: -0.1 },
    probability: 0.10,
  },
  {
    name: '牛市延续',
    market_move: { sol: 50, memes: 100, correlation_shift: 0 },
    probability: 0.15,
  },
  {
    name: '黑天鹅事件',
    market_move: { sol: -60, memes: -80, correlation_shift: 0.3 },
    probability: 0.01,
  },
];

压力测试输出:

压力测试结果

当前投资组合价值:$20,000

场景                       | 投资组合影响      | 概率
SOL -30% 闪崩              | -$7,200 (-36%)    | 5%
Meme 轮动退出             | -$5,040 (-25%)    | 10%
牛市延续                  | +$14,600 (+73%)   | 15%
黑天鹅事件                | -$12,400 (-62%)   | 1%

预期投资组合价值:
├─ 基本情况:$20,000
├─ 预期值(概率加权):$22,340 (+11.7%)
├─ 最坏情况 (99%):-$12,400 (-62%)
└─ VaR (95%, 30天):-$4,800 (-24%)

风险评估:
⚠️ 对 Meme 轮动高度敏感(-25% 情景)
⚠️ 黑天鹅敞口显著(-62%)
✓ 基本情景下预期价值为正
✓ 牛市情况下行空间可观(+73%)

建议:
考虑通过 SOL 看跌期权对冲 Meme 敞口,或
将 Meme 配置减少 10-15% 以改善风险状况。

</scenario_analysis>

集成点

风险管理器提供至:

  • meme-executor:批准的仓位规模、止损水平
  • meme-trader:仓位限制、可用资金
  • 所有技能:投资组合状态、风险警报

CLI 用法

# 计算仓位规模
npx tsx .claude/skills/risk-portfolio-manager/scripts/position-sizer.ts \
  --signal 8 \
  --risk-score 4 \
  --portfolio-file ./portfolio.json \
  --risk-mode moderate

# 获取投资组合风险指标
npx tsx .claude/skills/risk-portfolio-manager/scripts/risk-metrics.ts \
  --portfolio-file ./portfolio.json \
  --include-correlation \
  --var-confidence 95

# 再平衡建议
npx tsx .claude/skills/risk-portfolio-manager/scripts/rebalancer.ts \
  --portfolio-file ./portfolio.json \
  --target-allocation ./targets.json \
  --threshold 5

# 运行压力测试
npx tsx .claude/skills/risk-portfolio-manager/scripts/stress-test.ts \
  --portfolio-file ./portfolio.json \
  --scenarios default \
  --output-format detailed

# 检查紧急停止状态
npx tsx .claude/skills/risk-portfolio-manager/scripts/kill-switch.ts \
  --portfolio-file ./portfolio.json \
  --check-status

质量门禁

<validation_rules>

  • 仓位规模要求价格数据质量得分 >= 85%
  • VaR 计算需要 30 天以上的干净历史数据
  • 相关性矩阵需要同步的价格数据
  • 所有建议都包含置信水平
  • 未经过 rug 检测检查不得进行仓位规模设置 </validation_rules>

错误处理

<error_recovery>

  • 缺少价格数据:使用最后已知数据 + 陈旧警告
  • 计算错误:保守回退(最小规模)
  • 紧急停止冲突:安全优先(暂停 > 继续)
  • 数据质量不足:拒绝规模设置,请求刷新 </error_recovery>

<see_also>

  • references/risk-models.md - 数学公式
  • references/allocation-templates.md - 目标投资组合
  • scripts/position-sizer.ts - 规模引擎
  • scripts/risk-metrics.ts - 风险计算
  • scripts/kill-switch.ts - 自动安全 </see_also>

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Analyzes current state and user query to answer BMad questions or recommend the next workflow or agent. Use when user says what should I do next, what do I do now, or asks a question about BMad

majiayu000/claude-skill-registry-data

Build AI agents with Google ADK Python (Agent Development Kit). Use for multi-agent systems, workflow agents (sequential/parallel/loop), Vertex AI deployment, tool integration, human-in-the-loop.

majiayu000/claude-skill-registry-data

Build AI agents with Google ADK Python (Agent Development Kit). Use for multi-agent systems, workflow agents (sequential/parallel/loop), Vertex AI deployment, tool integration, human-in-the-loop.

majiayu000/claude-skill-registry-data

Portfolio allocation and rebalancing optimizer. Manages asset allocation across stocks/cash/bonds, performs periodic rebalancing, and ensures diversification according to market regime and risk tolerance.

majiayu000/claude-skill-registry-data

Create a hilarious and ultra-realistic video of an anthropomorphic animal acting like a human vlogger in a real-world setting.

majiayu000/claude-skill-registry-data

Speech-to-text transcription and translation via OpenAI Audio API -- models, response formats, timestamps, prompting, streaming, chunking, and diarization

majiayu000/claude-skill-registry-data

This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.

majiayu000/claude-skill-registry-data

小省导购员数字人带货版即梦视频提示词生成系统,基于四大智能体协同(提示词生成师、质量管控师、知识库运维师、跨环节适配师),按照"主体+运动+场景+(镜头语言+光影+氛围)"公式输出中英文双版提示词,适配5s短视频。确保人物一致性、视觉连贯性、情绪连贯性,支持知识库智能复用和跨工具适配(Suno音乐、AI绘画),为数字人带货视频提供高质量提示词生成服务。

majiayu000/claude-skill-registry-data

Upload and manage files using Google Gemini File API via scripts/. Use for uploading images, audio, video, PDFs, and other files for use with Gemini models. Supports file upload, status checking, and file management. Triggers on "upload file", "file API", "upload image", "upload PDF", "upload video", "file management".

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

majiayu000/claude-skill-registry-data

Conduct domain and industry research. Use when the user says "lets create a research report on [domain or industry]

majiayu000/claude-skill-registry-data

Conduct market research on competition and customers. Use when the user says "create a market research report about [business idea]".

majiayu000/claude-skill-registry-data

Conduct technical research on technologies and architecture. Use when the user says "create a technical research report on [topic]".

majiayu000/claude-skill-registry-data

Builds, edit or validate Agent Skill through conversational discovery. Use when the user requests to "Create an Agent", "Optimize an Agent" or "Edit an Agent".

相关技能