Communitygithub.com

投資組合風險分析器

完整的投資組合風險管理系統。分析持倉、計算風險指標、壓力測試情境、優化配置,並生成機構級風險報告——全部無需外部 API。

投資組合風險分析器 是什麼?

此技能提供了一個完整的投資組合風險管理系統,專為 AI 代理(如 Claude Code、Cursor、Codex)設計。用戶可以分享其持倉明細,技能即自動執行從價格查詢、風險指標計算(如集中度風險、VaR、最大回撤、Beta、夏普比率、收益分析)到壓力測試(多種歷史情境包含金融危機、COVID 崩盤等)的完整流程。技能支援股票、加密貨幣、ETF、房地產(REITs)和期權等多元資產類別,並提供自訂情境構建器。關鍵功能還包括投資組合優化(資產配置評估、風險平價分析、再平衡建議、相關性分析)、風險評分卡(0-100 綜合評分)、監控警報(每日/每週檢查模板)以及稅損收割掃描器。此工具旨在幫助開發者和投資者快速取得深度、數據驅動的風險洞察,以支援更明智的投資決策。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/modbender/skill-library-mcp/tree/HEAD/data/afrexai-portfolio-risk

在你喜歡的 AI 中提問

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

說明文件

投資組合風險分析器 是做什麼的?

完整的投資組合風險管理系統。分析持倉、計算風險指標、壓力測試情境、優化配置,並生成機構級風險報告——全部無需外部 API。


1. 投資組合導入

當用戶分享他們的投資組合(持倉、股票代碼、數量)時,將其結構化為以下格式:

portfolio:
  name: "用戶投資組合"
  currency: USD
  as_of: "2026-02-15"
  positions:
    - ticker: AAPL
      shares: 50
      avg_cost: 185.00
      current_price: 228.50  # 透過網路搜尋查詢
      asset_class: US_EQUITY
      sector: Technology
    - ticker: BTC
      units: 0.5
      avg_cost: 42000
      current_price: 97500
      asset_class: CRYPTO
      sector: Digital Assets
    - ticker: VOO
      shares: 100
      avg_cost: 410.00
      current_price: 535.00
      asset_class: US_EQUITY_ETF
      sector: Broad Market
  cash:
    amount: 15000
    currency: USD

價格查詢

對於每個持倉,使用網路搜尋找到當前價格:

  • 搜尋:[TICKER] stock price today
  • 對於加密貨幣:[COIN] price USD today
  • 記錄來源和時間戳

投資組合摘要表格

持倉股數/數量成本基礎當前價值權重損益損益 %
AAPL50$9,250$11,42518.2%+$2,175+23.5%
.....................
總計$XX,XXX$XX,XXX100%±$X,XXX±X.X%

2. 風險指標計算器

對於每次投資組合分析,計算以下所有項目:

2.1 集中度風險

持倉集中度:
- 任何單一持倉 > 20% 的投資組合 = 高風險 ⚠️
- 任何單一持倉 > 10% = 中等風險
- 前三大持倉 > 50% = 集中度高

行業集中度:
- 任何行業 > 30% = 超配
- 計算獨特行業數量 — 少於 4 個 = 缺乏多元化

資產類別分佈:
- 股票:X%
- 固定收益:X%
- 加密貨幣:X%
- 現金:X%
- 另類投資:X%

2.2 風險價值 (VaR) — 參數法

計算在給定信心水準下的最大預期損失:

每日 VaR 計算:
1. 查詢每個持倉的歷史波動率(年化)
   - 使用網路搜尋:"[TICKER] historical volatility 30 day"
   - 典型範圍:大型股 15-25%,加密貨幣 50-80%,債券 5-10%

2. 轉換為每日波動率:
   每日波動率 = 年化波動率 / √252

3. 持倉 VaR(95% 信心水準):
   持倉 VaR = 持倉價值 × 每日波動率 × 1.645

4. 持倉 VaR(99% 信心水準):
   持倉 VaR = 持倉價值 × 每日波動率 × 2.326

5. 投資組合 VaR(簡化版 — 假設股票間相關係數 ≈ 0.5):
   投資組合 VaR ≈ √(Σ(持倉 VaR²) + 2×0.5×Σ(VaR_i × VaR_j))

報告:
- 1 日 95% VaR:$X,XXX(投資組合的 X.X%)
- 1 日 99% VaR:$X,XXX(投資組合的 X.X%)
- 10 日 95% VaR:$X,XXX(= 1 日 VaR × √10)
- 月度 95% VaR:$X,XXX(= 1 日 VaR × √21)

2.3 最大回撤估算

基於資產類別的歷史最大回撤:
- 美國大型股:-50%(2008-09),典型修正 -20%
- 美國小型股:-55%,典型修正 -25%
- 國際股票:-55%,典型修正 -25%
- 新興市場:-65%,典型修正 -30%
- 投資級債券:-15%,典型修正 -5%
- 高收益債券:-30%,典型修正 -10%
- REITs:-70%,典型修正 -25%
- 加密貨幣(BTC):-85%,典型修正 -50%
- 黃金:-45%,典型修正 -15%
- 現金:0%

投資組合最大回撤估算:
= Σ(持倉權重 × 資產類別最大回撤)

報告:
- 估算最壞情況回撤:-$XX,XXX (XX.X%)
- 估算典型修正:-$XX,XXX (XX.X%)
- 恢復時間估計:X-X 個月(基於歷史平均值)

2.4 Beta 與市場敏感性

對於每個股票持倉:
- 透過網路搜尋查詢 Beta:"[TICKER] beta"
- 投資組合 Beta = Σ(持倉權重 × 持倉 Beta)

解讀:
- Beta > 1.2:投資組合為積極型(放大市場波動)
- Beta 0.8-1.2:投資組合為中性
- Beta < 0.8:投資組合為防禦型
- 負 Beta 持倉:對沖價值

市場影響:
- 如果標普 500 下跌 10%,投資組合預期變動:Beta × -10%

2.5 夏普比率估算

投資組合預期報酬率 = Σ(權重 × 預期報酬率)
其中按資產類別的預期報酬率:
- 美國大型股:每年 8-10%
- 美國小型股:每年 9-11%
- 國際已開發市場:每年 6-8%
- 新興市場:每年 8-12%
- 投資級債券:每年 4-5%
- 高收益債券:每年 6-7%
- 加密貨幣:高度變動(保守估計使用 0%)
- REITs:每年 7-9%
- 現金:當前貨幣市場利率(約 4.5%)

無風險利率:當前 3 個月期國庫券利率(如需請搜尋)

夏普比率 = (投資組合預期報酬率 - 無風險利率) / 投資組合波動率

評級:
- > 1.0:風險調整後報酬**優異**
- 0.5-1.0:**良好**
- 0-0.5:**平庸** — 考慮再平衡
- < 0:**差勁** — 報酬無法證明風險合理

2.6 收益分析

對於支付股息的持倉:
- 查詢股息率:"[TICKER] dividend yield"
- 年度收入 = 股數 × 每股年度股息
- 投資組合收益率 = 總年度股息 / 投資組合價值

報告:
- 月度估計收入:$XXX
- 年度估計收入:$X,XXX
- 成本收益率:X.X%
- 當前收益率:X.X%

3. 壓力測試

針對投資組合執行以下情境並報告影響:

3.1 標準情境

scenarios:
  market_crash_2008:
    name: "2008 金融危機"
    impacts:
      US_EQUITY: -0.50
      INTL_EQUITY: -0.55
      EMERGING: -0.60
      BONDS: +0.05
      HIGH_YIELD: -0.30
      REITS: -0.70
      CRYPTO: -0.80  # 根據風險狀況推測
      GOLD: +0.10
      CASH: 0

  covid_crash_2020:
    name: "COVID-19 崩盤(2020年2-3月)"
    impacts:
      US_EQUITY: -0.34
      INTL_EQUITY: -0.35
      EMERGING: -0.35
      BONDS: +0.03
      HIGH_YIELD: -0.20
      REITS: -0.40
      CRYPTO: -0.50
      GOLD: -0.05
      CASH: 0

  dot_com_2000:
    name: "網路泡沫破滅(2000-2002)"
    impacts:
      US_EQUITY: -0.45
      TECH: -0.75  # 特別應用於科技股
      INTL_EQUITY: -0.40
      BONDS: +0.15
      CASH: 0

  rate_hike_shock:
    name: "快速升息(+300 基點)"
    impacts:
      US_EQUITY: -0.15
      BONDS: -0.15
      HIGH_YIELD: -0.10
      REITS: -0.25
      CRYPTO: -0.20
      GOLD: -0.10
      CASH: +0.01  # 更高的收益率

  inflation_surge:
    name: "停滯性通膨(持續 8%+ 通膨率)"
    impacts:
      US_EQUITY: -0.20
      BONDS: -0.20
      CRYPTO: -0.10  # 有爭議的對沖工具
      GOLD: +0.15
      REITS: -0.05
      COMMODITIES: +0.20
      CASH: -0.03  # 實際價值侵蝕

  crypto_winter:
    name: "加密貨幣寒冬(80% 回撤)"
    impacts:
      CRYPTO: -0.80
      US_EQUITY: -0.05  # 輕微蔓延

3.2 壓力測試報告格式

對於每個情境:

📉 情境:[名稱]

| 持倉 | 當前價值 | 壓力測試後價值 | 損失 |
|----------|--------------|----------------|------|
| AAPL     | $11,425      | $5,713         | -$5,712 |
| ...      | ...          | ...            | ...  |
| 總計    | $XX,XXX      | $XX,XXX        | -$XX,XXX (-XX.X%) |

你能承受這個嗎?[是/否,基於現金儲備和收入需求]
恢復估計:X-X 個月

3.3 自訂情境構建器

如果用戶描述了特定的擔憂,建構一個自訂情境:

用戶:"如果科技股跌 40% 但債券反漲呢?"
→ 建構自訂影響對映,應用於投資組合,報告結果

4. 投資組合優化

4.1 當前配置評估

將當前配置與標準模型進行比較:

積極型(年齡 < 35,高風險承受度):
  股票:80-90%,債券:5-10%,另類投資:5-10%,現金:2-5%

成長型(年齡 35-50):
  股票:60-75%,債券:15-25%,另類投資:5-10%,現金:5%

平衡型(年齡 50-60):
  股票:40-60%,債券:30-40%,另類投資:5-10%,現金:5-10%

保守型(年齡 60+,注重收益):
  股票:20-40%,債券:40-50%,另類投資:5%,現金:10-20%

當前配置匹配:[模型] 概況
建議調整:[具體動作]

4.2 風險平價分析

風險平價目標:每個資產類別對投資組合貢獻**相等**的風險

步驟:
1. 計算每個持倉的風險貢獻:
   風險貢獻 = 權重 × 波動率 × 與投資組合的相關性

2. 對於相等的風險貢獻:
   目標權重_i = (1/波動率_i) / Σ(1/波動率_j)

3. 報告:
   當前權重 vs 風險平價權重
   重新平衡所需的交易
   對夏普比率的預期影響

4.3 再平衡建議

檢查再平衡觸發條件:
- 任何持倉偏離目標 > 5%?→ 需要再平衡
- 任何資產類別偏離目標 > 10%?→ 需要再平衡
- 上次再平衡距今 > 6 個月?→ 檢視

再平衡方法:
1. 計算目標權重
2. 計算當前權重
3. 確定所需交易(最小化交易次數)
4. 稅務批次優化:先賣出成本最高的批次(最小化稅務)
5. 若實現損失,考慮洗售規則

輸出交易清單:
| 動作 | 代碼 | 股數/數量 | 估計價值 | 原因 |
|--------|--------|--------|-----------|--------|
| 賣出   | AAPL   | 15     | $3,428    | 科技股超配 |
| 買入   | BND    | 25     | $1,850    | 債券低配 |

4.4 相關性分析

評估多元化品質:

**高度**相關組合 (>0.7) — 這些**不能**互相分散風險:
- 科技股之間
- 美國股票 ETF 之間
- 高收益債券與股票

**低度**相關組合 (<0.3) — **真正的**分散風險工具:
- 股票 vs 國庫債券
- 美國股票 vs 黃金
- 股票 vs 管理期貨

**負**相關 — 對沖工具:
- 多頭股票 + 賣出期權
- 股票 + VIX 產品
- 某些市場狀態下的成長股 + 價值股

為投資組合多元化評級:A/B/C/D/F

5. 風險評分卡 (0-100)

生成單一風險分數:

risk_scorecard:
  concentration_risk:
    weight: 20
    score: X  # 100 = 高度多元化,0 = 單一股票
    details: "最大持倉為 X%,代表 X 個行業"

  volatility_risk:
    weight: 20
    score: X  # 100 = 低波動,0 = 極度波動
    details: "投資組合年化波動率:X%"

  drawdown_risk:
    weight: 20
    score: X  # 100 = 最小回撤風險敞口,0 = 可能損失 50%+
    details: "最大估計回撤:X%"

  liquidity_risk:
    weight: 15
    score: X  # 100 = 全部高度流動,0 = 流動性差的持倉
    details: "X% 在流動性高的大型股,X% 在流動性差的資產"

  income_resilience:
    weight: 10
    score: X  # 100 = 強勁收入,0 = 無收益
    details: "投資組合收益率:X%,X% 來自可靠股息支付者"

  market_sensitivity:
    weight: 15
    score: X  # 100 = 低 Beta/防禦型,0 = 高度積極
    details: "投資組合 Beta:X.XX"

  overall_score: X/100
  rating: "[保守型|穩健型|積極型|投機型]"
  recommendation: "[關鍵行動項目]"

分數解讀

  • 80-100:穩固堡壘 — 保護良好,可能過於保守不利於成長
  • 60-79:穩健 — 良好的風險管理,可能還有小幅改進空間
  • 40-59:中等 — 合理,但存在顯著風險敞口
  • 20-39:偏高 — 有重大弱點,建議再平衡
  • 0-19:危險區 — 極度集中或波動,需要緊急行動

6. 監控與警報

每日檢查模板(用於 cron/心跳監控)

對於投資組合中的每個持倉:
1. 檢查價格與前收盤價的差異(網路搜尋)
2. 若有任何持倉單日變動 >3%,則標記
3. 若有任何持倉觸及停損水準,則標記
4. 檢查未來 7 天內的財報/事件

警報閾值:
- 單一持倉單日 -5% → 警報
- 投資組合單日 -3% → 警報
- 持倉觸及 52 週低點 → 關注
- VIX > 25 → 提高警覺
- VIX > 35 → 高度警報 — 檢視對沖策略

每週檢視模板

## 投資組合每週檢視 — [日期]

### 績效
- 投資組合價值:$XX,XXX(每週變動 ±X.X%)
- 最佳表現: [代碼] +X.X%
- 最差表現: [代碼] -X.X%
- 與標普 500 比較: [跑贏/跑輸] X.X%

### 風險變化
- VaR 變動:$X,XXX → $X,XXX
- 出現任何新的集中度問題?[是/否]
- 需要再平衡嗎?[是/否]

### 即將發生的事件
- 財報: [代碼和日期]
- 除息日: [代碼和日期]
- 聯準會/宏觀事件: [清單]

### 行動項目
1. [具體建議]
2. [具體建議]

7. 稅損收割掃描器

對於每個有未實現損失的持倉:
1. 計算未實現損失:(當前價格 - 平均成本) × 股數
2. 檢查損失是否 >$500(值得進行收割)
3. 識別稅務效率高的替換標的:
   - 同一行業 ETF(避免洗售)
   - 類似因子風險敞口
   - 持有替換標的 31 天以上再換回

報告:
| 代碼 | 未實現損失 | 替換標的 | 洗售解除日期 |
|--------|----------------|-------------|---------------------|
| XYZ    | -$2,500        | 類似 ETF | [日期 + 31 天]   |

估計稅務節省:$X,XXX(按 X% 邊際稅率)

8. 特殊資產類別

加密貨幣投資組合風險

加密貨幣特定的額外指標:

  • 比特幣主導地位相關性
  • 交易所風險(中心化 vs 自我保管)
  • DeFi 部位的協議風險
  • 穩定幣曝險與脫鉤風險
  • 質押/收益的稅務影響

房地產 (REITs/物業)

  • FFO 收益率 vs 股息收益率
  • 利率敏感性
  • 地理集中度
  • 物業類型多樣化(住宅/商業/工業)

期權持倉

如果投資組合包含期權:

  • Delta 曝險(相當於股票部位)
  • Theta 衰減(每日時間價值損失)
  • 隱含波動率 vs 歷史波動率
  • 最大損失計算

Individual skills in this repo

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

modbender/skill-library-mcp

Paid acquisition strategy, budget allocation, and avoiding common advertising mistakes across platforms

modbender/skill-library-mcp

Borrow from Aave via credit delegation. Agent self-funds by borrowing against delegator collateral. Supports borrow, repay, health checks. Works on Aave V2/V3.

modbender/skill-library-mcp

Discover and register autonomous AI agents. Use when: browsing the agent registry, submitting an agent for verification, or embedding agent badges. NOT for: general web search or agent capability analysis.

modbender/skill-library-mcp

Create AI avatar and talking head videos with OmniHuman, Fabric, PixVerse via inference.sh CLI. Models: OmniHuman 1.5, OmniHuman 1.0, Fabric 1.0, PixVerse Lipsync. Capabilities: audio-driven avatars, lipsync videos, talking head generation, virtual presenters. Use for: AI presenters, explainer videos, virtual influencers, dubbing, marketing videos. Triggers: ai avatar, talking head, lipsync, avatar video, virtual presenter, ai spokesperson, audio driven video, heygen alternative, synthesia alternative, talking avatar, lip sync, video avatar, ai presenter, digital human

modbender/skill-library-mcp

AI代码编辑器规则模板集合 - 为Cursor、Windsurf、Claude Code、Cline等AI编辑器提供项目规则配置。适用于需要配置AI编码助手规则的开发者,包含全栈Web、移动端、Vue3+SpringBoot等技术栈模板。

modbender/skill-library-mcp

Generate landing page code from product descriptions

modbender/skill-library-mcp

Create AI marketing videos for ads, promos, product launches, and brand content. Models: Veo, Seedance, Wan, FLUX for visuals, Kokoro for voiceover. Types: product demos, testimonials, explainers, social ads, brand videos. Use for: Facebook ads, YouTube ads, product launches, brand awareness. Triggers: marketing video, ad video, promo video, commercial, brand video, product video, explainer video, ad creative, video ad, facebook ad video, youtube ad, instagram ad, tiktok ad, promotional video, launch video

modbender/skill-library-mcp

Generate AI music videos end-to-end. Creates music with Suno (sunoapi.org), generates visuals with OpenAI/Seedream/Google/Seedance, and assembles into music video with ffmpeg. Supports timestamped lyrics (auto SRT), Suno native music video generation, slideshow/video/hybrid modes. Token-based cost tracking per generation.

modbender/skill-library-mcp

Generate AI-powered notes from videos (document, outline, or graphic-text formats)

modbender/skill-library-mcp

The video AI notes tool is provided by Baidu. Based on the video download address provided by the user, it downloads and parses the video, and finally generates AI notes corresponding to the video (a total of three types of notes can be generated: document notes, outline notes, and image-text notes).

modbender/skill-library-mcp

Automated appointment management for beauty salons, clinics, studios, and photo booths. Handles booking requests, calendar sync, conflict detection, reminders, no-show tracking, and waitlist management.

modbender/skill-library-mcp

Bird identification, life list tracking, and trading card generation. Use this skill when the user: sends a bird photo to identify, says "set up my Birdfolio" or "set my region", asks "how's my checklist", asks "Birdfolio progress", asks "how many birds have I found", asks "show my Birdfolio" or "show my life list", asks "what's my rarest bird", or asks "tell me about [bird species]". Handles everything from first-time setup through ongoing life list tracking and visual trading card generation.

modbender/skill-library-mcp

Multi-project task and research management (JSON-first CLI)

modbender/skill-library-mcp

Track stock and crypto portfolios with CLI - real-time prices, P&L, dividend tracking, multiple portfolios

modbender/skill-library-mcp

Track cryptocurrency portfolios with real-time prices, P&L calculations, and allocation analysis. Query Bitcoin, Ethereum, Solana and 10,000+ token holdings.

modbender/skill-library-mcp

加密貨幣Portfolio追蹤 - 支援TRON/ETH/BSC,分析持倉、收益、Gas費用

modbender/skill-library-mcp

Lead strategy with competitive analysis, strategic planning, growth roadmaps, and business portfolio management.

modbender/skill-library-mcp

Create ATS-optimized resumes and CVs with proper structure, metrics, and industry targeting.

modbender/skill-library-mcp

Use this skill when the user asks to build, create, design, develop, or improve ANY frontend interface, web page, UI component, or visual element. This includes: - Building landing pages, websites, web apps, dashboards, portfolios, or any web interface - Creating UI components (buttons, forms, cards, navbars, modals, etc.) - Designing pages with React, Vue, Next.js, Svelte, or any frontend framework - Adding styling or improving visual design of existing components - Implementing specific design aesthetics (modern, dark, minimalist, brutalist, etc.) - User mentions "frontend", "UI", "UX", "design", "interface", "web design", or "styling" - User asks for "beautiful", "modern", "professional", "clean", or any aesthetic adjective - User requests help with CSS, Tailwind, styled-components, or any styling approach This skill automatically retrieves the appropriate design system prompt (Neo-brutalism, Modern Dark, Bauhaus, Cyberpunk, Material, etc.) to help create visually distinctive, production-grade frontend...

modbender/skill-library-mcp

Native video analysis using Google Gemini API. Upload and analyze video files — describe scenes, extract text/UI, answer questions about content, transcribe speech, identify objects and actions. Use when: (1) User sends a video file and wants it analyzed, (2) Video summarization or description needed, (3) Extracting text, UI elements, or information from screen recordings, (4) Answering questions about video content, (5) Comparing multiple videos, (6) Analyzing tutorials, demos, or walkthroughs.

相關技能