个人财务管理。当用户提到财务、记账、import CSV、消费报告、/finance 时触发。
管理 Beancount 财务系统。数据在 ~/Desktop/Notes/Personal/Finance/。
/finance import从 ~/Downloads 自动发现新的银行 CSV,导入到 Beancount。
流程:
~/Downloads 找匹配的 CSV:
Chase*2679*.CSV → CheckingChase*0791*.CSV → SavingsChase*1607*.CSV → Sapphire Preferred (CSP)Chase*3254*.CSV → Freedom UnlimitedChase*9130*.CSV → Freedom FlexAccounts_History*.csv → FidelityFinance/raw/cd ~/Desktop/Notes/Personal/Finance && conda run -n finance python convert_chase.py
conda run -n finance bean-check main.beancount
/finance dashboard)/finance report [month]AI 月度财务分析。默认上个月(完整月),可指定如 2026-02。
数据获取(并行运行 5 个 bean-query):
cd ~/Desktop/Notes/Personal/Finance
# 1. 本月收入明细
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) as total WHERE account ~ 'Income' AND year = YEAR AND month = MONTH GROUP BY account ORDER BY total"
# 2. 本月支出明细
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) as total WHERE account ~ 'Expenses' AND year = YEAR AND month = MONTH GROUP BY account ORDER BY total DESC"
# 3. 上月支出(用于环比)
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) as total WHERE account ~ 'Expenses' AND year = PREV_YEAR AND month = PREV_MONTH GROUP BY account ORDER BY total DESC"
# 4. 本月大额单笔(>$100,不含房租)
conda run -n finance bean-query main.beancount \
"SELECT date, narration, account, position WHERE account ~ 'Expenses' AND NOT account ~ 'Rent' AND number > 100 AND year = YEAR AND month = MONTH ORDER BY number DESC"
# 5. 生活账户余额
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) WHERE account ~ 'Assets:Chase' OR account ~ 'Liabilities:Chase' GROUP BY account"
AI 分析内容(五个板块):
输出到对话中展示,不写入文件。
/finance dashboard更新 Obsidian Dashboard 页面(Finance/Dashboard.md)。
数据获取(并行运行):
cd ~/Desktop/Notes/Personal/Finance
# 1. 账户余额 (bean-query)
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) WHERE account ~ 'Assets:Chase' OR account ~ 'Assets:Cash' OR account ~ 'Assets:BoA' GROUP BY account"
# 2. 本月收支 (bean-query)
conda run -n finance bean-query main.beancount \
"SELECT root(account, 1), sum(convert(position, 'USD')) WHERE (account ~ 'Income' OR account ~ 'Expenses') AND year = YEAR AND month = MONTH GROUP BY root(account, 1)"
# 3. Top 支出分类 (bean-query)
conda run -n finance bean-query main.beancount \
"SELECT account, sum(convert(position, 'USD')) as total WHERE account ~ 'Expenses' AND year = YEAR AND month = MONTH GROUP BY account ORDER BY total DESC LIMIT 10"
# 4. 投资实时价格 (yfinance)
conda run -n finance python investments.py --live --json
# 5. Splitwise 余额
conda run -n finance python splitwise_balance.py --json
投资板块用 --live 的实时数据更新市值、总收益、YTD,标注 Updated: YYYY-MM-DD HH:MM。
收益绿色 <span style="color:#4CAF50">, 亏损红色 <span style="color:#F44336">。
Splitwise 板块用 splitwise_balance.py --json 更新 net 和明细。
写入 Finance/Dashboard.md,格式见下方模板。
/finance fava启动 fava web UI:
conda run -n finance fava ~/Desktop/Notes/Personal/Finance/main.beancount --host 127.0.0.1 --port 5001 &
如果 5001 已被占用,试 5002。告诉用户 URL。
# 💰 Finance Dashboard
> Last updated: {date} by Claude
## Account Balances
| Account | Balance |
|---------|---------|
| Chase Checking (...2679) | $X,XXX |
| Chase Savings (...0791) | $X,XXX |
| Cash | $XXX |
## Fidelity (估值需手动更新)
| Holding | Shares | Cost Basis |
|---------|--------|------------|
| MSFT | XX | $XX,XXX |
| GOOG | X | $XXX |
| ... | ... | ... |
## This Month ({month})
| | Amount |
|--|--------|
| Income | $X,XXX |
| Expenses | $X,XXX |
| **Net** | **+$X,XXX** |
### Top Expenses
| Category | Amount | % |
|----------|--------|---|
| Rent | $X,XXX | XX% |
| Food | $XXX | XX% |
| ... | ... | ... |
## Monthly Trend
| Month | Income | Expenses | Net |
|-------|--------|----------|-----|
| 2026-03 | ... | ... | ... |
| 2026-02 | ... | ... | ... |
| 2026-01 | ... | ... | ... |
| ... | ... | ... | ... |
## Data Coverage
- Checking: {earliest} ~ {latest}
- Savings: {earliest} ~ {latest}
- CSP: {earliest} ~ {latest}
- Fidelity: {earliest} ~ {latest}
- Total transactions: {count}
---
*fava: `conda run -n finance fava main.beancount --port 5001`*
finance(beancount + fava)~/Desktop/Notes/Personal/Finance/ 目录下运行investments.py --live --json(yfinance 实时价格),fallback 到 Fidelity Positions CSV/good-morning 和 /finance dashboard 时自动拉实时价格更新投资板块Updated: YYYY-MM-DD HH:MM(精确到分钟)investments.py 的 YTD_BASELINE 常量processed.json 记录已导入交易的指纹,保证增量导入不重复/finance report 输出到对话,不写入文件;/finance dashboard 写入 Dashboard.md