Communitygithub.com

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

AI驱动的投资组合风险管理和优化。用于头寸规模计算、投资组合配置管理、风险指标计算(VaR、夏普比率)、再平衡或实施防御性策略。涵盖:头寸规模、相关性分析、回撤管理、动态再平衡、熔断机制。

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

该技能是一个系统化的风险管理层,位于信号生成和交易执行之间。它使用数据驱动的方法优化头寸规模、管理投资组合风险并自动化防御性操作。该技能支持头寸规模计算引擎(基于凯利公式优化)、实时投资组合风险监控(包括VaR、夏普比率、相关性和集中度风险)、动态再平衡触发与建议、自动化防御性行动(如每日/每周亏损限制和熔断机制)以及压力测试场景分析。它主要适用于基于Solana生态的meme币交易系统,可从meme-trader、meme-executor、flow-tracker等工具获取输入,并为交易执行、信号生成和投资组合状态提供输出。所有推荐都包含置信度级别,并且没有经过rug检测的头寸规模计算会被拒绝。

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

在你喜欢的 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%(处于历史最高点)
├─ 夏普比率(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; // 触发再平衡的偏离百分比
}

再平衡输出:

再平衡建议

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

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

再平衡后预测:
├─ SOL: 31% (目标: 30%)
├─ Meme板块: 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;    // meme板块相对于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.

相关技能