Skip to content

Commit fae1dce

Browse files
feat(xueqiu): add earnings-date command (#211)
Add new YAML adapter to fetch upcoming earnings dates from xueqiu's company events API (公司大事). Supports A-share and H-share stocks. Features: - Filter by subtype=2 (预计财报发布) from event timeline - Show date, report name, and release status (⏳/✅) - --next flag to return only the closest upcoming earnings date - --limit to control result count Co-authored-by: nekomoto911 <nekomoto911@gmail.com>
1 parent d831b04 commit fae1dce

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/clis/xueqiu/earnings-date.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
site: xueqiu
2+
name: earnings-date
3+
description: 获取股票预计财报发布日期(公司大事)
4+
domain: xueqiu.com
5+
browser: true
6+
7+
args:
8+
symbol:
9+
type: str
10+
description: 股票代码,如 SH600519、SZ000858、00700
11+
next:
12+
type: bool
13+
default: false
14+
description: 仅返回最近一次未发布的财报日期
15+
limit:
16+
type: int
17+
default: 10
18+
description: 返回数量,默认 10
19+
20+
pipeline:
21+
- navigate: https://xueqiu.com
22+
- evaluate: |
23+
(async () => {
24+
const symbol = (${{ args.symbol | json }} || '').toUpperCase();
25+
const onlyNext = ${{ args.next }};
26+
if (!symbol) throw new Error('Missing argument: symbol');
27+
const resp = await fetch(
28+
`https://stock.xueqiu.com/v5/stock/screener/event/list.json?symbol=${encodeURIComponent(symbol)}&page=1&size=100`,
29+
{ credentials: 'include' }
30+
);
31+
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' Hint: Not logged in?');
32+
const d = await resp.json();
33+
if (!d.data || !d.data.items) throw new Error('获取失败: ' + JSON.stringify(d));
34+
35+
// subtype 2 = 预计财报发布
36+
let items = d.data.items.filter(item => item.subtype === 2);
37+
38+
const now = Date.now();
39+
let results = items.map(item => {
40+
const ts = item.timestamp;
41+
const dateStr = ts ? new Date(ts).toISOString().split('T')[0] : null;
42+
const isFuture = ts && ts > now;
43+
return {
44+
date: dateStr,
45+
report: item.message,
46+
status: isFuture ? '⏳ 未发布' : '✅ 已发布',
47+
_ts: ts,
48+
_future: isFuture
49+
};
50+
});
51+
52+
if (onlyNext) {
53+
const future = results.filter(r => r._future).sort((a, b) => a._ts - b._ts);
54+
results = future.length ? [future[0]] : [];
55+
}
56+
57+
return results;
58+
})()
59+
60+
- map:
61+
date: ${{ item.date }}
62+
report: ${{ item.report }}
63+
status: ${{ item.status }}
64+
65+
- limit: ${{ args.limit }}
66+
67+
columns: [date, report, status]

0 commit comments

Comments
 (0)