risk-portfolio-manager について
risk-portfolio-managerは、暗号資産取引でシグナル生成と取引実行の間に置くリスク管理スキルです。ポジションサイズ、ポートフォリオリスク、リバランス、防御措置を分析し、信頼度付きの提案を行います。
主な機能
- 01シグナルとリスクに基づくポジション調整
- 02VaR、CVaR、シャープレシオの算出
- 03配分のずれ検出とリバランス提案
- 04損失上限と防御措置の設定
- 05ストレスシナリオ分析
活用シーン
- 01市場状況とリスク許容度に応じたポジション決定
- 02ポートフォリオのVaRと資産相関の確認
- 03日次損失上限とストップロス措置の設定
- 04市場ショック時のポートフォリオ変化の評価
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ dreamineering/ meme-times --skill risk-portfolio-managerインストール後、Claude Code で/risk-portfolio-managerを入力して読み込まれたか確認します。
詳細
リスクポートフォリオマネージャー - AI 主導のリスク管理
シグナル生成と取引実行の間に位置する、体系的なリスク管理レイヤーです。データ主導のアプローチを使用して、ポジションサイズを最適化し、ポートフォリオリスクを管理し、防御措置を自動化します。
基本原則
ポジションサイズとリスク管理が、長期的に生き残れるかどうかを左右します。1 回の取引でポートフォリオを危険にさらしてはなりません。
起動トリガー
- 「このポジションのサイズを決めて」 - 「ポートフォリオのリスクはどれくらい?」 - 「保有資産をリバランスして」 - 「VaR を計算して」 - 「利益確定すべき?」 - 「リスク制限を設定して」 - 「ポートフォリオの相関を確認して」 - 「1 日あたりの損失上限」 - キーワード:ポジションサイズ、リスク管理、ポートフォリオ、配分、ドローダウン、VaR、シャープレシオ、リバランス、ストップロス、利益確定、相関、分散投資主な機能
1. ポジションサイズ設定エンジン
<position_sizing> サイズ設定方法:
interface PositionSizeRequest {
signal_strength: number; // 0-1 from meme-trader
token_risk_score: number; // 1-10 from rug detection
current_portfolio: Portfolio;
market_regime: 'bull' | 'bear' | 'sideways' | 'volatile';
risk_tolerance: 'conservative' | 'moderate' | 'degen';
}
interface PositionSizeResult {
recommended_size_pct: number; // % of portfolio
recommended_size_usd: number;
max_allowed_size: number;
reasoning: string[];
risk_warnings: string[];
}
ケリー基準(修正版):
Optimal Size = (Win Rate * Avg Win - (1 - Win Rate) * Avg Loss) / Avg Win
Adjusted Size = Kelly * Fractional Multiplier (0.25-0.5 for safety)
リスク許容度別サイズ設定マトリックス:
| リスク許容度 | 基本サイズ | 単一ポジションの上限 | 相関のあるエクスポージャーの上限 |
|---|---|---|---|
| 保守的 | 0.5-1% | 2% | 5% |
| 中程度 | 1-2% | 4% | 10% |
| ハイリスク志向 | 2-5% | 10% | 25% |
シグナルに基づく調整:
Final Size = Base Size * Signal Strength * (1 - Token Risk / 20) * Market Multiplier
Where:
- Signal Strength: 0.5-1.5 (weak to strong)
- Token Risk: 1-10 (lower is safer)
- Market Multiplier: 0.5 (volatile) to 1.2 (trending)
出力形式:
POSITION SIZE RECOMMENDATION
Token: $MEME
Signal Strength: 8/10
Token Risk Score: 4/10
Market Regime: BULL
RECOMMENDED SIZE:
├─ Percentage: 2.3% of portfolio
├─ Amount: $460 (of $20,000 portfolio)
├─ Max Allowed: $800 (4% limit)
└─ Risk-Adjusted: WITHIN LIMITS
REASONING:
1. Strong signal (8/10) supports above-average sizing
2. Low-medium risk token (4/10) allows full allocation
3. Bull market regime permits aggressive sizing
4. No correlation with existing positions
WARNINGS:
- Consider scaling in (3 tranches) vs single entry
- Set stop-loss at -25% ($345 max loss)
</position_sizing>
2. ポートフォリオリスク指標
<risk_metrics> リアルタイムのポートフォリオダッシュボード:
PORTFOLIO RISK DASHBOARD
═══════════════════════════════════════
POSITIONS (5 active):
Token | Size | PnL | Risk | Weight
$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%
───────────────────────────────────────
TOTAL | $20,000 | +$4,790 | | 100%
RISK METRICS:
├─ Daily VaR (95%): -$1,240 (-6.2%)
├─ Max Drawdown (30d): -18.3%
├─ Current Drawdown: 0% (at ATH)
├─ Sharpe Ratio (30d): 2.14
├─ Sortino Ratio: 2.87
├─ Beta to SOL: 1.34
CORRELATION MATRIX:
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
CONCENTRATION RISK:
├─ Top Position: 37% (SOL) - WITHIN LIMIT
├─ Top 3 Positions: 72.5% - HIGH
├─ Herfindahl Index: 0.23 - MODERATE
└─ Meme Exposure: 63% - HIGH
ALERTS:
⚠️ High correlation between MEME and WIF (0.85)
⚠️ Meme sector concentration above 50%
リスク計算:
interface PortfolioRisk {
// Value at Risk
var_95: number; // 95% confidence daily VaR
var_99: number; // 99% confidence daily VaR
cvar_95: number; // Conditional VaR (expected shortfall)
// Performance Risk
sharpe_ratio: number;
sortino_ratio: number;
max_drawdown: number;
current_drawdown: number;
// Correlation Risk
avg_correlation: number;
max_correlation: number;
correlation_cluster: string[]; // Highly correlated groups
// Concentration Risk
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 {
// Historical VaR using past 30 days of returns
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. 動的リバランス
**リバランスのトリガー:** - 目標配分からの乖離が 5% 超 - 単一ポジションが上限を超過 - ポジション間の相関が 0.9 超に急上昇 - セクター集中度がしきい値を超過 - 毎週の定期レビュー目標配分のフレームワーク:
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; // % drift to trigger
}
リバランスの出力:
REBALANCING RECOMMENDATION
Current vs Target Allocation:
Category | Current | Target | Drift | Action
SOL | 37% | 30% | +7% | SELL $1,400
Memes | 63% | 50% | +13% | SELL $2,600
Stables | 0% | 20% | -20% | BUY $4,000
SUGGESTED TRADES:
1. SELL 15% of BONK position ($630) → USDC
2. SELL 20% of WIF position ($500) → USDC
3. SELL 10% of SOL position ($740) → USDC
4. Keep MEME and DOGE positions
5. Convert sales to USDC stablecoin buffer
POST-REBALANCE PROJECTION:
├─ SOL: 31% (target: 30%)
├─ Memes: 48% (target: 50%)
├─ Stables: 21% (target: 20%)
└─ VaR Reduction: -18% (improved risk profile)
4. 防御措置の自動化
<defensive_actions> キルスイッチシステム:
interface KillSwitchConfig {
daily_loss_limit: number; // % of portfolio
weekly_loss_limit: number; // % of portfolio
position_loss_limit: number; // % per position
drawdown_limit: number; // % from peak
correlation_spike_action: 'alert' | 'reduce' | 'exit';
auto_execute: boolean;
}
const defaultKillSwitch: KillSwitchConfig = {
daily_loss_limit: 10, // Halt new trades at -10% day
weekly_loss_limit: 20, // Halt all activity at -20% week
position_loss_limit: 30, // Auto-close position at -30%
drawdown_limit: 25, // Emergency mode at -25% from peak
correlation_spike_action: 'alert',
auto_execute: false, // Require confirmation in Phase 1
};
トリガーされたアクション:
| トリガー | アクション | 重大度 |
|---|---|---|
| ポジション -25% | ストップロス警告 | 中 |
| ポジション -30% | 自動決済(有効な場合) | 高 |
| 1 日 -10% | 新規取引を停止 | 高 |
| 1 週間 -20% | ステーブルコインに退避 | 重大 |
| ドローダウン -25% | 緊急清算 | 重大 |
| 相関 > 0.95 | 1 つのポジションを縮小 | 中 |
アラート出力:
🚨 RISK ALERT: DAILY LOSS LIMIT APPROACHING
Current Day PnL: -8.7% ($-1,740)
Daily Limit: -10% ($-2,000)
Buffer Remaining: $260
TRIGGERED ACTIONS:
1. ⏸️ New trade execution PAUSED
2. ⚠️ Review all open positions
3. 📊 Increased monitoring frequency
RECOMMENDED:
- Review worst performing position (WIF: -15%)
- Consider partial exit if trend continues
- DO NOT average down
Type RESUME to re-enable trading
Type EXIT_ALL to liquidate positions
</defensive_actions>
5. シナリオ分析
<scenario_analysis> ストレステスト:
interface StressScenario {
name: string;
market_move: {
sol: number; // % change
memes: number; // % change vs SOL
correlation_shift: number;
};
probability: number;
}
const stressScenarios: StressScenario[] = [
{
name: 'SOL -30% Flash Crash',
market_move: { sol: -30, memes: -50, correlation_shift: 0.2 },
probability: 0.05,
},
{
name: 'Meme Rotation Out',
market_move: { sol: 0, memes: -40, correlation_shift: -0.1 },
probability: 0.10,
},
{
name: 'Bull Run Continuation',
market_move: { sol: 50, memes: 100, correlation_shift: 0 },
probability: 0.15,
},
{
name: 'Black Swan Event',
market_move: { sol: -60, memes: -80, correlation_shift: 0.3 },
probability: 0.01,
},
];
ストレステストの出力:
STRESS TEST RESULTS
Current Portfolio Value: $20,000
SCENARIO | Portfolio Impact | Probability
SOL -30% Flash Crash | -$7,200 (-36%) | 5%
Meme Rotation Out | -$5,040 (-25%) | 10%
Bull Run Continuation | +$14,600 (+73%) | 15%
Black Swan Event | -$12,400 (-62%) | 1%
EXPECTED PORTFOLIO VALUE:
├─ Base Case: $20,000
├─ Expected (prob-weighted): $22,340 (+11.7%)
├─ Worst Case (99%): -$12,400 (-62%)
└─ VaR (95%, 30d): -$4,800 (-24%)
RISK ASSESSMENT:
⚠️ High sensitivity to meme rotation (-25% scenario)
⚠️ Black swan exposure significant (-62%)
✓ Positive expected value in base scenarios
✓ Bull case upside substantial (+73%)
RECOMMENDATION:
Consider hedging meme exposure with SOL puts or reducing
meme allocation by 10-15% to improve risk profile.
</scenario_analysis>
統合ポイント
**リスクマネージャーが受け取る情報:** - **meme-trader**:シグナルの強度、トークンのリスクスコア - **meme-executor**:現在のポジション、エントリー価格 - **flow-tracker**:クジラの動き、流動性データ - **data-orchestrator**:検証済みの価格データ、品質スコア - **llama-analyst**:プロトコルのファンダメンタルズ、TVL の推移リスクマネージャーが提供する情報:
- meme-executor:承認済みのポジションサイズ、ストップロス水準
- meme-trader:ポジション上限、利用可能資金
- すべてのスキル:ポートフォリオの状態、リスクアラート
CLI の使用方法
# Calculate position size
npx tsx .claude/skills/risk-portfolio-manager/scripts/position-sizer.ts \
--signal 8 \
--risk-score 4 \
--portfolio-file ./portfolio.json \
--risk-mode moderate
# Get portfolio risk metrics
npx tsx .claude/skills/risk-portfolio-manager/scripts/risk-metrics.ts \
--portfolio-file ./portfolio.json \
--include-correlation \
--var-confidence 95
# Rebalancing recommendation
npx tsx .claude/skills/risk-portfolio-manager/scripts/rebalancer.ts \
--portfolio-file ./portfolio.json \
--target-allocation ./targets.json \
--threshold 5
# Run stress tests
npx tsx .claude/skills/risk-portfolio-manager/scripts/stress-test.ts \
--portfolio-file ./portfolio.json \
--scenarios default \
--output-format detailed
# Check kill switch status
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>
コメント
Markdown 対応