Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 95 additions & 13 deletions .claude/skills/haoinvest/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,39 @@ All-in-one investment management via CLI + Claude Code agent. CLI does data + co
4. Point out weak areas and suggest what else to check
5. If data is missing (e.g., financial health = N/A), say so honestly

### Workflow 2: "我有闲钱想投资" — Investment direction
### Workflow 2: "我有闲钱想投资" — Stock discovery & screening

1. Check current portfolio:
参考: `.claude/skills/haoinvest/references/stock-screening-workflow.md`

1. Check current portfolio to identify sector gaps:
```bash
uv run haoinvest portfolio list
```
2. Identify concentration: which sectors are overweight?
3. Scan sector rankings:
2. Judge market environment (use web search if needed for policy/macro context)
3. Scan sector rankings + capital flow:
```bash
uv run haoinvest market sector-list
uv run haoinvest market sector-flow # beta, may fail
uv run haoinvest market sector-flow --type concept # concept boards
```
4. Based on user profile + market environment, select screening strategy
(参考 `stock-screening-workflow.md` 中的预置策略: 价值型/成长型/高分红型/防御型):
```bash
uv run haoinvest market screen --roe-min 15 --pe-max 20 --cap-min 10e9
```
4. Drill into promising sectors:
5. Drill into promising sectors:
```bash
uv run haoinvest market sector <板块名>
```
5. Run reports on 2-3 candidates from underrepresented sectors
6. Explain WHY each candidate diversifies the portfolio
6. Run deep analysis on top 3-5 candidates:
```bash
uv run haoinvest analyze run <sym1>,<sym2>,<sym3> --modules fundamental,risk,peer
```
7. Rank candidates considering: 持仓互补性 + 估值 + 成长性 + 风险
8. Save research to Obsidian vault:
```bash
obsidian vault=".haoinvest/vault" create path="个股/<symbol>-<name>.md" content="..." silent
```

### Workflow 3: "我想买/卖 XXX" — Pre-Trade Review (5维度审查)

Expand Down Expand Up @@ -75,12 +91,22 @@ All-in-one investment management via CLI + Claude Code agent. CLI does data + co

4. **隐式情绪检测** (见 Workflow 3b)

5. If proceeding, suggest recording journal:
5. If proceeding with a BUY, record investment thesis:
```bash
uv run haoinvest portfolio thesis add <symbol> <price> "<买入理由>" \
--assumptions '["假设1", "假设2"]' --target <目标价> --stop-loss <止损价>
```
And suggest recording journal:
```bash
uv run haoinvest journal add "<决策理由>" --decision buy --emotion <detected> --symbols <symbol>
```

6. Always remind: **这不是投资建议,最终决定需要你自己判断**
6. Save analysis to Obsidian vault:
```bash
obsidian vault=".haoinvest/vault" create path="个股/<symbol>-<name>.md" content="..." silent
```

7. Always remind: **这不是投资建议,最终决定需要你自己判断**

### Workflow 3b: 隐式情绪检测 (每次交易讨论时自动执行)

Expand Down Expand Up @@ -137,21 +163,40 @@ All-in-one investment management via CLI + Claude Code agent. CLI does data + co

### Workflow 5: "定期体检" — Portfolio checkup

参考: `.claude/skills/haoinvest/references/position-management.md`

1. Portfolio holdings + P&L:
```bash
uv run haoinvest portfolio list
uv run haoinvest portfolio returns
```
2. Risk assessment:
2. Check guardrails alerts + thesis review status:
```bash
uv run haoinvest guardrails alerts --json
uv run haoinvest portfolio thesis list
```
3. For theses overdue for review, run analysis to check assumptions:
```bash
uv run haoinvest analyze run <symbol> --modules fundamental,risk,signals
```
Compare current data against thesis key_assumptions.
Mark reviewed after analysis:
```bash
uv run haoinvest portfolio thesis review <thesis_id>
```
4. Risk assessment:
```bash
uv run haoinvest analyze risk
```
3. For each holding with poor risk metrics, run a quick report
4. Check allocation via:
5. Check allocation and suggest rebalancing:
```bash
uv run haoinvest strategy optimize
```
5. Suggest rebalancing if needed
6. Search for prior research in Obsidian vault:
```bash
obsidian vault=".haoinvest/vault" search query="<symbol>" path="个股" limit=5
```
7. Append checkup results to vault notes

### Workflow 6: "情绪复盘" — Decision review

Expand All @@ -171,6 +216,8 @@ uv run haoinvest market quote <symbol(s)> # Price + info (b
uv run haoinvest market history <symbol> [--start] [--end] # OHLCV bars (30 days default)
uv run haoinvest market sector-list # A-share industry board ranking
uv run haoinvest market sector <name> # Sector constituents
uv run haoinvest market screen [--pe-max] [--roe-min] [--cap-min] [--div-min] [--sort] [--limit] # Stock screening
uv run haoinvest market sector-flow [--type industry|concept] [--limit] # Sector capital flow (beta)
```

### Analysis
Expand Down Expand Up @@ -200,6 +247,16 @@ uv run haoinvest portfolio returns [--symbol <sym>] # P&L
```
Actions: `buy`, `sell`, `dividend`, `split`, `transfer_in`, `transfer_out`

### Thesis
```bash
uv run haoinvest portfolio thesis add <symbol> <price> "<理由>" [--assumptions '["..."]'] [--target] [--stop-loss]
uv run haoinvest portfolio thesis list [--symbol] [--status active|invalidated|realized]
uv run haoinvest portfolio thesis show <id> # Full thesis details
uv run haoinvest portfolio thesis review <id> # Mark reviewed (resets timer)
uv run haoinvest portfolio thesis invalidate <id> "<reason>" # Mark invalidated
uv run haoinvest portfolio thesis realize <id> # Mark realized
```

### Strategy
```bash
uv run haoinvest strategy optimize [--method equal_weight|risk_parity|min_volatility|max_sharpe]
Expand Down Expand Up @@ -243,6 +300,31 @@ For crypto prices, **prefer Crypto.com MCP tools** when available:

Fall back to CLI if MCP is unavailable.

### Obsidian Vault (Research Knowledge Base)

Vault location: `.haoinvest/vault/` (relative to project root)

Use the `obsidian-cli` skill for all vault operations:
```bash
obsidian vault=".haoinvest/vault" search query="<keyword>" limit=5 # Search notes
obsidian vault=".haoinvest/vault" read path="个股/600519-贵州茅台.md" # Read note
obsidian vault=".haoinvest/vault" create path="个股/<sym>-<name>.md" content="..." silent # New note
obsidian vault=".haoinvest/vault" append path="个股/<sym>-<name>.md" content="## <date> 分析\n..." # Add to existing
```

Directory structure: `个股/` (stock analysis), `行业/` (sector research), `政策/` (policy notes), `模板/` (templates).
Use Obsidian wikilinks for cross-references: `[[白酒行业]]`, `[[600519-贵州茅台]]`.

### Reference Files

Analysis frameworks are in `.claude/skills/haoinvest/references/`:
- `a-share-analysis-framework.md` — 5-dimension A-share analysis framework
- `valuation-guide.md` — Relative valuation methods by industry
- `position-management.md` — Add/reduce/rotate decision framework
- `stock-screening-workflow.md` — Top-down screening with preset strategies

Refer to these when interpreting analysis results or guiding investment decisions.

## Teaching Mode

When explaining metrics, always:
Expand Down
78 changes: 78 additions & 0 deletions .claude/skills/haoinvest/references/a-share-analysis-framework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# A 股分析框架

A 股市场与美股/港股存在结构性差异:散户贡献约 87% 交易量,短期受政策和叙事驱动,长期价值因子有效。分析需覆盖以下 5 个维度。

## 1. 基本面(长期核心)

**权重**:选股时最重要,择时时次之。

**关注指标**:
- **盈利能力**:ROE(与同行比)、净利润率、毛利率趋势
- **成长性**:营收同比增长、净利润同比增长、连续几个季度的趋势方向
- **估值**:参考 `valuation-guide.md`
- **财务健康**:负债率、现金流、股息率

**判断方法**:
- 不要用绝对阈值判断好坏,要与**同行业**对比(peer 分析)
- 关注**趋势方向**而非单点数值:连续 3 季 ROE 下降比当前 ROE 绝对值低更值得警惕
- 多期数据对比:用 `get_financial_indicators(symbol, periods=8)` 获取历史 8 期

## 2. 政策面(A 股特有,短期权重高)

**为什么重要**:A 股受政策影响极大,国务院/证监会/央行的政策可以直接改变行业景气度。

**分析方法**(通过 web search):
- 近期是否有行业相关政策出台?(产业政策、财政刺激、监管变化)
- 五年规划中的重点方向?
- 是否处于政策收紧/放松周期?

**信号解读**:
- 政策利好 + 估值合理 → 积极关注
- 政策利空 + 估值偏高 → 谨慎回避
- 政策中性 → 回归基本面判断

## 3. 资金面

**关注数据**:
- 板块资金流向:`market sector-flow`(如可用)
- 北向资金持仓变化(季度粒度)
- 板块涨跌排名:`market sector-list`

**判断方法**:
- 主力资金持续流入的板块值得关注
- 资金流入 + 基本面支撑 = 强信号
- 资金流入但基本面不支撑 = 可能是短期炒作,谨慎

## 4. 技术面

**使用 `analyze run <symbol> --modules technical,signals`**

**注意事项**:
- 技术面在 A 股因散户主导有更强的"自我实现"效应
- 技术信号用于**择时**(何时买),不用于**选股**(买什么)
- 多时间框架确认:日线信号需要周线级别支持才可靠

## 5. 情绪面

**来源**:用户对话中的语言信号 + 市场整体情绪

**检测方法**:参考 SKILL.md 中的 Workflow 3b(隐式情绪检测)

**注意**:
- 市场极度恐慌时(大跌 + 恐慌情绪词频高)反而可能是价值买入机会
- 市场极度亢奋时(全民炒股 + FOMO)反而应该更谨慎

## 不同市场阶段的侧重

| 阶段 | 判断依据 | 分析侧重 |
|------|---------|---------|
| 牛市 | 指数持续上涨,成交量放大 | 重基本面选股 + 技术面择时,警惕过热 |
| 熊市 | 指数持续下跌,情绪低迷 | 重基本面安全边际,耐心等待,不急于抄底 |
| 震荡市 | 指数区间波动 | 重资金面和技术面,关注板块轮动 |

## 综合判断原则

1. **至少 3 个维度指向同一方向**才形成强信号
2. **基本面是底线**——短期可以不完美,但长期必须有支撑
3. **政策面可以加速但不能替代基本面**——纯政策炒作的股票在政策退潮后会回归
4. **永远标注不确定性**——说清楚哪些判断是数据支撑的,哪些是推测
73 changes: 73 additions & 0 deletions .claude/skills/haoinvest/references/position-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 持仓管理决策框架

## 核心理念

每笔持仓都有一个 **thesis**(投资逻辑)。所有加仓/减仓/换仓决策都围绕 thesis 展开:
- thesis 仍成立 + 价格更便宜 → 考虑加仓
- thesis 部分弱化 + 估值偏高 → 考虑减仓
- thesis 被打破 → 考虑清仓或换仓

## 加仓决策

### 前提条件(全部满足才考虑)
1. 原始 thesis 仍然成立(核心假设未被打破)
2. 估值比买入时更便宜或至少没有变贵
3. 仓位加仓后不违反 guardrails(单只 ≤15%,行业 ≤35%)
4. 不是出于"摊低成本"的心理(沉没成本谬误)

### 数据检查清单
```bash
uv run haoinvest analyze run <symbol> --modules fundamental,risk,signals
uv run haoinvest guardrails pre-trade-data <symbol> buy <qty> -m a_share
uv run haoinvest portfolio thesis review <symbol>
```

### 判断逻辑
- 基本面未恶化 + 估值更低 + 仓位安全 → **可以加仓**
- 基本面未恶化但估值未变 → **不急,等更好的价格**
- 基本面有恶化迹象 → **不加仓,重新审视 thesis**

## 减仓决策

### 触发信号
1. **估值过高**:PE/PB 显著高于行业中位数(peer 对比中处于前 10%)
2. **thesis 部分弱化**:核心假设中有 1-2 个不再成立,但整体逻辑未完全崩塌
3. **技术面背离**:价格创新高但量能萎缩,或出现明显顶部形态
4. **guardrails 触发**:浮盈超过 gain_review_threshold(默认 +30%)

### 减仓策略
- **分批减仓**:先减 20-30%,观察后续走势
- **保留底仓**:如果 thesis 未被打破,保留 50% 以上仓位
- **记录决策**:减仓后用 journal 记录理由和情绪

## 换仓决策

### 触发信号
1. **thesis 被打破**:核心假设失效(行业变化、公司暴雷、竞争格局改变)
2. **更优机会出现**:发现估值更低、基本面更好、且能改善组合分散度的标的
3. **行业轮动**:政策方向转变,原持仓行业前景显著恶化

### 换仓流程
1. 确认现有持仓 thesis 确实被打破(不是短期波动)
2. 新标的必须通过完整的 5 维度分析
3. 新标的的预期收益 > 现有持仓 + 交易成本
4. 不要同时大比例换仓——分批执行

## 不行动也是决策

**持有不动的条件**:
- thesis 完好
- 估值合理(不贵也不便宜)
- 技术面中性
- 没有更好的替代机会

**不要因为"持有太久没动静"就换仓** — 价值投资需要耐心。

## 情绪检查

每次做加仓/减仓/换仓决策前,问自己:
- 我是因为**数据和逻辑**在做决策,还是因为**情绪**?
- 如果这只股票我没有持仓,以当前价格我还会买吗?
- 我是否在追涨(FOMO)或杀跌(恐慌)?

如果对情绪不确定 → 等待 24 小时再决策。
Loading
Loading