Use wecom-cli to operate WeCom smart sheets and documents, building a complete stock research system.
Initial setup (automatic initialization)
Before performing any operation, first check whether the stock analysis configuration already exists in memory. If not, automatically create it according to the following process:
Step 1: Create a smart sheet
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "股票研究"}'
Obtain from the returned result docid。
Step 2: Create sub-sheets and fields
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "自选股"}'
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "持仓"}'
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "分析记录"}'
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "财报日程"}'
Watchlist fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "股票代码", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "股票名称", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "市场", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "目标价", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "方向", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "当前价", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "备注", "field_type": "FIELD_TYPE_TEXT"}
]}'
Holdings fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "股票代码", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "股票名称", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "买入价", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "持仓量", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "买入日期", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "备注", "field_type": "FIELD_TYPE_TEXT"}
]}'
Analysis record fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "股票代码", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "分析日期", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "分析类型", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "结论摘要", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "看多理由", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "看空理由", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "信心评分", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "建议", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "报告链接", "field_type": "FIELD_TYPE_TEXT"}
]}'
Earnings schedule fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "股票代码", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "股票名称", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "财报日期", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "状态", "field_type": "FIELD_TYPE_SINGLE_SELECT"}
]}'
Step 3: Save the configuration to memory
Save the following information to the memory file stock-analyzer-config.md:
---
name: stock-analyzer-config
description: 股票研究助手智能表格配置信息
type: project
---
## 股票研究表配置
- docid: <DOCID>
- url: <创建时返回的URL>
- 表格名称: 股票研究
- 自选股 sheet_id: <SHEET_ID>
- 持仓 sheet_id: <SHEET_ID>
- 分析记录 sheet_id: <SHEET_ID>
- 财报日程 sheet_id: <SHEET_ID>
Operation process
In the following commands,
<DOCID>and each<SHEET_ID>are read from stock-analyzer-config in memory.
Layer 1: Watchlist monitoring
Add to watchlist:
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<自选股SHEET_ID>", "records": [{"values": {
"股票代码": [{"type": "text", "text": "AAPL"}],
"股票名称": [{"type": "text", "text": "Apple"}],
"市场": [{"text": "美股"}],
"目标价": [{"type": "text", "text": "200"}],
"方向": [{"text": "看涨"}],
"当前价": [{"type": "text", "text": "185"}],
"备注": [{"type": "text", "text": ""}]
}}]}'
Update the current price and check the target price:
# 先查询所有自选股
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<自选股SHEET_ID>"}'
# AI 使用 WebSearch 获取最新股价
# 对比目标价,如果到达则发送通知
# 更新当前价
wecom-cli doc smartsheet_update_records '{"docid": "<DOCID>", "sheet_id": "<自选股SHEET_ID>", "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE", "records": [{"record_id": "RECORD_ID", "values": {
"当前价": [{"type": "text", "text": "198"}]
}}]}'
# 发送目标价到达通知
wecom-cli msg send_message '{"chat_type": 1, "chatid": "<USERID>", "msgtype": "text", "text": {"content": "目标价提醒:AAPL 当前 $198,接近目标价 $200(看涨)"}}'
Layer 2: Portfolio snapshot
Generate a portfolio snapshot:
# 查询持仓
wecom-cli doc smartsheet_get_records '{"docid": "<DOCID>", "sheet_id": "<持仓SHEET_ID>"}'
# AI 使用 WebSearch 获取各股票当前价
# 计算市值 = 当前价 × 持仓量
# 计算盈亏 = (当前价 - 买入价) × 持仓量
Output format:
## 持仓快照(2026-04-02)
| 股票 | 买入价 | 现价 | 持仓量 | 市值 | 盈亏 |
|------|--------|------|--------|------|------|
| AAPL | $170 | $185 | 10 | $1,850 | +$150 (+8.8%) |
| GOOGL | $140 | $145 | 5 | $725 | +$25 (+3.6%) |
| **合计** | | | | **$2,575** | **+$175 (+7.3%)** |
Layer 3: Deep research
Launch 4 AI analysts to research a stock in parallel.
Interaction process:
- User: "Help me do a deep analysis of NVDA"
- AI launches 4 analytical perspectives for parallel research
- Aggregate and generate a report
4 analyst roles:
| Role | Focus | Analysis content |
|---|---|---|
| Fundamentals analyst | Revenue, profit, growth trends | Revenue growth rate, profit margin, free cash flow |
| Moat analyst | Competitive advantage | Technical barriers, brand, network effects, switching costs |
| Valuation analyst | Valuation reasonableness | P/E, P/B, DCF, peer comparison |
| Risk analyst | Potential risks | Industry risk, policy risk, customer concentration |
Generate a deep research report:
# 创建报告文档
wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "深度研究:NVDA 2026-04-02"}'
# 写入报告
wecom-cli doc edit_doc_content '{"docid": "<报告DOCID>", "content": "# NVIDIA (NVDA) 深度研究报告\n\n## 总览\n| 维度 | 评分(1-10) | 摘要 |\n|------|-----------|------|\n| 基本面 | 9 | 营收同比增长 122% |\n| 护城河 | 9 | CUDA 生态壁垒极高 |\n| 估值 | 6 | P/E 65x 高于历史均值 |\n| 风险 | 5 | 依赖 AI 投资周期 |\n\n## 看多理由\n1. ...\n\n## 看空理由\n1. ...\n\n## 信心评分:7.5/10\n## 建议:当前持仓可继续持有,但不宜追高加仓", "content_type": 1}'
# 保存分析记录
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<分析记录SHEET_ID>", "records": [{"values": {
"股票代码": [{"type": "text", "text": "NVDA"}],
"分析日期": [{"type": "text", "text": "2026-04-02"}],
"分析类型": [{"text": "深度研究"}],
"结论摘要": [{"type": "text", "text": "基本面强、护城河深、估值偏高、风险可控"}],
"看多理由": [{"type": "text", "text": "1. 数据中心收入持续爆发 2. CUDA生态壁垒 3. Blackwell架构量产"}],
"看空理由": [{"type": "text", "text": "1. 估值充分反映增长 2. 大客户自研芯片 3. 出口管制风险"}],
"信心评分": [{"type": "text", "text": "7.5"}],
"建议": [{"type": "text", "text": "继续持有,不宜追高,等待回调至$120以下"}],
"报告链接": [{"type": "text", "text": "https://doc.weixin.qq.com/docx/<DOCID>"}]
}}]}'
Layer 4: Automatic stock screening
Screen stocks according to user-defined conditions.
Interaction process:
- User: "Help me find companies with ROE greater than 15% and PE less than 20"
- AI uses WebSearch to search for stocks that meet the conditions
- Generate a screening results list
Output format:
| 排名 | 股票 | PE | ROE | 行业 |
|------|------|-----|-----|------|
| 1 | A公司 | 15.2 | 22% | 金融 |
| 2 | B公司 | 18.5 | 18% | 制造 |
Earnings reminders
Add an earnings schedule:
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<财报日程SHEET_ID>", "records": [{"values": {
"股票代码": [{"type": "text", "text": "AAPL"}],
"股票名称": [{"type": "text", "text": "Apple"}],
"财报日期": [{"type": "text", "text": "2026-04-25"}],
"状态": [{"text": "待发布"}]
}}]}'
Field type write format (general rules)
For the complete field type format description, see crm-schema
| Field type | Write format | Example |
|---|---|---|
| TEXT | [{"type":"text","text":"值"}] |
Stock code, price, date, etc. (numbers are stored as text) |
| SINGLE_SELECT | [{"text":"选项文本"}] |
Market, direction, analysis type, status, etc. |
Practical notes
Common pitfalls
- Do not pass key_type when updating — must include
"key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE" - When an API call fails — Check the error code: 301085 means the docid is invalid (use url instead); 2022004 means the field was not found (call add_fields first); 2022003 means the record does not exist (call add_records first). When encountering an error, first use
smartsheet_get_sheet '{"url": "<URL>"}'to verify the table structure. - Stock price data — Obtained via WebSearch; there may be delays, so it is recommended to note the data timestamp
- Numeric calculations — All numeric values are stored as TEXT; after reading them, the AI converts them to numbers for calculations
- Report documents — In-depth research reports are recommended to be saved as separate documents for easy review
- options do not take effect when creating a SINGLE_SELECT —
smartsheet_add_fieldsTheproperty.optionspassed in will not pre-create options; options are automatically created via[{"text": "选项"}]when a record is first written. When creating a field, thepropertyparameter can be omitted.
Scheduled automation suggestions
| Task | Suggested time | Cron |
|---|---|---|
| Position snapshot | Weekdays 18:00 | 0 18 * * 1-5 |
| Target price check | Weekdays 9:30, 15:30 | 30 9,15 * * 1-5 |
| Earnings check | Every Monday 9:00 | 0 9 * * 1 |
Data linkage
- This Skill's data will be read by the following Skills:
wecomcli-workflow-business-advisor— Financial advisor analyzes investment performance