Communitygithub.com

majiayu000/claude-skill-registry

人工智能驱动的投资组合风险管理和优化。用于仓位规模计算、投资组合配置、风险评估(VaR、夏普比率)、再平衡或执行防御策略。涵盖:仓位规模、相关性分析、回撤管理、动态再平衡和紧急开关。

claude-skill-registry 是什么?

这是一个系统性风险管理技能层,位于信号生成与交易执行之间。它采用数据驱动方法优化仓位规模、管理投资组合风险并自动化防御操作。该技能支持仓位规模计算引擎(修正凯利准则与风险调整矩阵)、实时风险仪表盘(VaR、最大回撤、夏普比率、相关性矩阵等)、动态再平衡触发及建议、紧急开关系统(日/周亏损限制、最大回撤限制)、情景分析(压力测试与概率加权结果)。主要集成 meme-trader、meme-executor、flow-tracker 等外部技能,并提供 CLI 命令行工具。质量门控要求价格数据质量评分≥85%,VaR 计算需要 30 天以上干净数据,所有建议均包含置信水平。适用于 Claude Code、Codex 以及任何支持技能编排的 AI 代理平台。

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

在你喜欢的 AI 中提问

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

文档

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

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

核心原则

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

激活触发器

核心能力

1. 仓位规模计算引擎

<position_sizing> 规模计算方法:

interface PositionSizeRequest {
  signal_strength: number;    // 0-1 来自 meme-trader
  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%(处于 ATH)
├─ 夏普比率(30 天):2.14
├─ 索提诺比率:2.87
├─ Beta 对 SOL: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; // % 偏离触发
}

再平衡输出:

再平衡建议

当前与目标配置对比:
类别         | 当前   | 目标   | 偏离   | 操作
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;    // % 变化 vs 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

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".

majiayu000/claude-skill-registry

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry

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

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

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

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

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

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

majiayu000/claude-skill-registry

BlockRun works with Claude Code and Google Antigravity.

majiayu000/claude-skill-registry

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

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

majiayu000/claude-skill-registry

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

CRITICAL: Use for MolyKit AI chat toolkit. Triggers on: BotClient, OpenAI, SSE streaming, AI chat, molykit, PlatformSend, spawn(), ThreadToken, cross-platform async, Chat widget, Messages, PromptInput, Avatar, LLM

majiayu000/claude-skill-registry

AI and machine learning workflow covering LLM application development, RAG implementation, agent architecture, ML pipelines, and AI-powered features.

majiayu000/claude-skill-registry

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

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

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

相关技能