Communitygithub.com

風險投資組合經理 - AI驅動的風險控制

AI驅動的投資組合風險管理與最佳化。用於部位規模設定、投資組合配置管理、風險指標計算(VaR、夏普值)、再平衡或實施防禦策略。涵蓋:部位規模設定、相關性分析、回撤管理、動態再平衡、緊急停止機制。

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

此技能為一個系統性的風險管理層,位於訊號產生和交易執行之間,利用數據驅動的方法來最佳化部位規模、管理投資組合風險,並自動化防禦性行動。其核心理念是:部位規模設定和風險管理決定長期生存,沒有任何單一交易應該威脅整個投資組合。技能支援多種觸發情境,包括部位規模計算、投資組合風險指標檢視、動態再平衡、以及透過殺戮開關(kill switch)系統的自動化防禦。它與其他技能(如迷因交易者、迷因執行者)深度整合,接收訊號強度和代幣風險評分等輸入,並輸出經過認可的部位規模、停損水準和風險警報。此外,技能包含壓力測試和情境分析功能,可評估極端市場事件對投資組合的影響,並提供可執行的最佳化建議。

相容平台✓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-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
├─ 貝塔值(對 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>

整合點

風險經理提供給:

  • 迷因執行者:經認可的部位規模、停損水準
  • 迷因交易者:部位限制、可用資金
  • 所有技能:投資組合狀態、風險警報

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

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.

相關技能