From stock-deep-analyzer
Analyzes a portfolio for drift, generates a trade list with estimated turnover costs, and checks concentration changes. Supports A/HK/US markets with market-specific cost models.
How this command is triggered — by the user, by Claude, or both
Slash command
/stock-deep-analyzer:rebalanceThe summary Claude sees in its command listing — used to decide when to auto-load this command
# /rebalance <持仓> [targets=等权] [threshold=5]
对一个组合做**再平衡分析**:当前权重偏离目标多少、要不要动、动的话买卖什么、换手要花多少钱。
A 股个人无资本利得税 → **不做税损收割 (TLH)**,聚焦 **漂移 + 风险 + 换手成本**。
(持仓含美股时,会一句话提示"美股部分可另议税损"。)
## 输入
持仓列表 `[{ticker, weight, market, industry?, value?, price?}]`,与 `--portfolio` 的 CSV 结构同源(ticker / weight / note):
| 字段 | 必填 | 说明 |
|---|---|---|
| `ticker` | ✅ | `600519.SH` / `00700.HK` / `AAPL` |
| `weight` | ✅ | 当前权重,0-1 小数或 0-100 百分数(自动归一化) |
| `market` | 选 | `A` / `HK` / `US`,缺省按 ticker 后缀推断 |
| `industry` | 选 | 行业,用于行业分散度 |
| `value` | 选 | 该持仓市值(给了才能算金额/成本) |
| `price` | 选 | 现价(给了才能估股数,A 股按手取整) |
- **...对一个组合做再平衡分析:当前权重偏离目标多少、要不要动、动的话买卖什么、换手要花多少钱。
A 股个人无资本利得税 → 不做税损收割 (TLH),聚焦 漂移 + 风险 + 换手成本。 (持仓含美股时,会一句话提示"美股部分可另议税损"。)
持仓列表 [{ticker, weight, market, industry?, value?, price?}],与 --portfolio 的 CSV 结构同源(ticker / weight / note):
| 字段 | 必填 | 说明 |
|---|---|---|
ticker | ✅ | 600519.SH / 00700.HK / AAPL |
weight | ✅ | 当前权重,0-1 小数或 0-100 百分数(自动归一化) |
market | 选 | A / HK / US,缺省按 ticker 后缀推断 |
industry | 选 | 行业,用于行业分散度 |
value | 选 | 该持仓市值(给了才能算金额/成本) |
price | 选 | 现价(给了才能估股数,A 股按手取整) |
None → 等权 (1/N);或 {ticker: 目标权重} 显式目标。from lib.tier1.rebalance import build_rebalance
out = build_rebalance(holdings, targets=None, drift_threshold=5.0)
# out = {drift_table, trades, turnover_cost, concentration, summary, methodology_log}
配合已有 --portfolio:先 python run.py --portfolio holdings.csv 跑组合体检,
再把同一份 holdings 喂给 build_rebalance 做调仓建议。
drift_table — 每只 当前 vs 目标 vs 漂移(pp) + 是否超阈值 + 方向(超配→卖/低配→买)summary.any_breach / n_breached / max_drift_pp — 默认 >5pp 才触发trades — 仅对超阈值持仓:BUY/SELL + 金额 + 估算股数(A 股按手)turnover_cost — 分市场拆解:
concentration — 前 3 大集中度 / 最大单只 / HHI / 行业分散 的 前→后 对比value/price 时只出漂移方向,不估金额与成本。改编自
anthropics/financial-serviceswealth-management/portfolio-rebalance,A 股适配。 方法论详见skills/deep-analysis/references/fin-methods/rebalance.md。
npx claudepluginhub wbh604/uzi-skill --plugin stock-deep-analyzer/rebalanceAnalyzes portfolio allocation drift and generates tax-aware rebalancing trades for a specified client or account.
/portfolio-analysisAnalyzes crypto portfolio positions for allocation, diversification, risk metrics (Sharpe ratio, volatility, max drawdown, VaR), correlations, performance, and rebalancing recommendations.
/tax-loss-harvestIdentifies tax-loss harvesting opportunities from a client portfolio, estimates federal and state tax savings, and flags wash-sale risks across all account types including IRAs.
/backtestCombines factors from a library into a composite signal, then runs a quintile-backtest with transaction costs, fitting weights on train and scoring on test. Reports long-short return net of turnover costs.
/review-fi-portfolioReviews fixed income portfolio: prices bonds, fetches reference data and cashflows, runs scenario analysis, produces risk/return report with breakdowns.
/track-walletTracks crypto wallets across Ethereum, Bitcoin, Solana, Polygon, BSC, and more; shows real-time balances, DeFi positions, NFT holdings, P&L, transaction history, and analytics.