gangtise-openapi-cli 0.28.3 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -181
- package/dist/src/cli.js +122 -7
- package/dist/src/core/args.js +56 -15
- package/dist/src/core/asyncContent.js +5 -3
- package/dist/src/core/client.js +39 -12
- package/dist/src/core/commandBodies.js +42 -6
- package/dist/src/core/endpoints.js +43 -0
- package/dist/src/core/fileParse.js +87 -0
- package/dist/src/core/indicatorMatrix.js +51 -25
- package/dist/src/core/transport.js +20 -0
- package/dist/src/version.js +1 -1
- package/gangtise-openapi/SKILL.md +18 -11
- package/gangtise-openapi/references/commands/indicator.md +79 -37
- package/gangtise-openapi/references/commands/insight.md +19 -0
- package/gangtise-openapi/references/commands/tool.md +40 -0
- package/gangtise-openapi/references/commands/vault.md +3 -1
- package/gangtise-openapi/references/examples.md +36 -2
- package/gangtise-openapi/references/response-schema.md +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,181 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
## Changelog
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
README 仅列最近 5 个版本摘要:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
9
|
+
- **v0.30.0 — 2026-08-02**:适配 EDE 接口重构(`universe` 取代 `securityCodeList`、截面矩阵转置、指标元数据结构化),新增 `indicator screener` 条件选股,并修正复权参数名。
|
|
10
|
+
- **v0.29.0 — 2026-07-25**:新增财报日历与 PDF 解析工具,群消息补 `quoteMsg`,并加强大整数 ID 与高积分调用防护。
|
|
11
|
+
- **v0.28.3 — 2026-07-24**:修复列式响应在错误 `--field` 下静默错列的问题,并校正 EDE 与字段文档。
|
|
12
|
+
- **v0.28.2 — 2026-07-24**:EDE 批量取数新增 `--key-by name|code`,优化无数据诊断与相关 Skill 文档。
|
|
13
|
+
- **v0.28.1 — 2026-07-23**:调整 Agent Skill 取数路由,多证券财务与估值指标优先使用 EDE 批量接口。
|
|
14
|
+
- **v0.28.0 — 2026-07-21**:适配新版错误码,强化日期校验、异步状态处理、可观测性与计费安全。
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
- SKILL.md 必备规则加第 10 条:`--field` 不确定就别传;`quote realtime` **无 `close`**(用 `latestPrice`)、**无市值**(总市值走 `indicator cross-section --indicator qte_mkt_cptl`,仅 A 股)
|
|
16
|
-
- `quote realtime` 补全 16 个实测字段(此前 `fields.md` 漏 `turnoverRate` / `volumeRatio`);`valuation-analysis` 标注只有 7 个字段、无 `securityCode`(误传会拿到一列重复的 `tradeDate`,长度相等拦不住)
|
|
17
|
-
- **推翻 07-23 关于 EDE `reportType` 的结论**(复测 2026-07-24):旧文档写「枚举不可信、`value=2/4` 直接 `999999`、指定口径请改用 `fundamental --report-type`」。实测是 label 与 value **错位但映射稳定**:`1`=合并(默认)、`2`=合并(调整)、`3`=母公司、`4`=母公司(调整),四值与三大报表逐一对得上;`2`/`4` 为空只是该报告期尚无调整表。**EDE 可以指定口径——母公司传 `3`,合并省略即可**
|
|
18
|
-
- 修正 `response-schema.md` 里会**反向诱导传错字段**的陈旧记录:`main-business` 行原写 `endDate` / `breakdownName` / `revenue`(实测均不存在),改为真实的 `periodName` / `periodEndDate` / `categoryName` + `opRevenue` / `grossProfit` 等 15 个字段
|
|
19
|
-
- 标注上游 meta 字段错位(实测边界):**A 股累计口径的 `balance-sheet` / `cash-flow`** 的 `companyType` 与 `currency` 值互换(`companyType=人民币`、`currency=银行`),A 股 `income-statement`、港股/美股三表均正确;A 股 `*-quarterly` 单季表另有 `companyType` 返回未映射数字码(`102119999`)的问题——读这两列按值判断语义,科目数字不受影响
|
|
16
|
+
### 历史里程碑
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
- **v0.26.0–v0.27.0**:建立高积分端点 `no-replay`、原子下载与容错分页机制,并补齐 Skill 分发和发布质量门禁。
|
|
19
|
+
- **v0.22.0–v0.23.0**:统一“省略 `--size` 即拉全量”的分页语义,引入机器可识别的部分结果、Token 自愈,并完成 API 域名迁移与资金流向、机构搜索支持。
|
|
20
|
+
- **v0.19.0–v0.20.0**:上线 EDE 证券指标接口,扩展美股公告与财务报表,同时加强凭证脱敏、CSV 正确性和分页容错。
|
|
21
|
+
- **v0.16.0–v0.18.0**:以服务端参考数据替代多数本地静态表,收紧端点参数,并加入产业公众号资讯。
|
|
22
|
+
- **v0.14.0–v0.15.0**:新增跨市场实时行情、美股日 K 与题材数据,完善全市场 K 线分片和部分失败容错。
|
|
23
|
+
- **v0.12.0–v0.13.0**:奠定并发翻页、连接复用、流式输出与 K 线分片架构,并扩展港股财报、EDB 和股票池。
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
**新增**
|
|
26
|
-
- `indicator cross-section` / `time-series` 加 `--key-by name|code`(默认 `name`):`code` 模式列头用 `indicatorCode`(时序多证券侧用 `securityCode`),唯一且与服务端返回列序无关。**多证券批量按 code 回填必用**——此前拍平只按指标显示名,而多个指标同名(如 `cf_finc_exp`/`_qtr` 都叫「财务费用」)+ 服务端会重排返回列序,导致按名/按位置都错位、只能绕道 raw API 手工回填
|
|
27
|
-
|
|
28
|
-
**修复**
|
|
29
|
-
- EDE `999999` 无数据提示只对取数端点(`cross-section`/`time-series`)套用,`indicator.search`(同为 no-999999 策略、仅关键词入参)回落通用提示;文案改为「日期匹配指标周期(财务/MRQ 用报告期末、日频估值用交易日)、`scopeList`、`parameterList` 中 required 参数」——修正此前「行情/估值用交易日」与 `finc_pb_mrq` 仅报告期末的矛盾
|
|
30
|
-
|
|
31
|
-
**文档(随包 skill)**
|
|
32
|
-
- `indicator.md`:`--key-by` 文档 + 两处 synopsis;`periodNum` 补「部分需配年报日期」、`startDate` 补「取值须匹配指标周期」
|
|
33
|
-
- `examples.md` 例15:批量三截面示例改用 `--key-by code`
|
|
34
|
-
|
|
35
|
-
### v0.28.1 — 2026-07-23
|
|
36
|
-
|
|
37
|
-
Agent Skill 文档取数路由对齐(对齐 gangtise-mcp 0.1.46):多证券取一批**已实现**财务/估值指标优先走 EDE `indicator cross-section`/`time-series` 一次拉取,替代逐只 `fundamental` 循环。**本版仅改随包分发的 skill 文档(`gangtise-openapi/`),无 CLI 代码/命令/参数变更。**
|
|
38
|
-
|
|
39
|
-
**路由规则**
|
|
40
|
-
- 单票财务/估值/盈利预测/股东/主营、单票完整三大报表 → 仍走 `fundamental` 专用命令;行情/K 线 → `quote`(免费批量)
|
|
41
|
-
- 多证券已实现财务/估值指标 → 优先 EDE(`cross-section` 单日快照 / `time-series` 单指标×多证券区间)
|
|
42
|
-
- 始终排除 EDE:盈利预测·一致预期、估值历史分位(实测 EDE 无此两类)、OHLCV/K 线、单票完整报表
|
|
43
|
-
- EDE 取数前三项校验:`indicatorName`+`description` 语义 / `scopeList` 覆盖全部目标市场 / `parameterList` 必填参数,任一不符即回退专用接口
|
|
44
|
-
|
|
45
|
-
**实测校正(2026-07-23)**
|
|
46
|
-
- `scope` 字段更正为 `scopeList[].market/.securityType`(服务端已返回实际覆盖),覆盖按指标而异:`finc_pe_ttm`/`finc_pb_mrq` 仅 A 股、`is_op_rev` A 股+港股,均不含美股;`valuation-analysis`/`earning-forecast` 仅 A 股
|
|
47
|
-
- `finc_pb_mrq`(市净率 MRQ) 只在报告期末打值(交易日取 `null`),非日频;EDE 财务指标 `reportType` 枚举 label 与实测取数不符(`value=2/4` 直接 `999999`),要指定报表口径改用 `fundamental` 三大报表 `--report-type`
|
|
48
|
-
- ⚠️ **本条 `reportType` 结论已被 v0.28.3 复测推翻,勿据此路由**:实际是 `1`=合并 / `2`=合并(调整) / `3`=母公司 / `4`=母公司(调整),EDE 可直接指定口径,见上方 v0.28.3 条目(`finc_pb_mrq` 部分仍成立)
|
|
49
|
-
|
|
50
|
-
### v0.28.0 — 2026-07-21
|
|
51
|
-
|
|
52
|
-
对齐服务端 2026-07-17 更新(内资研报下载调价 + 41 个公开错误码重排)。**41 个码逐个打了线上探针**,结论是迁移按「错误处理层」而非按业务模块进行、文档并不等于现状:同一个接口内,参数校验层与路由层已发新码,方法路由层和 token 过滤器仍发旧码,异步生成状态也仍是旧码。CLI 对两代都识别。
|
|
53
|
-
|
|
54
|
-
**错误码体系**
|
|
55
|
-
- `errors.ts` 错误码表按新三层结构(`999xxx` 服务统一层 / `1xxxxx` 业务通用层 / `2xxxxx` 接口专有层)重写,覆盖 41 个公开码 + 实测仍在线的旧码
|
|
56
|
-
- 异步轮询同时识别 `410110`/`140001`(生成中)与 `410111`/`140002`(终态失败)。实测服务端**仍在用旧码**(HTTP 400、无 `errorType`),新码为预置——服务端切换那天 `--wait` 不会在首次轮询就抛错中止,把已扣的 50 积分作废
|
|
57
|
-
- `140002`(异步 PROCESSING_FAILED,`410111` 的新码)纳入 transport 终态码集合、任何 HTTP 状态都不重试——异步 `*-check`(get-content)端点无 retry 声明、走默认策略,`140002@500` 会被白重试 2 次才轮到 `asyncContent` 的 `FAILED_CODES` 识别(后者在 `client.call` 的 `withRetry` 之上、拦不到重试);`140002` 语义即「生成失败·终态」、只有那些异步端点会返回它,故全局终态化既安全又省掉白重试。实测服务端仍用 `410111`,此为预置
|
|
58
|
-
- token 自愈补上 `999002`(`0000001008` 的新码);`999011`(AK/SK 不匹配)加入**终态码集合**,任何 HTTP 状态下都不重试——凭证错不会自己好。注意它只来自 `auth.login`,而 login 走 `useAuth=false` 压根不经过自愈码表,所以「不列进自愈表」并拦不住 `auth.login` 在 5xx 上按默认策略重放两次,必须落在终态码上
|
|
59
|
-
- 修正 `900002` 的错误释义:实测服务端用它表示「请求方法不正确」(HTTP 405),旧文档写作「请求缺少 uid」,据此排查会走错方向
|
|
60
|
-
- 错误提示改为只给下一步动作,不再复述服务端 msg(此前输出形如 `资源不存在 资源不存在,确认 ID 有效`)——新旧两代都过了一遍:留用的 `903301` / `8000016` / `8000018` / `999995` / `999997` / `900001` / `130001` / `410004` / `410110` / `410111` 原本是逐字重复 msg
|
|
61
|
-
- 补上 `410001` / `410106` 两个 EDE 专有旧码的提示——它们没被 2026-07-17 重排收编,却是 `indicator` 取数最常见的两个报错(漏传 `--indicator`/`--security`、漏传 `periodNum` 等必填参数),`indicator.md` 早已把它们列为首要排查项
|
|
62
|
-
- `110002`(日期区间非法)提示改为同时覆盖 `--start-date/--end-date` 与 `--start-time/--end-time`——此前只提 date 参数,而 `insight` 系 list 按 `--start-time` 排序,旧提示指向的是命令根本没有的参数
|
|
63
|
-
- `999006`(限流)提示不再断言「CLI 已退避重试」——仅限流以 429 返回时才全局按 `Retry-After` 退避重试;5xx 形态只有默认策略端点会重试、贵档 no-replay 端点不会,200 错误信封则不重试
|
|
64
|
-
- `130001` 提示改为先给通用「未找到数据/核对查询条件」再限定 EDE 指标权限(此前把通用 DATA_NOT_FOUND 一律导向「未开通指标」);`130002` 提示补上「非法 `--file-type` 也归此码」(下载类兜底)
|
|
65
|
-
|
|
66
|
-
**行为变更(本地校验)**
|
|
67
|
-
- 所有 date 参数(`--start-date`/`--end-date`/`--date`/`--report-date`,覆盖 Quote/Fundamental、AI `theme-tracking`/`hot-topic`/`management-discuss-*`、Alternative `edb-data`、Indicator)只接受 `YYYY-MM-DD`,其余格式在发请求前报 `ValidationError`——**服务端额外接受的两种「年在后」格式日月顺序相反**:实测 `07/01/2026`(斜杠)读成 `2026-01-07`、`07-01-2026`(横杠)读成 `2026-07-01`,同样三个数字差半年且都返回 HTTP 200,响应里不回显服务端实际采用的日期(用 `25/12` 与 `12/25` 的互补接受结果交叉验证)。CLI 无从判断用户想要哪个读法,故只转发无歧义写法。`20260701` / `2026/07/01` 这类服务端同样能正确处理的写法也一并拒掉——统一成一种入参形态,好过按端点逐一探针维护白名单;报错文案说明该用哪种写法,不再断言输入本身有歧义
|
|
68
|
-
- **datetime 参数(`--start-time`/`--end-time`)本地拦截覆盖全部透传命令**(insight research/summary/announcement-hk/us、vault 各 list、`quote minute-kline`、`ai security-clue` 等原样透传的 18 处,外加转时间戳的 A 股 `announcement` / `knowledge-batch`)。**服务端对透传的年在后格式静默误解析、并不报 `110001`**:实测 `insight research list` 对 `07/01/2026` 返回 1562 条(=`2026-01-07`)、`07-01-2026` 返回 210 条(=`2026-07-01`),差半年、都 HTTP 200、响应不回显实际日期。新增 `parseDatetimeOption` 做**时区无关**的字段校验(算术闰年、不构造本地 `Date`,故 DST 缺口时刻等对服务端合法的字符串不被客户端时区误伤)后**原样透传**
|
|
69
|
-
- 本地时间校验只认 `YYYY-MM-DD`、`YYYY-MM-DD HH:mm[:ss]`(空格或 `T` 分隔、秒可省)或 10/13 位时间戳;此前 `parseTimestamp13` 用 `new Date()` 兜底还能吞 `.SSS` 毫秒尾、`+08:00` 时区尾、以及 `Infinity`/`1e309`/非整数(数字分支只查 `NaN`,这类会序列化成 null 静默取消过滤),现一律拒绝(时间戳分支改用严格 `^\d{10}$`/`^\d{13}$` 位数正则——这也是科学计数法 / 16 进制 / 空白 / 非标准位数被拒、且 13 位 `1000000000000` 不再落进秒分支的原因)
|
|
70
|
-
|
|
71
|
-
**修复**
|
|
72
|
-
- EDE 内层信封的报错(`indicator` 取数失败的 `999999` / `130001` 等)此前**永远拿不到 traceId**:实测 `traceId` 只挂在外层信封上,而外层在解包时即被丢弃,内层抛错又没传 details。现在外层 id 以不可枚举属性随 payload 带下去(不进 JSON/CSV 输出),`ApiError.traceId` 兜底读它——这类错误恰恰最需要报障,此前与 README「报错行会带 trace」的表述对不上
|
|
73
|
-
- HTTP 200 包裹的错误信封(Gangtise 也用这种形态)此前会丢掉服务端的 `Retry-After`:主 JSON 路径与下载 JSON 路径两处 `unwrapEnvelope` 都补上(此前只有 4xx/5xx 的 `throwHttpError` 保留),限流响应的退避窗口不再被丢弃
|
|
74
|
-
- `toTimestamp13` 的日历校验补年份与时间 round-trip:`0050-06-15` 曾被 `Date(50,…)` 构造器映射成 1950、DST 缺失时刻(如 America/New_York 的 `02:30`)曾被静默移到 `03:30`——均改为拒绝
|
|
75
|
-
- 异步终态失败(`410111`/`140002`)的报错行补上 code / msg / `traceId` 并提示重提会再次计费——此前只打印一句 "Content generation failed",把本版新增的 trace 信息吞掉了,与 README「报错行会带 trace」的表述矛盾
|
|
76
|
-
|
|
77
|
-
**可观测性**
|
|
78
|
-
- 响应信封新增的 `traceId` 透出到 CLI 报错行:`API error (130002) [trace 830965044897325056]: 资源不存在 确认 ID 有效…`——这是 Gangtise 侧唯一能回溯一次失败的抓手,报障时请带上
|
|
79
|
-
|
|
80
|
-
**计费**
|
|
81
|
-
- `insight research download`(内资研报)**20 → 10 积分/篇**,SKILL.md 积分速查表与 `insight.md` 同步
|
|
82
|
-
|
|
83
|
-
**文档(实测结论沉淀)**
|
|
84
|
-
- SKILL.md 异常处理表重写为「实测确认在用」与「文档列出但未触发」两组,标注每个码的实测状态与兜底关系(`100003` 是参数类兜底、`130002` 是下载类兜底,`130003`/`130004`/`130005` 均未启用)
|
|
85
|
-
- 记录两个实测坑:**枚举值拼错与分页越界服务端不报错**(静默忽略该筛选条件,拼错会伪装成"结果正常");**`viewpoint-debate` 敏感内容不被提前拦截**,扣满 50 积分后才以 `410111` 失败
|
|
86
|
-
- 纠正 SKILL 异常表 `110001`/`110002` 行的日期分类:此前按命令组(「Quote/Fundamental 用 date、Insight/AI 用 datetime」「110001 只有 Insight 系报」)与 AI `management-discuss --report-date`(date 型)及实测都冲突——实测 `fundamental` 对 `2020/01/01` 报 110001、`insight research list` 对 `30/06/2025` 反而宽松解析返回数据,改为按参数名分类、不按命令组预判
|
|
87
|
-
- 新增判别法:新码信封 `code` 是 JSON 数字且带 `errorType`,旧码是字符串且没有——但它判断的是**单条错误路径**切没切,不是整个接口(成功响应也没有 `errorType`,别拿它当判据)
|
|
88
|
-
- README 常见错误表同步重写;Troubleshooting 的 `8000014/8000015` → `999011`、`430007` → `100006`
|
|
89
|
-
|
|
90
|
-
### v0.27.0 — 2026-07-11
|
|
91
|
-
|
|
92
|
-
**EDE 指标(体验修复)**
|
|
93
|
-
- `indicator` 三端点对 `999999` 不再自动重试——实测服务端用 `999999` + HTTP 500 表示「查询无数据」(节假日 / 未来日期 / 未覆盖标的),此前每次空查询白烧 3 个请求 + ~4 秒;错误提示改为指向检查查询条件而非「稍后重试」
|
|
94
|
-
|
|
95
|
-
**资金与下载加固(承接 v0.26.0)**
|
|
96
|
-
- 下载路径同样接入重试策略:50/篇 的 `summary` / `foreign-report` / `my-conference` download 改为 no-replay(与 AI Agent 同价档;下载中断重试可能重复计费),10-30/篇 的下载维持默认重试
|
|
97
|
-
- 签名 URL 下载增加整体硬截止(10× 单请求超时)——headers/body 超时是空闲型,慢滴速传输可无限续命;最终 rename 失败时清理 `.part`
|
|
98
|
-
- `GANGTISE_PAGE_CONCURRENCY` 防御性解析:非法/非正数回退默认 5、上限 32——负值此前被底层钳制成**单 worker 串行**(静默变慢),过大值可能造成过度并发触发限流
|
|
99
|
-
- `--version` 更新提示改为数值分段版本比较(不处理预发布号;本项目只发 x.y.z)——刚发版的 registry 滞后窗口不再把旧版本提示成"可更新"
|
|
100
|
-
|
|
101
|
-
**体验与正确性小修**
|
|
102
|
-
- `--wait` 异步轮询容忍瞬态错误:5xx/网络抖动只消耗一次尝试并继续等待,不再作废整段等待(积分不足等终态错误仍立即中止)
|
|
103
|
-
- table 输出单元格显示宽度上限 120(超长截断加 `…`)——一个超长字段不再把整列所有行 pad 成同宽(行数 × 宽度的空格放大)
|
|
104
|
-
- markdown 输出先转义反斜杠再转义竖线,字面 `\|` 单元格不再错位列;table/markdown 过滤 C1 控制符(U+009B 单字节 CSI 注入面)
|
|
105
|
-
- 自动文件名按码点截断,emoji 不再被截成 `�`;EDE 矩阵中与 `date`/`security`/`name` 同名的指标列自动加后缀,不再覆盖元数据列
|
|
106
|
-
- 全市场分片截断时输出 `truncatedShards`(具体日期区间,与 `failedShards` 对称),脚本/AI 消费者可定向缩窗补拉
|
|
107
|
-
- 分页端点首页形状漂移(如 `total` 变字符串)时 `--verbose` 下告警,不再完全静默退化单页
|
|
108
|
-
|
|
109
|
-
**Skill 分发**
|
|
110
|
-
- `gangtise-openapi/` 目录纳入 npm 包;README 安装命令改为从 `$(npm root -g)` 复制——此前的相对路径命令对 npm 用户不可执行
|
|
111
|
-
|
|
112
|
-
**防漂移门禁(工程,不影响 CLI 行为)**
|
|
113
|
-
- 新增 README↔ENDPOINTS 一致性测试:「自动翻页」清单与注册表 pagination 标记双向比对(此类手抄清单漂移已发生两次);insight/reference 子命令的 `--help` 覆盖改为从端点注册表派生,新命令漏接线直接测试失败
|
|
114
|
-
- `npm run prepare` 前置断言 README/CHANGELOG 含当前版本条目(写盘前检查,失败零残留);`npm run typecheck` 纳入 tests/(tsconfig.test.json)
|
|
115
|
-
- CI:`npm pack` 装包冒烟(`--help` + skill 文件存在校验)、测试矩阵 Node 下限改精确 20.18.1、CI typecheck;publish 的 `workflow_dispatch` 必须指向 `v*` tag(关闭无护栏发布通道)
|
|
116
|
-
|
|
117
|
-
### v0.26.0 — 2026-07-11
|
|
118
|
-
|
|
119
|
-
**资金安全(重要)**
|
|
120
|
-
- 13 个贵档端点(`one-pager` / `investment-logic` / `peer-comparison` / `research-outline` / `theme-tracking` / `management-discuss-*`×2 / `hot-topic` / `knowledge-batch` / `earnings-review get-id` / `viewpoint-debate get-id` / `concept-info` / `concept-securities`)改为 **no-replay 重试策略**:5xx / 超时 / `999999` 不再自动重放——实测(2026-07-11)平台按次计费且**缓存命中不豁免**,同参数重放每次都扣分;仅连接期错误(`ECONNREFUSED`/DNS,请求未发出)、429 限流和 token 自愈仍重试。便宜按条计费的 list 类维持原全量重试(失败响应没有数据行、不计费)
|
|
121
|
-
- 连接失败 `ECONNREFUSED` / `UND_ERR_CONNECT_TIMEOUT` 纳入默认重试范围(此前这两类不重试)
|
|
122
|
-
|
|
123
|
-
**文件安全**
|
|
124
|
-
- 所有 `--output` 落盘(导出、流式下载主路径、签名 URL 跟随下载)改为原子写:先写同目录 `.part` 成功后 rename——重跑失败不再毁掉已有旧文件;顺带修掉中止路径上 `.part` 因流懒打开竞态残留的问题
|
|
125
|
-
- 签名 URL 跟随下载改走 transport 层:遵守 `GANGTISE_TIMEOUT_MS`(此前裸 `fetch` 无超时,慢滴速 CDN 可无限挂起)、网络错误自动重试、跟随最多 3 跳重定向(undici 不自动跟随,超限/缺 `Location` 报错而非把跳转页存成文件)、`--verbose` 日志剥离签名 query 只留 origin+path
|
|
126
|
-
- 自动命名去重后缀试尽 `-1`…`-99` 仍冲突时报错,不再静默覆盖最早的文件
|
|
127
|
-
|
|
128
|
-
**修复 / 加固**
|
|
129
|
-
- 下载重定向超过 3 跳或缺 `Location` 时报错,不再把跳转页 HTML 当文件内容保存
|
|
130
|
-
- 损坏的 gzip 响应包装为带请求上下文的 `ApiError`(此前抛裸 zlib `Z_DATA_ERROR`,与请求无关联且不可定位)
|
|
131
|
-
- `alternative edb-search --limit` ≤200、`indicator search --limit` ≤100 本地上限校验——实测服务端对超限值静默截断(201→200、101→100),与 v0.25.0 的 `--top` 同类同修法
|
|
132
|
-
|
|
133
|
-
### v0.25.0 — 2026-07-10
|
|
134
|
-
|
|
135
|
-
**新增接口(4)**
|
|
136
|
-
- `insight qa list` — 投资者问答 QA:按证券提取互动平台 / 电话会议 / 调研纪要的提问与回答;`--security-code`(必填)、`--source`(`conference`/`interactive`/`survey`)、`--question-category`(11 类,见 `insight.md`)、`--answer-important`(`1` 是 / `0` 否)、`--start-time`/`--end-time`(字符串直传);自动翻页(单页上限 500);0.1 积分/条
|
|
137
|
-
- `insight report-image list` / `download` — 研报图表:按关键词搜索研报图片,返回 `chunkId` + 元数据(`--keyword` 必填、`--top` 默认 10 上限 20、`--source-id`、时间过滤;**免费**),再 `download --chunk-id` 下二进制原图(JPEG,0.1 积分/张)
|
|
138
|
-
- `reference official-account-search` — 公众号 ID 搜索:输入公众号名 / 机构 / 关键字返回 `accountId`(喂 `insight official-account list --account-id`);`--keyword`(必填)、`--category`(`listedCompany`/`broker`/`government`/`media`,可重复;未分类公众号 `category` 为 `null`,传 `--category` 会漏掉)、`--top`(默认 10 上限 10);免费
|
|
139
|
-
|
|
140
|
-
**变更**
|
|
141
|
-
- `indicator search` / `cross-section` / `time-series` 市场范围从仅 A 股扩展至 A 股 / 港股 / 美股(服务端变更;CLI 早已支持 `--currency` 与多市场证券代码,无需改动)。⚠️ 美股代码用交易所后缀 `.O`(NASDAQ) / `.N`(NYSE),**非 `.US`**——官方示例的 `AAPL.US` 查不到数据,实测须 `AAPL.O`
|
|
142
|
-
|
|
143
|
-
**修复 / 加固**(承接上一批未单独发版的改动)
|
|
144
|
-
- 分页 / 分片 `partial` 检测补全:`requestPaginated` 的短后续页、`MAX_PAGES` 上限、`total` 漂移、失败页四种场景统一触发 `partial`(退出码 3)——失败页独立成判定条件,避免超额返回的兄弟页把行数补满、掩盖失败页空洞;`quote` 全市场分片硬错后熔断、破损形状分片计入 `failedShards`
|
|
145
|
-
- `--top` 本地上限校验(`report-image` / `knowledge-batch` ≤20,reference 六个搜索命令 ≤10)——实测服务端对超限值**静默截断**不报错,现在发请求前本地报错;`securities-search` / `institution-search` / `official-account-search` 的 `--category` 加本地白名单——实测服务端对拼错的分类**不报错**(securities-search 静默忽略过滤返回全类别、另两个静默返回空),拼写错误不再伪装成"无结果"(`insight qa` 的枚举服务端会报 `100003`,故不做本地白名单)
|
|
146
|
-
- 错误码 `100003`(参数值非法)补充中文提示——服务端不指明是哪个参数,提示对照命令 `--help` 检查枚举参数拼写
|
|
147
|
-
- undici `^7.16.0` → `^7.28.0`(修 keep-alive 队列污染 GHSA-35p6-xmwp-9g52),`engines.node` `>=20` → `>=20.18.1` 对齐 undici 实际最低要求
|
|
148
|
-
|
|
149
|
-
### v0.24.0 — 2026-07-07
|
|
150
|
-
|
|
151
|
-
**新增**
|
|
152
|
-
- `raw list` — 列出所有已注册的 endpoint key(含 method / path / description),配合 `raw call <key>` 使用,不必再翻文档记 key;支持 `--format`(默认 table)/ `--output`
|
|
153
|
-
- AI 同步生成端点内置 120s 超时下限(`one-pager` / `investment-logic` / `peer-comparison` / `theme-tracking` / `research-outline` / `management-discuss-announcement` / `management-discuss-earnings-call`)——生成耗时长不再撞 30s 默认超时触发重试,**不必再手动前缀 `GANGTISE_TIMEOUT_MS`**;显式设更大值仍生效(取 max)
|
|
154
|
-
- 429 响应尊重 `Retry-After`(秒或 HTTP-date;覆盖 JSON、非 JSON、下载三类错误路径),优先于默认指数退避,封顶 60s 防挂死
|
|
155
|
-
- 超大结果(≥5 万行且走非流式渲染:table/json/markdown,或 jsonl/csv 未带 `--output`)在 stderr 提示改用 `--format jsonl --output <path>` 流式落盘
|
|
156
|
-
|
|
157
|
-
**性能**
|
|
158
|
-
- JSON 请求启用 gzip(`accept-encoding: gzip` + 本地解压)——实测 `reference constant-list` 2110B→586B(3.6x),K 线类高重复大 JSON 收益更高;下载二进制路径不变
|
|
159
|
-
- 全市场按日分片(`quote fund-flow` / `day-kline` / `day-kline-us`,均 1 天/片)自动跳过周六日(A/港/美股周末闭市必空),省 ~28% 请求与每日调用配额;多日分片(`day-kline-hk` 2 天、`index-day-kline` 30 天)不受影响
|
|
160
|
-
|
|
161
|
-
**修复**
|
|
162
|
-
- 表格(table/markdown)显示宽度纳入 emoji 码位区(0x1F000–0x1FAFF),含 emoji 的微信群名/消息不再错位
|
|
163
|
-
- `fundamental earning-forecast` 默认 `--end-date`("today")改用运行机器本地日期;此前用 UTC 日期,CST 凌晨 0–8 点会算成"昨天"
|
|
164
|
-
|
|
165
|
-
**文档 / 工程**(不影响已发布 CLI 行为)
|
|
166
|
-
- `insight announcement`(A 股公告)时间过滤时区说明:`--start-time`/`--end-time` 按运行机器时区换算,跨机器精确边界改传 13 位毫秒时间戳
|
|
167
|
-
- CI 测试矩阵增加 Node 24(此前仅 20;发布用 24)
|
|
168
|
-
|
|
169
|
-
### v0.23.0 — 2026-07-05
|
|
170
|
-
|
|
171
|
-
**行为变更(注意)**
|
|
172
|
-
- ⚠️ 默认 API 域名迁移:`https://open.gangtise.com` → `https://openapi.gangtise.com`。旧域名仍可用,CLI 只是切换了默认值(新旧域名多接口实测等价);如需固定旧域名设 `GANGTISE_BASE_URL=https://open.gangtise.com`
|
|
173
|
-
- `vault wechat-chatroom-list`:服务端接口改版为返回 `{ total, list }`(此前无 `total`、列名 `chatRoomList`)。CLI 相应改为按 `total` 并发翻页(不再串行翻页);省略 `--size` 仍拉全量、传 `--size N` 取前 N 条,`Total:` 提示恢复
|
|
174
|
-
- 无翻页的行情端点(`quote fund-flow` / `minute-kline` / 显式多标的的日 K:`day-kline`·`-hk`·`-us`·`index-day-kline`)返回行数撞上单次 `--limit` 时标 `partial`(退出码 3)+ stderr 警告,避免被静默截断;`--limit` 现本地校验 ≤ 10000(撞服务端上限也不漏标)。K 线 `--security all` 仍走日期分片自动补全,不受影响
|
|
175
|
-
|
|
176
|
-
**新增**
|
|
177
|
-
- `quote fund-flow` — A股个股日资金流向(沪深京),含小/中/大/特大单流入流出金额及占比、主力净流入等字段;`--security`(或 `aShares` 全市场)、`--start-date` / `--end-date`、`--limit`(默认 6000,上限 10000)、`--field` 指定返回字段;无积分消耗(单只证券无翻页,撞 `--limit` 时的截断处理见上「行为变更」;**`aShares` 全市场须显式传 `--start-date`/`--end-date`,CLI 按日自动分片并发合并——缺日期会本地报错**)
|
|
178
|
-
- `reference institution-search` — 机构 ID 搜索,输入机构名/简称返回 `institutionId` 及适用接口参数(`usageScopes`);`--keyword`(必填)、`--category`(`domesticBroker`/`foreignInstitution`/`leadInstitution`/`opinionInstitution`/`foreignOpinionInstitution`,可重复)、`--top`(默认 10,上限 10);免费。覆盖既有 `--broker`/`--institution` 全部机构类(research/foreign-report/opinion/foreign-opinion/summary/roadshow/site-visit/strategy/my-conference)
|
|
179
|
-
- `vault my-conference-list` 新增 `--source` — 按录制来源筛选(`1`=企微会议助理 `2`=会议服务微信群,可重复;不传返回全部)
|
|
180
|
-
|
|
181
|
-
> 更早版本及完整更新历史见 [CHANGELOG.md](CHANGELOG.md)。
|
|
25
|
+
> 完整更新明细及更早版本见 [CHANGELOG.md](CHANGELOG.md)。
|
|
182
26
|
|
|
183
27
|
## 首次安装
|
|
184
28
|
|
|
@@ -248,7 +92,7 @@ gangtise-openapi/
|
|
|
248
92
|
│ ├── ai.md # AI 能力命令(one-pager / earnings-review / viewpoint-debate 等)
|
|
249
93
|
│ ├── alternative.md # 行业指标数据库(EDB search / EDB data)
|
|
250
94
|
│ ├── fundamental.md # 财务数据命令(A股/港股三大报表 / 估值 / 盈利预测 / 股东)
|
|
251
|
-
│ ├── indicator.md # 证券级数据指标 EDE(search / 截面 /
|
|
95
|
+
│ ├── indicator.md # 证券级数据指标 EDE(search / 截面 / 时序 / 条件选股)
|
|
252
96
|
│ ├── insight.md # 投研内容命令(研报 / 观点 / 纪要 / 公告 / 外资)
|
|
253
97
|
│ ├── quote.md # 行情命令(A股/港股/指数 K 线)
|
|
254
98
|
│ ├── reference-and-lookup.md # GTS Code 搜索与枚举速查
|
|
@@ -305,6 +149,7 @@ cp -r "$SKILL_SRC" ~/.hermes/skills/gangtise-openapi
|
|
|
305
149
|
| | `site-visit list` | 调研 |
|
|
306
150
|
| | `strategy list` | 策略 |
|
|
307
151
|
| | `forum list` | 论坛 |
|
|
152
|
+
| | `performance-calendar list` / `download` | 财报日历(业绩预告/快报/公告,含原文 PDF 下载) |
|
|
308
153
|
| | `research list` / `download` | 研报(含 Markdown 下载) |
|
|
309
154
|
| | `foreign-report list` / `download` | 外资研报(含中文翻译下载) |
|
|
310
155
|
| | `announcement list` / `download` | A股公告(含 Markdown 下载) |
|
|
@@ -359,11 +204,13 @@ cp -r "$SKILL_SRC" ~/.hermes/skills/gangtise-openapi
|
|
|
359
204
|
| **Indicator** | `search` | 证券级数据指标搜索(按名称匹配,返回 indicatorCode 及可传参数 parameterList) |
|
|
360
205
|
| | `cross-section` | 指标截面数据(多指标 × 多证券,单日快照;前置 `search` 拿 code) |
|
|
361
206
|
| | `time-series` | 指标时间序列(多指标 × 单证券 或 单指标 × 多证券,按区间) |
|
|
207
|
+
| | `screener` | 条件选股(按指标表达式从证券/板块范围筛股;前置 `search` 拿 code) |
|
|
362
208
|
| **Alternative** | `edb-search` | 行业指标搜索(按关键词匹配,返回 indicatorId 等元信息) |
|
|
363
209
|
| | `edb-data` | 行业指标时序数据(批量拉取,最多10个指标) |
|
|
364
210
|
| | `concept-info` | 题材指数基本信息(投资逻辑/行业空间/竞争格局/催化事件) |
|
|
365
211
|
| | `concept-securities` | 题材指数成分股(题材深度F8,按分组,标记重点个股) |
|
|
366
|
-
| **
|
|
212
|
+
| **Tool** | `file-parse` / `file-parse-check` | PDF 解析为 Markdown + 图片(异步,返回 ZIP) |
|
|
213
|
+
| **Raw** | `call` | 原始接口调用(可访问任意 JSON / download endpoint;upload 型如 `tool.file-parse.submit` 需走 `tool file-parse`,raw 带不了文件) |
|
|
367
214
|
|
|
368
215
|
## 命令概览
|
|
369
216
|
|
|
@@ -377,6 +224,7 @@ cp -r "$SKILL_SRC" ~/.hermes/skills/gangtise-openapi
|
|
|
377
224
|
- `gangtise indicator ...`
|
|
378
225
|
- `gangtise alternative ...`
|
|
379
226
|
- `gangtise reference ...`
|
|
227
|
+
- `gangtise tool ...`
|
|
380
228
|
- `gangtise raw call ...` / `gangtise raw list`
|
|
381
229
|
|
|
382
230
|
## 推荐工作流
|
|
@@ -410,7 +258,7 @@ gangtise ai knowledge-batch --query 比亚迪 --query 最近热门概念
|
|
|
410
258
|
- **HTTP keep-alive**:所有请求复用同一个 `undici.Agent`(连接池 16),避免重复 TLS 握手。
|
|
411
259
|
- **流式下载**:指定 `--output` 时,二进制响应(PDF 等)直接 `pipeline` 到磁盘,不经过内存缓冲;50MB PDF 内存占用近乎为零。
|
|
412
260
|
- **流式输出**:`jsonl`/`csv` 格式且 `--output` 指定时,超过 1000 行自动切换为逐行写盘,避免一次性构建百 MB 字符串。
|
|
413
|
-
- **自动重试**:5xx / 429 / `ECONNREFUSED` / `ECONNRESET` / `ETIMEDOUT` / `ENOTFOUND` / `EAI_AGAIN` / `UND_ERR_*`(undici 连接/超时类)/ `999999` 系统错误自动指数退避重试 2 次。**贵档端点例外**(one-pager 等 13 个生成/提交类 + 50/篇 的 summary/foreign-report/my-conference 下载,共 16 个):5xx/超时不重放——按次计费不幂等,重放即重复扣分;仅连接失败、429 与 token 自愈重试。**`indicator`(EDE)端点对 `999999`
|
|
261
|
+
- **自动重试**:5xx / 429 / `ECONNREFUSED` / `ECONNRESET` / `ETIMEDOUT` / `ENOTFOUND` / `EAI_AGAIN` / `UND_ERR_*`(undici 连接/超时类)/ `999999` 系统错误自动指数退避重试 2 次。**贵档端点例外**(one-pager 等 13 个生成/提交类 + 50/篇 的 summary/foreign-report/my-conference 下载,共 16 个):5xx/超时不重放——按次计费不幂等,重放即重复扣分;仅连接失败、429 与 token 自愈重试。**`indicator`(EDE)端点对 `999999` 不重试**——重放一次已计费的查询没有意义(该码 2026-08-01 前还兼表「查询无数据」,现已改为返回空数组)。**终态码 `999011`(凭证无效)/ `140002`(异步生成失败)在任何 HTTP 状态下都不重试**——凭证错不会因重试而变,异步生成失败是终态。
|
|
414
262
|
- **Token 自愈**:调用返回 `0000001008` / `999002` 时自动强制刷新 Token 并重试一次。
|
|
415
263
|
- **K线/资金流向自动分片**:`quote day-kline --security all`、`quote fund-flow --security aShares` 等全市场查询自动按日期切分(A股 K线/资金流向 1 天/片、美股 1 天/片、HK 2 天/片、指数 30 天/片),并发执行后合并结果;按日分片自动跳过周六日。分片时如果用户未传 `--limit`,自动注入 `limit: 10000`(API 上限)避免默认 6000 截断。
|
|
416
264
|
- **Token 内存缓存**:Token 在进程内存中缓存,避免每次请求读盘。
|
|
@@ -425,6 +273,7 @@ gangtise ai knowledge-batch --query 比亚迪 --query 最近热门概念
|
|
|
425
273
|
- `insight site-visit list`
|
|
426
274
|
- `insight strategy list`
|
|
427
275
|
- `insight forum list`
|
|
276
|
+
- `insight performance-calendar list`
|
|
428
277
|
- `insight research list`
|
|
429
278
|
- `insight foreign-report list`
|
|
430
279
|
- `insight announcement list`
|
|
@@ -453,7 +302,7 @@ gangtise ai knowledge-batch --query 比亚迪 --query 最近热门概念
|
|
|
453
302
|
|
|
454
303
|
## 智能文件命名
|
|
455
304
|
|
|
456
|
-
下载命令(`summary download`、`research download`、`foreign-report download`、`announcement download`、`announcement-hk download`、`announcement-us download`、`official-account download`、`vault drive-download`、`vault record-download`、`vault my-conference-download`)省略 `--output` 时,自动使用真实标题作为文件名:
|
|
305
|
+
下载命令(`summary download`、`research download`、`foreign-report download`、`announcement download`、`announcement-hk download`、`announcement-us download`、`official-account download`、`performance-calendar download`、`vault drive-download`、`vault record-download`、`vault my-conference-download`)省略 `--output` 时,自动使用真实标题作为文件名:
|
|
457
306
|
|
|
458
307
|
1. **缓存优先** — 如果之前执行过对应的 `list` 命令,标题已缓存在 `~/.config/gangtise/title-cache.json`,直接使用,无额外 API 调用
|
|
459
308
|
2. **API 回查** — 缓存未命中时,自动查询最近 200 条记录匹配标题
|
|
@@ -530,6 +379,12 @@ gangtise insight report-image download --chunk-id image_10_384655917758685184_8
|
|
|
530
379
|
|
|
531
380
|
# 纪要下载(会议平台来源可选 HTML 格式)
|
|
532
381
|
gangtise insight summary download --summary-id 4906813 --file-type 2
|
|
382
|
+
|
|
383
|
+
# 财报日历:注意用 --start-date/--end-date(按 publishDate 过滤),不是 --start-time
|
|
384
|
+
gangtise insight performance-calendar list --start-date 2026-07-01 --end-date 2026-07-25 \
|
|
385
|
+
--market aShares --category performanceForecast --size 20 --format json
|
|
386
|
+
# 下载业绩报告原文(仅 hasAttachment: true 的记录;A股 10 积分 / 港美股 20 积分)
|
|
387
|
+
gangtise insight performance-calendar download --performance-report-id 33753017 --output ./业绩预告.pdf
|
|
533
388
|
```
|
|
534
389
|
|
|
535
390
|
### Reference
|
|
@@ -714,19 +569,31 @@ gangtise indicator search --keyword 收盘价 --format table # → q
|
|
|
714
569
|
gangtise indicator search --keyword 平均ROE --limit 5 --format json # 看 parameterList
|
|
715
570
|
|
|
716
571
|
# 截面:多指标 × 多证券,单日快照(行情类用交易日;财务类用报告期末,如 2026-03-31)
|
|
572
|
+
# --security 也接受板块 ID(reference sector-search 的 10 位 sectorId),与代码混传取并集
|
|
717
573
|
gangtise indicator cross-section \
|
|
718
574
|
--indicator qte_close --indicator qte_vol --indicator qte_mkt_cptl \
|
|
719
575
|
--security 600519.SH --security 09992.HK \
|
|
720
|
-
--date 2026-
|
|
576
|
+
--date 2026-07-31 --format table
|
|
577
|
+
# 输出列:security / name / <各指标名>…(v0.30.0 起无 date 列——日期挂在每个指标的参数上)
|
|
721
578
|
|
|
722
579
|
# 时间序列:多指标 × 单证券 或 单指标 × 多证券(不能多 × 多,否则报 410001)
|
|
723
580
|
gangtise indicator time-series --indicator qte_close \
|
|
724
581
|
--security 600519.SH --security 09992.HK \
|
|
725
|
-
--start-date 2026-
|
|
726
|
-
|
|
727
|
-
#
|
|
582
|
+
--start-date 2026-07-29 --end-date 2026-07-31 --format table
|
|
583
|
+
|
|
584
|
+
# 条件选股:F1/F2… 绑定指标,用表达式组合筛选(--indicator-param 按变量索引,不是按 code)
|
|
585
|
+
gangtise indicator screener \
|
|
586
|
+
--indicator F1:qte_mkt_cptl --indicator F2:finc_pe_ttm \
|
|
587
|
+
--indicator-param "F1:scale=8" \
|
|
588
|
+
--security 1000000287 \
|
|
589
|
+
--expression "F1 >= 500 && F2 <= 30" \
|
|
590
|
+
--date 2026-07-31 --format table
|
|
591
|
+
|
|
592
|
+
# 复权 / 指标专属参数用 --indicator-param "code:key=value"
|
|
593
|
+
# ⚠️ 参数名必须以 search 的 parameterList 为准:传错名服务端静默忽略、退回默认值,不报错
|
|
728
594
|
gangtise indicator cross-section --indicator qte_close --security 600519.SH \
|
|
729
|
-
--date
|
|
595
|
+
--date 2024-01-02 --indicator-param "qte_close:adjustType=3" # 1不复权/2前复权/3后复权/4定点
|
|
596
|
+
# 不复权 1685.01 → 前复权 1531.225 → 后复权 13609.6168(前复权在最新交易日等于不复权,验证要用历史日)
|
|
730
597
|
|
|
731
598
|
# 必填参数:很多指标默认调用报 410106(缺必填参数),按 parameterList 的 required 补齐再取:
|
|
732
599
|
# N 期统计补 periodNum、区间/周期类(如 qte_amp_mo 月振幅)补 startDate、年度/分红类补 fiscalYear
|
|
@@ -764,6 +631,19 @@ gangtise alternative concept-info --concept-id 121000130 --format json
|
|
|
764
631
|
gangtise alternative concept-securities --concept-id 121000130 --format json
|
|
765
632
|
```
|
|
766
633
|
|
|
634
|
+
### Tool(PDF 解析)
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
# 一步到位:上传 → 阻塞等待 → 结果 ZIP 落盘(含 file.md + images/)
|
|
638
|
+
gangtise tool file-parse --file ./研报.pdf --wait --output ./研报.zip
|
|
639
|
+
|
|
640
|
+
# 分两步:先提交拿 taskId(此时按页扣费 0.8/页),约 3 分钟后取结果(免费)
|
|
641
|
+
gangtise tool file-parse --file ./研报.pdf
|
|
642
|
+
gangtise tool file-parse-check --task-id 829081108954501120 --output ./研报.zip
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
限制:单文件 ≤100MB、≤500 页,同一用户最多 10 个并发任务;未就绪时 `file-parse-check` 输出 `{"status":"pending"}`(退出码 0),重试即可,不会重复扣费。
|
|
646
|
+
|
|
767
647
|
### Raw
|
|
768
648
|
|
|
769
649
|
```bash
|
|
@@ -815,7 +695,7 @@ CLI 会在本地校验常见数值参数,避免把明显非法的请求发到
|
|
|
815
695
|
| `999010` | 接口地址不存在(`raw call` 的 key 可能已下线,用 `raw list` 核对) |
|
|
816
696
|
| `999012` / `999013` / `999014` | 账号禁用 / 已过期 / 租户失效 |
|
|
817
697
|
| `999016` | 调用方 IP 不在允许范围 |
|
|
818
|
-
| `999999` | Gangtise 系统错误,请稍后重试(`indicator`
|
|
698
|
+
| `999999` | Gangtise 系统错误,请稍后重试(`indicator` 端点无数据已改为返回空表,此码基本只剩真故障) |
|
|
819
699
|
| `100003` | 参数值非法——**最宽的兜底码**;msg 通常已指明字段(如「limit 最小为 1,最大为 10000」),先读 msg |
|
|
820
700
|
| `100001` | 缺必填参数(msg 带字段名,如「缺少必填参数: reportId」) |
|
|
821
701
|
| `100006` | 查询/下载数量超限——**取代旧 `430007`** |
|
package/dist/src/cli.js
CHANGED
|
@@ -3,13 +3,14 @@ import { Command, Option } from "commander";
|
|
|
3
3
|
import { checkAsyncContent, pollAsyncContent, POLL_MAX_ATTEMPTS } from "./core/asyncContent.js";
|
|
4
4
|
import { readTokenCache, redactTokenCache } from "./core/auth.js";
|
|
5
5
|
import { collectKeyValue, collectList, collectNumberList, dateArg, datetimeArg, isVersionNewer, localDateString, maybeArray, parseChoiceList, parseFrom, parseNumberOption, parseOptionalNumberOption, parseSize, parseTimestamp13 } from "./core/args.js";
|
|
6
|
-
import { buildIndicatorCrossSectionBody, buildIndicatorTimeSeriesBody, buildQuoteKlineBody, buildStockPoolStocksBody, buildWechatChatroomListBody, buildWechatMessageListBody } from "./core/commandBodies.js";
|
|
6
|
+
import { buildIndicatorCrossSectionBody, buildIndicatorScreenerBody, buildIndicatorTimeSeriesBody, buildQuoteKlineBody, buildStockPoolStocksBody, buildWechatChatroomListBody, buildWechatMessageListBody } from "./core/commandBodies.js";
|
|
7
7
|
import { flattenCrossSection, flattenTimeSeries, unwrapIndicatorData } from "./core/indicatorMatrix.js";
|
|
8
8
|
import { callKlineWithSharding, isAllMarket, isFullMarket } from "./core/quoteSharding.js";
|
|
9
9
|
import { loadConfig } from "./core/config.js";
|
|
10
10
|
import { resolveTitle, saveDownloadResult, uniquePath } from "./core/download.js";
|
|
11
11
|
import { ENDPOINTS, listEndpoints } from "./core/endpoints.js";
|
|
12
12
|
import { ApiError, ConfigError, ValidationError } from "./core/errors.js";
|
|
13
|
+
import { fetchFileParseResult, pollFileParseResult, submitFileParse } from "./core/fileParse.js";
|
|
13
14
|
import { normalizeRows, zipFieldRow } from "./core/normalize.js";
|
|
14
15
|
import { parseOutputFormat } from "./core/output.js";
|
|
15
16
|
import { printData } from "./core/printer.js";
|
|
@@ -69,11 +70,11 @@ function flagIfLimitTruncated(data, cap, label) {
|
|
|
69
70
|
*/
|
|
70
71
|
async function runDownload(client, endpointKey, query, options) {
|
|
71
72
|
if (options.output) {
|
|
72
|
-
const result = await client.call(endpointKey,
|
|
73
|
+
const result = await client.call(endpointKey, options.body, query, { streamTo: options.output });
|
|
73
74
|
await saveDownloadResult(result, options.fallbackName, options.output);
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
const result = await client.call(endpointKey,
|
|
77
|
+
const result = await client.call(endpointKey, options.body, query);
|
|
77
78
|
const resolved = options.resolveOutputPath ? await options.resolveOutputPath(result) : undefined;
|
|
78
79
|
// Title-derived names are auto-generated too — dedupe them like the fallback names.
|
|
79
80
|
await saveDownloadResult(result, options.fallbackName, resolved ? await uniquePath(resolved) : undefined);
|
|
@@ -161,6 +162,7 @@ const roadshow = new Command("roadshow");
|
|
|
161
162
|
const siteVisit = new Command("site-visit");
|
|
162
163
|
const strategy = new Command("strategy");
|
|
163
164
|
const forum = new Command("forum");
|
|
165
|
+
const performanceCalendar = new Command("performance-calendar");
|
|
164
166
|
const research = new Command("research");
|
|
165
167
|
const foreignReport = new Command("foreign-report");
|
|
166
168
|
const announcement = new Command("announcement");
|
|
@@ -235,6 +237,79 @@ addScheduleList(siteVisit, "insight.site-visit.list", {
|
|
|
235
237
|
});
|
|
236
238
|
addScheduleList(strategy, "insight.strategy.list", { institution: true, location: true });
|
|
237
239
|
addScheduleList(forum, "insight.forum.list", { researchArea: true, location: true });
|
|
240
|
+
// Earnings calendar: the only insight list filtered by DATE (--start-date/--end-date
|
|
241
|
+
// on publishDate), not by the --start-time datetime every sibling uses — so it does
|
|
242
|
+
// not go through addTimeFilters. It also takes no --keyword / --rank-type / --search-type.
|
|
243
|
+
/** Row ceiling applied when `--security` is the only thing bounding a
|
|
244
|
+
* performance-calendar fetch. Far above any single company's calendar (a whole
|
|
245
|
+
* A-share history is dozens of rows), far below the 50k the auto-pagination
|
|
246
|
+
* would otherwise pull if the server ever stopped honoring securityList. */
|
|
247
|
+
const SECURITY_ONLY_ROW_CAP = 1000;
|
|
248
|
+
/** Warn + mark partial when a `--security`-only fetch lands on the cap with rows
|
|
249
|
+
* still unfetched: that is the signature of a filter that did not narrow anything,
|
|
250
|
+
* and the rows on screen are then a truncated slice of the whole calendar rather
|
|
251
|
+
* than a company's. `total` decides it — a result that happens to be exactly `cap`
|
|
252
|
+
* rows long IS complete (from + rows covers total) and must stay exit 0, or every
|
|
253
|
+
* automated caller reads a full answer as truncated. */
|
|
254
|
+
function flagIfImplicitCapHit(data, cap, from) {
|
|
255
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
256
|
+
return;
|
|
257
|
+
const rec = data;
|
|
258
|
+
if (!Array.isArray(rec.list) || rec.list.length < cap)
|
|
259
|
+
return;
|
|
260
|
+
const total = typeof rec.total === "number" ? rec.total : undefined;
|
|
261
|
+
if (total !== undefined && from + rec.list.length >= total)
|
|
262
|
+
return;
|
|
263
|
+
rec.partial = true;
|
|
264
|
+
process.stderr.write(`[gangtise] warning: --security was the only bound, so the fetch was capped at ${cap} rows and more remain (total=${String(rec.total)}) — the filter may not have narrowed anything. Re-run with --start-date/--end-date or an explicit --size.\n`);
|
|
265
|
+
}
|
|
266
|
+
const PERFORMANCE_MARKETS = ["aShares", "hkStocks", "usChinaConcept", "usStocks"];
|
|
267
|
+
const PERFORMANCE_CATEGORIES = ["performanceForecast", "performanceExpress", "performanceAnnouncement"];
|
|
268
|
+
performanceCalendar.command("list").description("Earnings calendar (业绩预告 / 快报 / 公告)")
|
|
269
|
+
.option("--from <number>", "Starting offset", "0")
|
|
270
|
+
.option("--size <number>", "Total rows to return; omit to fetch all")
|
|
271
|
+
.option("--start-date <date>", "Start date (yyyy-MM-dd), filters publishDate", dateArg("--start-date"))
|
|
272
|
+
.option("--end-date <date>", "End date (yyyy-MM-dd), filters publishDate", dateArg("--end-date"))
|
|
273
|
+
.option("--security <code>", "Security code (e.g. 000001.SZ)", collectList, [])
|
|
274
|
+
.option("--market <name>", `Market: ${PERFORMANCE_MARKETS.join("/")}`, collectList, [])
|
|
275
|
+
.option("--category <name>", `Event type: ${PERFORMANCE_CATEGORIES.join("/")}`, collectList, [])
|
|
276
|
+
.option("--format <format>", "Output format", "table").option("--output <path>", "Output path")
|
|
277
|
+
.action((options) => {
|
|
278
|
+
// Enum typos first: a misspelled --category is the likelier mistake, and its
|
|
279
|
+
// message is the more useful one when both checks would fire.
|
|
280
|
+
const marketList = parseChoiceList(options.market, "--market", PERFORMANCE_MARKETS);
|
|
281
|
+
const categoryList = parseChoiceList(options.category, "--category", PERFORMANCE_CATEGORIES);
|
|
282
|
+
// Unfiltered, this endpoint holds >120k rows (probed 2026-07-25: 126683, it
|
|
283
|
+
// also carries FUTURE scheduled events) and an omitted --size means "fetch
|
|
284
|
+
// everything" — 50k rows at the 1000-page cap, ~5000 credits at 0.1/row.
|
|
285
|
+
// Require a bound: a full date range, an explicit --size, or a security filter.
|
|
286
|
+
const explicitlyBounded = Boolean(options.size) || Boolean(options.startDate && options.endDate);
|
|
287
|
+
if (!explicitlyBounded && !options.security.length) {
|
|
288
|
+
throw new ValidationError("insight performance-calendar list without a bound would auto-paginate the whole calendar (>120k rows at 0.1 credits each): pass --start-date and --end-date, or --security, or an explicit --size");
|
|
289
|
+
}
|
|
290
|
+
// --security is only a real bound while the server honors securityList. It does
|
|
291
|
+
// today (probed 2026-07-25: an unknown or malformed code returns total 0, it is
|
|
292
|
+
// not silently ignored like a bad enum) — but a five-figure credit bill must not
|
|
293
|
+
// rest on that staying true. When --security is the ONLY bound, cap the fetch:
|
|
294
|
+
// one company's whole calendar is dozens of rows, so the cap is invisible in
|
|
295
|
+
// normal use and turns a filter regression into a truncated result (partial +
|
|
296
|
+
// exit 3) instead of a 5000-credit pull.
|
|
297
|
+
const implicitCap = explicitlyBounded ? undefined : SECURITY_ONLY_ROW_CAP;
|
|
298
|
+
const from = parseFrom(options.from);
|
|
299
|
+
return emit(options, async (client) => {
|
|
300
|
+
const data = await client.call("insight.performance-calendar.list", {
|
|
301
|
+
from, size: parseSize(options.size) ?? implicitCap,
|
|
302
|
+
startDate: options.startDate, endDate: options.endDate,
|
|
303
|
+
marketList,
|
|
304
|
+
securityList: maybeArray(options.security),
|
|
305
|
+
categoryList,
|
|
306
|
+
});
|
|
307
|
+
if (implicitCap)
|
|
308
|
+
flagIfImplicitCapHit(data, implicitCap, from);
|
|
309
|
+
return data;
|
|
310
|
+
}, { endpointKey: "insight.performance-calendar.list", idField: "performanceReportId" });
|
|
311
|
+
});
|
|
312
|
+
addDownloadCommand(performanceCalendar, { endpointKey: "insight.performance-calendar.download", idOption: "--performance-report-id", idField: "performanceReportId", fallbackPrefix: "performance-calendar", titleListEndpoint: "insight.performance-calendar.list" });
|
|
238
313
|
addTimeFilters(research.command("list").option("--search-type <number>", "Search type: 1=title 2=fulltext", "1").option("--rank-type <number>", "Rank type: 1=composite 2=time desc", "1").option("--broker <id>", "Broker ID", collectList, []).option("--security <code>", "Security code", collectList, []).option("--industry <id>", "Industry ID", collectList, []).option("--category <name>", "Report category", collectList, []).option("--llm-tag <tag>", "Semantic tag", collectList, []).option("--rating <name>", "Rating", collectList, []).option("--rating-change <name>", "Rating change", collectList, []).option("--min-pages <number>", "Min report pages").option("--max-pages <number>", "Max report pages").option("--source <type>", "Source type", collectList, []).option("--format <format>", "Output format", "table").option("--output <path>", "Output path")).action((options) => emit(options, (client) => client.call("insight.research.list", {
|
|
239
314
|
from: parseFrom(options.from), size: parseSize(options.size), startTime: options.startTime, endTime: options.endTime, keyword: options.keyword,
|
|
240
315
|
searchType: parseNumberOption(options.searchType, "--search-type", { integer: true, min: 1 }), rankType: parseNumberOption(options.rankType, "--rank-type", { integer: true, min: 1 }),
|
|
@@ -331,6 +406,7 @@ insight.addCommand(roadshow);
|
|
|
331
406
|
insight.addCommand(siteVisit);
|
|
332
407
|
insight.addCommand(strategy);
|
|
333
408
|
insight.addCommand(forum);
|
|
409
|
+
insight.addCommand(performanceCalendar);
|
|
334
410
|
insight.addCommand(research);
|
|
335
411
|
insight.addCommand(foreignReport);
|
|
336
412
|
insight.addCommand(announcement);
|
|
@@ -630,17 +706,53 @@ indicator.command("search").requiredOption("--keyword <text>", "Search keyword,
|
|
|
630
706
|
});
|
|
631
707
|
await printData(unwrapIndicatorData(raw), format, options.output);
|
|
632
708
|
}));
|
|
633
|
-
indicator.command("cross-section").option("--indicator <code>", "Indicator code, e.g. qte_close (repeat for multiple)", collectList, []).option("--security <code>", "Security code, e.g. 600519.SH (repeat
|
|
709
|
+
indicator.command("cross-section").option("--indicator <code>", "Indicator code, e.g. qte_close (repeat for multiple)", collectList, []).option("--security <code>", "Security code, e.g. 600519.SH, or a sector ID from 'gangtise reference sector-search' (repeat; union, deduped)", collectList, []).requiredOption("--date <date>", "Data date (yyyy-MM-dd); sent as each indicator's tradeDate — report-period indicators need --indicator-param 'code:reportDate=...' instead", dateArg("--date")).option("--currency <code>", "Currency: DFT/CNY/HKD/USD/EUR/GBP/JPY/TWD/MOP/AUD (default DFT)").option("--scale <code>", "Scale: 0=个 3=千 4=万 6=百万 8=亿 9=十亿 (default 0)").option("--indicator-param <spec>", "Per-indicator param 'code:key=value', e.g. qte_close:adjustType=2 for 前复权 (repeat); read exact keys from 'indicator search'", collectList, []).addOption(new Option("--key-by <mode>", "Column key: name=display name (default) | code=indicatorCode, unique & order-stable for batch code→value mapping").choices(["name", "code"]).default("name")).option("--format <format>", "Output format", "table").option("--output <path>").action((options) => withClient(async (client) => {
|
|
634
710
|
const format = parseOutputFormat(options.format);
|
|
635
711
|
const raw = await client.call("indicator.cross-section", buildIndicatorCrossSectionBody(options));
|
|
636
712
|
await printData(flattenCrossSection(unwrapIndicatorData(raw), options.keyBy), format, options.output);
|
|
637
713
|
}));
|
|
638
|
-
indicator.command("time-series").option("--indicator <code>", "Indicator code, e.g. qte_close (repeat for multiple)", collectList, []).option("--security <code>", "Security code, e.g. 600519.SH (repeat
|
|
714
|
+
indicator.command("time-series").option("--indicator <code>", "Indicator code, e.g. qte_close (repeat for multiple)", collectList, []).option("--security <code>", "Security code, e.g. 600519.SH, or a sector ID from 'gangtise reference sector-search' (repeat; union, deduped)", collectList, []).requiredOption("--start-date <date>", "Start date (yyyy-MM-dd)", dateArg("--start-date")).requiredOption("--end-date <date>", "End date (yyyy-MM-dd)", dateArg("--end-date")).option("--calendar-type <type>", "Calendar: ND=natural TD=trading WD=weekday (default TD)").option("--currency <code>", "Currency: DFT/CNY/HKD/USD/EUR/GBP/JPY/TWD/MOP/AUD (default DFT)").option("--scale <code>", "Scale: 0=个 3=千 4=万 6=百万 8=亿 9=十亿 (default 0)").option("--indicator-param <spec>", "Per-indicator param 'code:key=value', e.g. qte_close:adjustType=2 for 前复权 (repeat); read exact keys from 'indicator search'", collectList, []).addOption(new Option("--key-by <mode>", "Column key: name=display name (default) | code=indicatorCode/securityCode, unique & order-stable for batch mapping").choices(["name", "code"]).default("name")).option("--format <format>", "Output format", "table").option("--output <path>").action((options) => withClient(async (client) => {
|
|
639
715
|
const format = parseOutputFormat(options.format);
|
|
640
716
|
const raw = await client.call("indicator.time-series", buildIndicatorTimeSeriesBody(options));
|
|
641
717
|
await printData(flattenTimeSeries(unwrapIndicatorData(raw), options.keyBy), format, options.output);
|
|
642
718
|
}));
|
|
719
|
+
indicator.command("screener").description("Screen securities by an expression over indicator values (条件选股)").option("--indicator <spec>", "Bind a variable to an indicator, 'F1:code', e.g. F1:qte_mkt_cptl (repeat)", collectList, []).option("--security <code>", "Security code, e.g. 600519.SH, or a sector ID from 'gangtise reference sector-search' (repeat; union, deduped)", collectList, []).requiredOption("--expression <expr>", "Filter over the bound variables, e.g. 'F1 >= 800 && (F2 >= 20 && F2 <= 30)'; also supports contains/notcontains on string indicators").option("--date <date>", "Data date (yyyy-MM-dd); sent as each indicator's tradeDate unless it already has one", dateArg("--date")).option("--indicator-param <spec>", "Per-variable param 'F1:key=value', e.g. F1:scale=8 (repeat); read exact keys from 'indicator search'", collectList, []).addOption(new Option("--key-by <mode>", "Column key: name=display name (default) | code=indicatorCode").choices(["name", "code"]).default("name")).option("--format <format>", "Output format", "table").option("--output <path>").action((options) => withClient(async (client) => {
|
|
720
|
+
const format = parseOutputFormat(options.format);
|
|
721
|
+
const raw = await client.call("indicator.screener", buildIndicatorScreenerBody(options));
|
|
722
|
+
// Same payload shape as cross-section (one row per matched security, one
|
|
723
|
+
// column per indicator) with a `field` on each indicator entry.
|
|
724
|
+
await printData(flattenCrossSection(unwrapIndicatorData(raw), options.keyBy), format, options.output);
|
|
725
|
+
}));
|
|
643
726
|
program.addCommand(indicator);
|
|
727
|
+
const tool = new Command("tool").description("Research tool APIs: PDF parsing");
|
|
728
|
+
tool.command("file-parse").description("Parse a PDF into Markdown + images (async; 0.8 credits/page, billed at submit)")
|
|
729
|
+
.requiredOption("--file <path>", "PDF to upload (max 100MB / 500 pages)")
|
|
730
|
+
.option("--wait", "Wait for the parse to finish and save the result ZIP (blocking, up to ~5 min)")
|
|
731
|
+
.option("--output <path>", "Where to save the result ZIP (used with --wait)")
|
|
732
|
+
.action((options) => withClient(async (client) => {
|
|
733
|
+
const taskId = await submitFileParse(client, options.file);
|
|
734
|
+
if (!options.wait) {
|
|
735
|
+
process.stderr.write(`File parse task submitted. taskId: ${taskId}\n`);
|
|
736
|
+
process.stdout.write(`${JSON.stringify({ taskId, status: "pending", hint: `Run 'gangtise tool file-parse-check --task-id ${taskId}' in ~3 minutes to download the result ZIP` })}\n`);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
process.stderr.write(`Got taskId: ${taskId}, waiting for the parse to finish...\n`);
|
|
740
|
+
if (await pollFileParseResult(client, taskId, options.output) !== "ok") {
|
|
741
|
+
// Fetching the result is free and the task keeps running server-side —
|
|
742
|
+
// re-checking later costs nothing, resubmitting re-bills the whole file.
|
|
743
|
+
process.stderr.write(`Parse result not available after ${POLL_MAX_ATTEMPTS} attempts. Try again later with: gangtise tool file-parse-check --task-id ${taskId}\n`);
|
|
744
|
+
process.exitCode = 1;
|
|
745
|
+
}
|
|
746
|
+
}));
|
|
747
|
+
tool.command("file-parse-check").description("Download a finished file-parse result ZIP by taskId (free)")
|
|
748
|
+
.requiredOption("--task-id <id>", "taskId from 'tool file-parse'")
|
|
749
|
+
.option("--output <path>", "Where to save the result ZIP")
|
|
750
|
+
.action((options) => withClient(async (client) => {
|
|
751
|
+
if (await fetchFileParseResult(client, options.taskId, options.output) === "pending") {
|
|
752
|
+
process.stdout.write(`${JSON.stringify({ taskId: options.taskId, status: "pending", hint: "Parse not finished yet, retry in ~1 minute" })}\n`);
|
|
753
|
+
}
|
|
754
|
+
}));
|
|
755
|
+
program.addCommand(tool);
|
|
644
756
|
program.command("raw").description("Raw API calls").addCommand(new Command("call").argument("<endpointKey>").option("--body <json>").option("--query <key=value>", "Query string pair", collectKeyValue, {}).option("--format <format>", "Output format", "json").option("--output <path>").action(async (endpointKey, options) => {
|
|
645
757
|
const endpoint = ENDPOINTS[endpointKey];
|
|
646
758
|
if (!endpoint) {
|
|
@@ -660,12 +772,15 @@ program.command("raw").description("Raw API calls").addCommand(new Command("call
|
|
|
660
772
|
// Fail loudly on arguments the endpoint kind can't use — they used to be
|
|
661
773
|
// silently dropped, leaving the user to puzzle over server-side errors.
|
|
662
774
|
if (endpoint.kind === "download") {
|
|
663
|
-
|
|
664
|
-
|
|
775
|
+
// POST download endpoints (file-parse result) take their parameters as a JSON
|
|
776
|
+
// body; GET ones take --query and can't carry a body at all.
|
|
777
|
+
if (body !== undefined && endpoint.method !== "POST") {
|
|
778
|
+
throw new ValidationError(`--body is not supported for GET download endpoints (use --query key=value); ${endpointKey} is kind=download`);
|
|
665
779
|
}
|
|
666
780
|
await runDownload(client, endpointKey, options.query, {
|
|
667
781
|
output: options.output,
|
|
668
782
|
fallbackName: "download.bin",
|
|
783
|
+
body,
|
|
669
784
|
});
|
|
670
785
|
return;
|
|
671
786
|
}
|