Communitygithub.com

風險投資組合管理員 - 以AI驅動的風險控制

AI驅動的投資組合風險管理與優化,用於部位規模設定、投資組合配置、風險指標計算、再平衡及防禦策略實施。

風險投資組合管理員 - 以AI驅動的風險控制 是什麼?

此風險投資組合管理員技能提供一套系統性的風險管理層,位於信號生成與交易執行之間。它採用數據驅動方法來優化部位規模、管理投資組合風險,並自動化防禦行動。該技能支援多種平台(如 Claude Code、Cursor、Codex),並能處理部位規模計算(使用凱利準則與風險調整矩陣)、即時風險指標監控(包含 VaR、夏普比率、最大回撤)、動態再平衡觸發,以及止損警報與緊急停止等自動化防禦動作。其核心原則是確保沒有任何單一交易會危及整個投資組合,並透過結構化的 CLU 指令與整合既有工具(如價格驗證與地毯檢測)來實現穩健的風控。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

風險投資組合管理員 - 以AI驅動的風險控制 是做什麼的?

系統性風險管理層,位於信號生成與交易執行之間。採用數據驅動方法來優化部位規模、管理投資組合風險,並自動化防禦行動。

核心原則

部位規模設定與風險管理決定長期存活。沒有任何單一交易應該威脅到投資組合。

觸發條件

核心能力

1. 部位規模設定引擎

<position_sizing> 規模設定方法:

interface PositionSizeRequest {
  signal_strength: number;    // 0-1 來自迷因交易員
  token_risk_score: number;   // 1-10 來自地毯偵測
  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 - 中等
└─ 迷因曝險:63% - 高

警報:
⚠️ MEME 和 WIF 之間高度相關性 (0.85)
⚠️ 迷因板塊集中度超過 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
迷因幣      | 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%)
├─ 迷因幣: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: '迷因幣輪動出場',
    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%
迷因幣輪動出場          | -$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%)

風險評估:
⚠️ 對迷因幣輪動高度敏感(-25% 情境)
⚠️ 黑天鵝曝險顯著(-62%)
✓ 基本情境具有正向預期價值
✓ 多頭情境上行空間可觀(+73%)

建議:
考慮使用 SOL 賣權對沖迷因幣曝險,或將迷因幣配置減少 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 天以上的乾淨歷史數據
  • 相關性矩陣需要同步的價格數據
  • 所有建議均包含信心水準
  • 沒有地毯偵測檢查不得進行部位規模設定 </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".

相關技能