risk-portfolio-manager
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRisk Portfolio Manager - AI-Driven Risk Control
投资组合风险管理器 - AI驱动的风险控制
Systematic risk management layer that sits between signal generation and trade execution. Uses data-driven approaches to optimize position sizing, manage portfolio risk, and automate defensive actions.
位于信号生成与交易执行之间的系统化风险管理层。采用数据驱动方法优化头寸规模、管理投资组合风险并自动化执行防御操作。
Core Principle
核心原则
Position sizing and risk management determine long-term survival. No single trade should threaten the portfolio.
头寸规模与风险管理决定长期生存能力。任何单笔交易都不应威胁整个投资组合的安全。
Activation Triggers
触发条件
<triggers>
- "Size this position"
- "What's my portfolio risk?"
- "Rebalance my holdings"
- "Calculate VaR"
- "Should I take profit?"
- "Set up risk limits"
- "Portfolio correlation check"
- "Daily loss limit"
- Keywords: position size, risk management, portfolio, allocation, drawdown, VaR, Sharpe, rebalance, stop loss, take profit, correlation, diversification
</triggers>
<triggers>
- "调整该头寸规模"
- "我的投资组合风险如何?"
- "重新平衡我的持仓"
- "计算VaR"
- "我应该止盈吗?"
- "设置风险限额"
- "投资组合相关性检查"
- "每日亏损限额"
- 关键词:position size、risk management、portfolio、allocation、drawdown、VaR、Sharpe、rebalance、stop loss、take profit、correlation、diversification
</triggers>
Core Capabilities
核心能力
1. Position Sizing Engine
1. 头寸规模计算引擎
<position_sizing>
Sizing Methods:
typescript
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[];
}Kelly Criterion (Modified):
Optimal Size = (Win Rate * Avg Win - (1 - Win Rate) * Avg Loss) / Avg Win
Adjusted Size = Kelly * Fractional Multiplier (0.25-0.5 for safety)Risk-Adjusted Sizing Matrix:
| Risk Tolerance | Base Size | Max Single Position | Max Correlated Exposure |
|---|---|---|---|
| Conservative | 0.5-1% | 2% | 5% |
| Moderate | 1-2% | 4% | 10% |
| Degen | 2-5% | 10% | 25% |
Signal-Based Adjustments:
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)Output Format:
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>
<position_sizing>
规模计算方法:
typescript
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 (弱到强)
- Token Risk: 1-10 (数值越低越安全)
- Market Multiplier: 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. Portfolio Risk Metrics
2. 投资组合风险指标
<risk_metrics>
Real-Time Portfolio Dashboard:
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%Risk Calculations:
typescript
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>
<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%(处于历史新高)
├─ Sharpe比率(30天): 2.14
├─ Sortino比率: 2.87
├─ 相对于SOL的Beta值: 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) - 符合限额
├─ 前3大持仓: 72.5% - 偏高
├─ 赫芬达尔指数: 0.23 - 中等
└─ Meme代币暴露: 63% - 偏高
警报:
⚠️ MEME与WIF相关性较高(0.85)
⚠️ Meme板块集中度超过50%风险计算方法:
typescript
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. Dynamic Rebalancing
3. 动态再平衡
<rebalancing>
**Rebalancing Triggers:**
- Drift > 5% from target allocation
- Single position > max limit
- Correlation spike > 0.9 between positions
- Sector concentration > threshold
- Weekly scheduled review
</rebalancing>
Target Allocation Framework:
typescript
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 Output:
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)<rebalancing>
**再平衡触发条件:**
- 与目标配置偏差>5%
- 单一头寸超过上限
- 头寸间相关性飙升>0.9
- 板块集中度超过阈值
- 每周定期审查
</rebalancing>
目标配置框架:
typescript
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
Memes | 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%)
├─ Memes: 48%(目标:50%)
├─ 稳定币:21%(目标:20%)
└─ VaR降低: -18%(风险状况改善)4. Automated Defensive Actions
4. 自动化防御操作
<defensive_actions>
Kill Switch System:
typescript
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
};Triggered Actions:
| Trigger | Action | Severity |
|---|---|---|
| Position -25% | Stop-loss warning | MEDIUM |
| Position -30% | Auto-close (if enabled) | HIGH |
| Daily -10% | Halt new trades | HIGH |
| Weekly -20% | Exit to stables | CRITICAL |
| Drawdown -25% | Emergency liquidation | CRITICAL |
| Correlation > 0.95 | Reduce one position | MEDIUM |
Alert Output:
🚨 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>
<defensive_actions>
止损开关系统:
typescript
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
5. 场景分析
<scenario_analysis>
Stress Testing:
typescript
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 Output:
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>
<scenario_analysis>
压力测试:
typescript
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: '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暴露,或减少10-15%的Meme配置以改善风险状况。</scenario_analysis>
Integration Points
集成点
<integrations>
**Risk Manager receives from:**
- **meme-trader**: Signal strength, token risk scores
- **meme-executor**: Current positions, entry prices
- **flow-tracker**: Whale movements, liquidity data
- **data-orchestrator**: Validated price data, quality scores
- **llama-analyst**: Protocol fundamentals, TVL trends
Risk Manager provides to:
- meme-executor: Approved position sizes, stop-loss levels
- meme-trader: Position limits, available capital
- All skills: Portfolio state, risk alerts
<integrations>
**风险管理器接收来自:**
- **meme-trader**: 信号强度、代币风险评分
- **meme-executor**: 当前头寸、入场价格
- **flow-tracker**: 大额资金动向、流动性数据
- **data-orchestrator**: 验证后的价格数据、质量评分
- **llama-analyst**: 协议基本面、TVL趋势
风险管理器输出至:
- meme-executor: 批准的头寸规模、止损水平
- meme-trader: 头寸限额、可用资金
- 所有技能: 投资组合状态、风险警报
CLI Usage
CLI使用方法
bash
undefinedbash
undefinedCalculate 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
--signal 8
--risk-score 4
--portfolio-file ./portfolio.json
--risk-mode moderate
npx tsx .claude/skills/risk-portfolio-manager/scripts/position-sizer.ts
--signal 8
--risk-score 4
--portfolio-file ./portfolio.json
--risk-mode moderate
--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
--portfolio-file ./portfolio.json
--include-correlation
--var-confidence 95
npx tsx .claude/skills/risk-portfolio-manager/scripts/risk-metrics.ts
--portfolio-file ./portfolio.json
--include-correlation
--var-confidence 95
--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
--portfolio-file ./portfolio.json
--target-allocation ./targets.json
--threshold 5
npx tsx .claude/skills/risk-portfolio-manager/scripts/rebalancer.ts
--portfolio-file ./portfolio.json
--target-allocation ./targets.json
--threshold 5
--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
--portfolio-file ./portfolio.json
--scenarios default
--output-format detailed
npx tsx .claude/skills/risk-portfolio-manager/scripts/stress-test.ts
--portfolio-file ./portfolio.json
--scenarios default
--output-format detailed
--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
--portfolio-file ./portfolio.json
--check-status
undefinednpx tsx .claude/skills/risk-portfolio-manager/scripts/kill-switch.ts
--portfolio-file ./portfolio.json
--check-status
--portfolio-file ./portfolio.json
--check-status
undefinedQuality Gates
质量校验规则
<validation_rules>
- Position sizing requires quality score >= 85% on price data
- VaR calculations require 30+ days of clean historical data
- Correlation matrix requires synchronized price data
- All recommendations include confidence levels
- No position sizing without rug detection check </validation_rules>
<validation_rules>
- 头寸规模计算要求价格数据质量评分≥85%
- VaR计算需要30天以上的有效历史数据
- 相关性矩阵需要同步的价格数据
- 所有建议需包含置信水平
- 未完成rug detection检查不得进行头寸规模计算 </validation_rules>
Error Handling
错误处理
<error_recovery>
- Missing price data: Use last known + stale warning
- Calculation error: Conservative fallback (minimum size)
- Kill switch conflict: Safety wins (halt > continue)
- Data quality insufficient: Reject sizing, request refresh </error_recovery>
<see_also>
- references/risk-models.md - Mathematical formulas
- references/allocation-templates.md - Target portfolios
- scripts/position-sizer.ts - Sizing engine
- scripts/risk-metrics.ts - Risk calculations
- scripts/kill-switch.ts - Automated safety </see_also>
<error_recovery>
- 缺失价格数据:使用最新已知数据并标注过期警告
- 计算错误:采用保守 fallback(最小规模)
- 止损开关冲突:安全优先(暂停>继续)
- 数据质量不足:拒绝规模计算,请求刷新数据 </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>