@hithink-tech/hithink-finance-cli 0.1.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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/SECURITY.md +3 -0
- package/dist/application/config.d.ts +44 -0
- package/dist/application/config.js +111 -0
- package/dist/application/ports/auth-provider.d.ts +23 -0
- package/dist/application/ports/auth-provider.js +2 -0
- package/dist/application/source-policy.d.ts +13 -0
- package/dist/application/source-policy.js +31 -0
- package/dist/application/use-cases/data-clean.d.ts +2 -0
- package/dist/application/use-cases/data-clean.js +18 -0
- package/dist/application/use-cases/data-init.d.ts +4 -0
- package/dist/application/use-cases/data-init.js +9 -0
- package/dist/application/use-cases/data-remove.d.ts +2 -0
- package/dist/application/use-cases/data-remove.js +27 -0
- package/dist/application/use-cases/data-repair.d.ts +5 -0
- package/dist/application/use-cases/data-repair.js +5 -0
- package/dist/application/use-cases/data-sync.d.ts +25 -0
- package/dist/application/use-cases/data-sync.js +55 -0
- package/dist/application/use-cases/local-query.d.ts +4 -0
- package/dist/application/use-cases/local-query.js +88 -0
- package/dist/application/use-cases/market-history.d.ts +8 -0
- package/dist/application/use-cases/market-history.js +16 -0
- package/dist/application/use-cases/market-panel.d.ts +3 -0
- package/dist/application/use-cases/market-panel.js +5 -0
- package/dist/application/use-cases/remote-query.d.ts +4 -0
- package/dist/application/use-cases/remote-query.js +66 -0
- package/dist/cli/context.d.ts +17 -0
- package/dist/cli/context.js +52 -0
- package/dist/cli/i18n.d.ts +23 -0
- package/dist/cli/i18n.js +150 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +80 -0
- package/dist/cli/program.d.ts +20 -0
- package/dist/cli/program.js +111 -0
- package/dist/commands/auth/index.d.ts +10 -0
- package/dist/commands/auth/index.js +131 -0
- package/dist/commands/config/index.d.ts +13 -0
- package/dist/commands/config/index.js +26 -0
- package/dist/commands/data/index.d.ts +10 -0
- package/dist/commands/data/index.js +185 -0
- package/dist/commands/db/index.d.ts +4 -0
- package/dist/commands/db/index.js +72 -0
- package/dist/commands/financials/index.d.ts +5 -0
- package/dist/commands/financials/index.js +6 -0
- package/dist/commands/index/index.d.ts +5 -0
- package/dist/commands/index/index.js +6 -0
- package/dist/commands/market/index.d.ts +5 -0
- package/dist/commands/market/index.js +6 -0
- package/dist/commands/market/local.d.ts +4 -0
- package/dist/commands/market/local.js +97 -0
- package/dist/commands/remote.d.ts +11 -0
- package/dist/commands/remote.js +195 -0
- package/dist/commands/skills/index.d.ts +4 -0
- package/dist/commands/skills/index.js +43 -0
- package/dist/commands/special/index.d.ts +5 -0
- package/dist/commands/special/index.js +6 -0
- package/dist/commands/symbol/index.d.ts +5 -0
- package/dist/commands/symbol/index.js +6 -0
- package/dist/commands/system/capabilities.d.ts +4 -0
- package/dist/commands/system/capabilities.js +24 -0
- package/dist/commands/system/doctor.d.ts +4 -0
- package/dist/commands/system/doctor.js +15 -0
- package/dist/commands/system/schema.d.ts +4 -0
- package/dist/commands/system/schema.js +47 -0
- package/dist/commands/system/uninstall.d.ts +11 -0
- package/dist/commands/system/uninstall.js +68 -0
- package/dist/commands/system/update.d.ts +11 -0
- package/dist/commands/system/update.js +72 -0
- package/dist/contracts/envelope.d.ts +37 -0
- package/dist/contracts/envelope.js +36 -0
- package/dist/contracts/errors.d.ts +23 -0
- package/dist/contracts/errors.js +33 -0
- package/dist/contracts/local-capabilities.d.ts +13 -0
- package/dist/contracts/local-capabilities.js +37 -0
- package/dist/contracts/registry.d.ts +9 -0
- package/dist/contracts/registry.js +4 -0
- package/dist/contracts/remote-capabilities.d.ts +24 -0
- package/dist/contracts/remote-capabilities.js +667 -0
- package/dist/domains/financials/types.d.ts +6 -0
- package/dist/domains/financials/types.js +2 -0
- package/dist/domains/index/types.d.ts +6 -0
- package/dist/domains/index/types.js +2 -0
- package/dist/domains/market/types.d.ts +6 -0
- package/dist/domains/market/types.js +2 -0
- package/dist/domains/special/types.d.ts +5 -0
- package/dist/domains/special/types.js +2 -0
- package/dist/domains/symbol/types.d.ts +6 -0
- package/dist/domains/symbol/types.js +2 -0
- package/dist/infrastructure/credentials/api-key-provider.d.ts +14 -0
- package/dist/infrastructure/credentials/api-key-provider.js +102 -0
- package/dist/infrastructure/credentials/keyring.d.ts +15 -0
- package/dist/infrastructure/credentials/keyring.js +21 -0
- package/dist/infrastructure/credentials/redact.d.ts +3 -0
- package/dist/infrastructure/credentials/redact.js +26 -0
- package/dist/infrastructure/duckdb/connection.d.ts +8 -0
- package/dist/infrastructure/duckdb/connection.js +18 -0
- package/dist/infrastructure/duckdb/dump-client.d.ts +20 -0
- package/dist/infrastructure/duckdb/dump-client.js +66 -0
- package/dist/infrastructure/duckdb/factors.d.ts +3 -0
- package/dist/infrastructure/duckdb/factors.js +83 -0
- package/dist/infrastructure/duckdb/importer.d.ts +11 -0
- package/dist/infrastructure/duckdb/importer.js +105 -0
- package/dist/infrastructure/duckdb/migrations.d.ts +17 -0
- package/dist/infrastructure/duckdb/migrations.js +92 -0
- package/dist/infrastructure/duckdb/quality.d.ts +12 -0
- package/dist/infrastructure/duckdb/quality.js +56 -0
- package/dist/infrastructure/duckdb/schema.d.ts +4 -0
- package/dist/infrastructure/duckdb/schema.js +14 -0
- package/dist/infrastructure/filesystem/atomic-file.d.ts +2 -0
- package/dist/infrastructure/filesystem/atomic-file.js +38 -0
- package/dist/infrastructure/filesystem/platform-paths.d.ts +15 -0
- package/dist/infrastructure/filesystem/platform-paths.js +42 -0
- package/dist/infrastructure/filesystem/process-lock.d.ts +6 -0
- package/dist/infrastructure/filesystem/process-lock.js +56 -0
- package/dist/infrastructure/filesystem/stdin.d.ts +5 -0
- package/dist/infrastructure/filesystem/stdin.js +9 -0
- package/dist/infrastructure/fuyao/client.d.ts +31 -0
- package/dist/infrastructure/fuyao/client.js +145 -0
- package/dist/infrastructure/fuyao/envelope.d.ts +9 -0
- package/dist/infrastructure/fuyao/envelope.js +8 -0
- package/dist/infrastructure/fuyao/pagination.d.ts +16 -0
- package/dist/infrastructure/fuyao/pagination.js +44 -0
- package/dist/infrastructure/fuyao/retry.d.ts +5 -0
- package/dist/infrastructure/fuyao/retry.js +18 -0
- package/dist/infrastructure/fuyao/windowing.d.ts +8 -0
- package/dist/infrastructure/fuyao/windowing.js +25 -0
- package/dist/infrastructure/skills/drift.d.ts +3 -0
- package/dist/infrastructure/skills/drift.js +8 -0
- package/dist/infrastructure/skills/installer.d.ts +13 -0
- package/dist/infrastructure/skills/installer.js +48 -0
- package/dist/infrastructure/skills/manifest.d.ts +11 -0
- package/dist/infrastructure/skills/manifest.js +62 -0
- package/dist/infrastructure/updater/cache.d.ts +15 -0
- package/dist/infrastructure/updater/cache.js +76 -0
- package/dist/infrastructure/updater/check.d.ts +13 -0
- package/dist/infrastructure/updater/check.js +51 -0
- package/dist/infrastructure/updater/install.d.ts +4 -0
- package/dist/infrastructure/updater/install.js +39 -0
- package/dist/output/json.d.ts +3 -0
- package/dist/output/json.js +16 -0
- package/dist/output/renderer.d.ts +4 -0
- package/dist/output/renderer.js +47 -0
- package/dist/output/table.d.ts +2 -0
- package/dist/output/table.js +31 -0
- package/migrations/001-initial.sql +95 -0
- package/migrations/manifest.json +12 -0
- package/package.json +66 -0
- package/schemas/capabilities.json +290 -0
- package/schemas/command-envelope.schema.json +12 -0
- package/scripts/postinstall.mjs +27 -0
- package/scripts/update-check.mjs +23 -0
- package/skills/hithink-finance-data/SKILL.md +74 -0
- package/skills/hithink-finance-data/references/data-clean.md +33 -0
- package/skills/hithink-finance-data/references/data-init.md +35 -0
- package/skills/hithink-finance-data/references/data-migrate.md +33 -0
- package/skills/hithink-finance-data/references/data-remove.md +33 -0
- package/skills/hithink-finance-data/references/data-repair.md +33 -0
- package/skills/hithink-finance-data/references/data-status.md +33 -0
- package/skills/hithink-finance-data/references/data-sync.md +34 -0
- package/skills/hithink-finance-data/references/data-validate.md +33 -0
- package/skills/hithink-finance-data/references/db-describe.md +33 -0
- package/skills/hithink-finance-data/references/db-export.md +33 -0
- package/skills/hithink-finance-data/references/db-query.md +33 -0
- package/skills/hithink-finance-financials/SKILL.md +59 -0
- package/skills/hithink-finance-financials/references/financials-balance-sheet.md +40 -0
- package/skills/hithink-finance-financials/references/financials-cash-flow.md +40 -0
- package/skills/hithink-finance-financials/references/financials-income.md +40 -0
- package/skills/hithink-finance-financials/references/financials-indicators.md +37 -0
- package/skills/hithink-finance-index/SKILL.md +59 -0
- package/skills/hithink-finance-index/references/index-catalog.md +36 -0
- package/skills/hithink-finance-index/references/index-constituents.md +36 -0
- package/skills/hithink-finance-index/references/index-history.md +38 -0
- package/skills/hithink-finance-index/references/index-snapshot.md +37 -0
- package/skills/hithink-finance-market/SKILL.md +63 -0
- package/skills/hithink-finance-market/references/market-adjustment-factors.md +33 -0
- package/skills/hithink-finance-market/references/market-calendar.md +35 -0
- package/skills/hithink-finance-market/references/market-corporate-actions.md +38 -0
- package/skills/hithink-finance-market/references/market-history.md +39 -0
- package/skills/hithink-finance-market/references/market-panel.md +33 -0
- package/skills/hithink-finance-market/references/market-snapshot.md +39 -0
- package/skills/hithink-finance-research/SKILL.md +58 -0
- package/skills/hithink-finance-research/references/research-workflow.md +34 -0
- package/skills/hithink-finance-shared/SKILL.md +55 -0
- package/skills/hithink-finance-shared/references/auth-and-config.md +31 -0
- package/skills/hithink-finance-shared/references/global-rules.md +21 -0
- package/skills/hithink-finance-shared/references/lifecycle.md +23 -0
- package/skills/hithink-finance-shared/references/skills-management.md +22 -0
- package/skills/hithink-finance-special-data/SKILL.md +68 -0
- package/skills/hithink-finance-special-data/references/special-anomaly-list.md +36 -0
- package/skills/hithink-finance-special-data/references/special-anomaly-stock.md +37 -0
- package/skills/hithink-finance-special-data/references/special-dragon-tiger.md +37 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock-history.md +36 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock-trend.md +38 -0
- package/skills/hithink-finance-special-data/references/special-hot-stock.md +36 -0
- package/skills/hithink-finance-special-data/references/special-limit-up-ladder.md +35 -0
- package/skills/hithink-finance-special-data/references/special-limit-up-pool.md +40 -0
- package/skills/hithink-finance-special-data/references/special-skyrocket.md +36 -0
- package/skills/hithink-finance-symbol/SKILL.md +56 -0
- package/skills/hithink-finance-symbol/references/symbol-list.md +39 -0
- package/skills/hithink-finance-symbol/references/symbol-search.md +39 -0
- package/skills/manifest.json +55 -0
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
|
|
3
|
+
const aShareCode = z.string().regex(/^\d{6}\.(SH|SZ|BJ)$/iu);
|
|
4
|
+
const indexCode = z.string().regex(/^\d{6}\.(SH|SZ|BJ|TI)$/iu);
|
|
5
|
+
const commaCodes = z.string().min(1);
|
|
6
|
+
const record = z.record(z.string(), z.unknown());
|
|
7
|
+
const itemOutput = z.object({ item: z.array(record) }).passthrough();
|
|
8
|
+
const objectOutput = z.object({}).passthrough();
|
|
9
|
+
const historyInput = z
|
|
10
|
+
.object({
|
|
11
|
+
thscode: aShareCode,
|
|
12
|
+
startMs: z.number().int().nonnegative(),
|
|
13
|
+
endMs: z.number().int().nonnegative(),
|
|
14
|
+
adjust: z.enum(['none', 'forward', 'backward']).default('forward'),
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
.refine((value) => value.endMs >= value.startMs, { message: 'end-ms must be >= start-ms' });
|
|
18
|
+
const indexHistoryInput = z
|
|
19
|
+
.object({
|
|
20
|
+
thscode: indexCode,
|
|
21
|
+
startMs: z.number().int().nonnegative(),
|
|
22
|
+
endMs: z.number().int().nonnegative(),
|
|
23
|
+
})
|
|
24
|
+
.strict()
|
|
25
|
+
.refine((value) => value.endMs >= value.startMs, { message: 'end-ms must be >= start-ms' });
|
|
26
|
+
const financialInput = z
|
|
27
|
+
.object({
|
|
28
|
+
thscode: aShareCode,
|
|
29
|
+
period: z.enum(['annual', 'quarterly']).default('annual'),
|
|
30
|
+
limit: z.number().int().min(1).max(20).optional(),
|
|
31
|
+
startMs: z.number().int().nonnegative().optional(),
|
|
32
|
+
endMs: z.number().int().nonnegative().optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict()
|
|
35
|
+
.superRefine((value, context) => {
|
|
36
|
+
const hasStart = value.startMs !== undefined;
|
|
37
|
+
const hasEnd = value.endMs !== undefined;
|
|
38
|
+
if (hasStart !== hasEnd) {
|
|
39
|
+
context.addIssue({
|
|
40
|
+
code: 'custom',
|
|
41
|
+
message: 'start-ms and end-ms must be provided together',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if ((hasStart || hasEnd) && value.limit !== undefined) {
|
|
45
|
+
context.addIssue({ code: 'custom', message: 'limit and date range are mutually exclusive' });
|
|
46
|
+
}
|
|
47
|
+
if (hasStart && hasEnd && value.endMs < value.startMs) {
|
|
48
|
+
context.addIssue({ code: 'custom', message: 'end-ms must be >= start-ms' });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const financialOptions = [
|
|
52
|
+
{
|
|
53
|
+
flags: '--thscode <code>',
|
|
54
|
+
description: 'single A-share thscode',
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: true,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
flags: '--period <period>',
|
|
60
|
+
description: 'financial period',
|
|
61
|
+
type: 'string',
|
|
62
|
+
choices: ['annual', 'quarterly'],
|
|
63
|
+
defaultValue: 'annual',
|
|
64
|
+
},
|
|
65
|
+
{ flags: '--limit <number>', description: 'recent report count (1-20)', type: 'integer' },
|
|
66
|
+
{
|
|
67
|
+
flags: '--start-ms <milliseconds>',
|
|
68
|
+
description: 'range start in milliseconds',
|
|
69
|
+
type: 'integer',
|
|
70
|
+
queryName: 'start',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
flags: '--end-ms <milliseconds>',
|
|
74
|
+
description: 'range end in milliseconds',
|
|
75
|
+
type: 'integer',
|
|
76
|
+
queryName: 'end',
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
function financial(id, command, endpoint) {
|
|
80
|
+
return {
|
|
81
|
+
id,
|
|
82
|
+
command: ['financials', command],
|
|
83
|
+
description: `Query ${command} financial statements`,
|
|
84
|
+
endpoint,
|
|
85
|
+
method: 'GET',
|
|
86
|
+
inputSchema: financialInput,
|
|
87
|
+
outputSchema: itemOutput,
|
|
88
|
+
options: financialOptions,
|
|
89
|
+
paging: 'none',
|
|
90
|
+
window: 'ten-years',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export const remoteCapabilities = [
|
|
94
|
+
{
|
|
95
|
+
id: 'symbol.search',
|
|
96
|
+
command: ['symbol', 'search'],
|
|
97
|
+
description: 'Resolve a name or code to thscode',
|
|
98
|
+
endpoint: '/api/meta/tickers/search',
|
|
99
|
+
method: 'GET',
|
|
100
|
+
inputSchema: z
|
|
101
|
+
.object({
|
|
102
|
+
q: z.string().min(1),
|
|
103
|
+
exchange: z.enum(['SH', 'SZ', 'BJ']).optional(),
|
|
104
|
+
assetType: z.enum(['a-share', 'a-share-index']).optional(),
|
|
105
|
+
limit: z.number().int().min(1).max(50).default(10),
|
|
106
|
+
})
|
|
107
|
+
.strict(),
|
|
108
|
+
outputSchema: itemOutput,
|
|
109
|
+
options: [
|
|
110
|
+
{
|
|
111
|
+
flags: '--q <query>',
|
|
112
|
+
description: 'name, ticker, or thscode',
|
|
113
|
+
type: 'string',
|
|
114
|
+
required: true,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
flags: '--exchange <exchange>',
|
|
118
|
+
description: 'exchange filter',
|
|
119
|
+
type: 'string',
|
|
120
|
+
choices: ['SH', 'SZ', 'BJ'],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
flags: '--asset-type <type>',
|
|
124
|
+
description: 'asset type',
|
|
125
|
+
type: 'string',
|
|
126
|
+
choices: ['a-share', 'a-share-index'],
|
|
127
|
+
queryName: 'asset_type',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
flags: '--limit <number>',
|
|
131
|
+
description: 'maximum matches (1-50)',
|
|
132
|
+
type: 'integer',
|
|
133
|
+
defaultValue: 10,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
paging: 'none',
|
|
137
|
+
window: 'none',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'symbol.list',
|
|
141
|
+
command: ['symbol', 'list'],
|
|
142
|
+
description: 'List symbols with bounded pagination',
|
|
143
|
+
endpoint: '/api/meta/tickers/list',
|
|
144
|
+
method: 'GET',
|
|
145
|
+
inputSchema: z
|
|
146
|
+
.object({
|
|
147
|
+
exchange: z.string().default('SH,SZ'),
|
|
148
|
+
assetType: z.enum(['a-share', 'a-share-index']).default('a-share'),
|
|
149
|
+
limit: z.number().int().min(1).max(10000).default(1000),
|
|
150
|
+
offset: z.number().int().nonnegative().default(0),
|
|
151
|
+
})
|
|
152
|
+
.strict(),
|
|
153
|
+
outputSchema: itemOutput,
|
|
154
|
+
options: [
|
|
155
|
+
{
|
|
156
|
+
flags: '--exchange <exchanges>',
|
|
157
|
+
description: 'comma-separated exchanges',
|
|
158
|
+
type: 'string',
|
|
159
|
+
defaultValue: 'SH,SZ',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
flags: '--asset-type <type>',
|
|
163
|
+
description: 'asset type',
|
|
164
|
+
type: 'string',
|
|
165
|
+
choices: ['a-share', 'a-share-index'],
|
|
166
|
+
defaultValue: 'a-share',
|
|
167
|
+
queryName: 'asset_type',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
flags: '--limit <number>',
|
|
171
|
+
description: 'page size (1-10000)',
|
|
172
|
+
type: 'integer',
|
|
173
|
+
defaultValue: 1000,
|
|
174
|
+
},
|
|
175
|
+
{ flags: '--offset <number>', description: 'row offset', type: 'integer', defaultValue: 0 },
|
|
176
|
+
],
|
|
177
|
+
paging: 'offset',
|
|
178
|
+
window: 'none',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: 'market.snapshot',
|
|
182
|
+
command: ['market', 'snapshot'],
|
|
183
|
+
description: 'Query A-share price snapshots',
|
|
184
|
+
endpoint: '/api/a-share/prices/snapshot',
|
|
185
|
+
method: 'GET',
|
|
186
|
+
inputSchema: z
|
|
187
|
+
.object({
|
|
188
|
+
thscodes: commaCodes.optional(),
|
|
189
|
+
limit: z.number().int().min(1).max(10000).default(100),
|
|
190
|
+
offset: z.number().int().nonnegative().default(0),
|
|
191
|
+
})
|
|
192
|
+
.strict(),
|
|
193
|
+
outputSchema: itemOutput,
|
|
194
|
+
options: [
|
|
195
|
+
{
|
|
196
|
+
flags: '--thscodes <codes>',
|
|
197
|
+
description: 'comma-separated A-share thscodes',
|
|
198
|
+
type: 'string',
|
|
199
|
+
},
|
|
200
|
+
{ flags: '--limit <number>', description: 'page size', type: 'integer', defaultValue: 100 },
|
|
201
|
+
{ flags: '--offset <number>', description: 'row offset', type: 'integer', defaultValue: 0 },
|
|
202
|
+
],
|
|
203
|
+
paging: 'offset',
|
|
204
|
+
window: 'none',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: 'market.history',
|
|
208
|
+
command: ['market', 'history'],
|
|
209
|
+
description: 'Query daily A-share history',
|
|
210
|
+
endpoint: '/api/a-share/prices/historical',
|
|
211
|
+
method: 'GET',
|
|
212
|
+
inputSchema: historyInput,
|
|
213
|
+
outputSchema: itemOutput,
|
|
214
|
+
options: [
|
|
215
|
+
{
|
|
216
|
+
flags: '--thscode <code>',
|
|
217
|
+
description: 'single A-share thscode',
|
|
218
|
+
type: 'string',
|
|
219
|
+
required: true,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
flags: '--start-ms <milliseconds>',
|
|
223
|
+
description: 'start timestamp',
|
|
224
|
+
type: 'integer',
|
|
225
|
+
required: true,
|
|
226
|
+
queryName: 'start',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
flags: '--end-ms <milliseconds>',
|
|
230
|
+
description: 'end timestamp',
|
|
231
|
+
type: 'integer',
|
|
232
|
+
required: true,
|
|
233
|
+
queryName: 'end',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
flags: '--adjust <mode>',
|
|
237
|
+
description: 'adjustment mode',
|
|
238
|
+
type: 'string',
|
|
239
|
+
choices: ['none', 'forward', 'backward'],
|
|
240
|
+
defaultValue: 'forward',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
paging: 'none',
|
|
244
|
+
window: 'ten-years',
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: 'market.corporate-actions',
|
|
248
|
+
command: ['market', 'corporate-actions'],
|
|
249
|
+
description: 'Query adjustment events',
|
|
250
|
+
endpoint: '/api/a-share/corporate-actions/adjustment-factors',
|
|
251
|
+
method: 'GET',
|
|
252
|
+
inputSchema: z
|
|
253
|
+
.object({ thscode: aShareCode, fromDate: isoDate.optional(), toDate: isoDate.optional() })
|
|
254
|
+
.strict(),
|
|
255
|
+
outputSchema: itemOutput,
|
|
256
|
+
options: [
|
|
257
|
+
{
|
|
258
|
+
flags: '--thscode <code>',
|
|
259
|
+
description: 'single A-share thscode',
|
|
260
|
+
type: 'string',
|
|
261
|
+
required: true,
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
flags: '--from-date <date>',
|
|
265
|
+
description: 'first ex-date YYYY-MM-DD',
|
|
266
|
+
type: 'string',
|
|
267
|
+
queryName: 'from',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
flags: '--to-date <date>',
|
|
271
|
+
description: 'last ex-date YYYY-MM-DD',
|
|
272
|
+
type: 'string',
|
|
273
|
+
queryName: 'to',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
paging: 'none',
|
|
277
|
+
window: 'none',
|
|
278
|
+
},
|
|
279
|
+
financial('financials.income', 'income', '/api/a-share/financials/income-statements'),
|
|
280
|
+
financial('financials.balance-sheet', 'balance-sheet', '/api/a-share/financials/balance-sheets'),
|
|
281
|
+
financial('financials.cash-flow', 'cash-flow', '/api/a-share/financials/cash-flow-statements'),
|
|
282
|
+
{
|
|
283
|
+
id: 'financials.indicators',
|
|
284
|
+
command: ['financials', 'indicators'],
|
|
285
|
+
description: 'Query financial indicators for a report',
|
|
286
|
+
endpoint: '/api/a-share/financials/indicators',
|
|
287
|
+
method: 'GET',
|
|
288
|
+
inputSchema: z
|
|
289
|
+
.object({ thscode: aShareCode, report: z.string().regex(/^\d{4}-[1-4]$/u) })
|
|
290
|
+
.strict(),
|
|
291
|
+
outputSchema: z.object({ abilities: z.array(record) }).passthrough(),
|
|
292
|
+
options: [
|
|
293
|
+
{
|
|
294
|
+
flags: '--thscode <code>',
|
|
295
|
+
description: 'single A-share thscode',
|
|
296
|
+
type: 'string',
|
|
297
|
+
required: true,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
flags: '--report <period>',
|
|
301
|
+
description: 'report quarter YYYY-[1-4]',
|
|
302
|
+
type: 'string',
|
|
303
|
+
required: true,
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
paging: 'none',
|
|
307
|
+
window: 'none',
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: 'market.calendar',
|
|
311
|
+
command: ['market', 'calendar'],
|
|
312
|
+
description: 'Query the one-year A-share trading calendar',
|
|
313
|
+
endpoint: '/api/a-share/calendar/trading-days',
|
|
314
|
+
method: 'GET',
|
|
315
|
+
inputSchema: z.object({}).strict(),
|
|
316
|
+
outputSchema: itemOutput,
|
|
317
|
+
options: [],
|
|
318
|
+
paging: 'none',
|
|
319
|
+
window: 'one-year',
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
id: 'index.catalog',
|
|
323
|
+
command: ['index', 'catalog'],
|
|
324
|
+
description: 'List THS indices by category',
|
|
325
|
+
endpoint: '/api/a-share-index/catalog/ths-index-list',
|
|
326
|
+
method: 'GET',
|
|
327
|
+
inputSchema: z
|
|
328
|
+
.object({ tag: z.enum(['cn_concept', 'region', 'tszs', 'industry']).default('cn_concept') })
|
|
329
|
+
.strict(),
|
|
330
|
+
outputSchema: itemOutput,
|
|
331
|
+
options: [
|
|
332
|
+
{
|
|
333
|
+
flags: '--tag <tag>',
|
|
334
|
+
description: 'index category',
|
|
335
|
+
type: 'string',
|
|
336
|
+
choices: ['cn_concept', 'region', 'tszs', 'industry'],
|
|
337
|
+
defaultValue: 'cn_concept',
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
paging: 'none',
|
|
341
|
+
window: 'none',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: 'index.constituents',
|
|
345
|
+
command: ['index', 'constituents'],
|
|
346
|
+
description: 'Query index constituents',
|
|
347
|
+
endpoint: '/api/a-share-index/constituents/ths-stock-list',
|
|
348
|
+
method: 'GET',
|
|
349
|
+
inputSchema: z.object({ thscode: indexCode }).strict(),
|
|
350
|
+
outputSchema: itemOutput,
|
|
351
|
+
options: [
|
|
352
|
+
{
|
|
353
|
+
flags: '--thscode <code>',
|
|
354
|
+
description: 'single index thscode',
|
|
355
|
+
type: 'string',
|
|
356
|
+
required: true,
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
paging: 'none',
|
|
360
|
+
window: 'none',
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
id: 'index.snapshot',
|
|
364
|
+
command: ['index', 'snapshot'],
|
|
365
|
+
description: 'Query index price snapshots',
|
|
366
|
+
endpoint: '/api/a-share-index/prices/snapshot',
|
|
367
|
+
method: 'GET',
|
|
368
|
+
inputSchema: z.object({ thscodes: commaCodes }).strict(),
|
|
369
|
+
outputSchema: itemOutput,
|
|
370
|
+
options: [
|
|
371
|
+
{
|
|
372
|
+
flags: '--thscodes <codes>',
|
|
373
|
+
description: 'comma-separated index thscodes',
|
|
374
|
+
type: 'string',
|
|
375
|
+
required: true,
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
paging: 'none',
|
|
379
|
+
window: 'none',
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
id: 'index.history',
|
|
383
|
+
command: ['index', 'history'],
|
|
384
|
+
description: 'Query daily index history',
|
|
385
|
+
endpoint: '/api/a-share-index/prices/historical',
|
|
386
|
+
method: 'GET',
|
|
387
|
+
inputSchema: indexHistoryInput,
|
|
388
|
+
outputSchema: itemOutput,
|
|
389
|
+
options: [
|
|
390
|
+
{
|
|
391
|
+
flags: '--thscode <code>',
|
|
392
|
+
description: 'single index thscode',
|
|
393
|
+
type: 'string',
|
|
394
|
+
required: true,
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
flags: '--start-ms <milliseconds>',
|
|
398
|
+
description: 'start timestamp',
|
|
399
|
+
type: 'integer',
|
|
400
|
+
required: true,
|
|
401
|
+
queryName: 'start',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
flags: '--end-ms <milliseconds>',
|
|
405
|
+
description: 'end timestamp',
|
|
406
|
+
type: 'integer',
|
|
407
|
+
required: true,
|
|
408
|
+
queryName: 'end',
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
paging: 'none',
|
|
412
|
+
window: 'ten-years',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
id: 'special.limit-up-pool',
|
|
416
|
+
command: ['special', 'limit-up-pool'],
|
|
417
|
+
description: 'Query the limit-up stock pool',
|
|
418
|
+
endpoint: '/api/a-share/special-data/limit-up-pool',
|
|
419
|
+
method: 'GET',
|
|
420
|
+
inputSchema: z
|
|
421
|
+
.object({
|
|
422
|
+
dateMs: z.number().int().nonnegative().optional(),
|
|
423
|
+
page: z.number().int().min(1).default(1),
|
|
424
|
+
size: z.number().int().min(1).max(200).default(50),
|
|
425
|
+
sortField: z
|
|
426
|
+
.enum(['last_price', 'continue_day_cnt', 'seal_money', 'limit_up_time'])
|
|
427
|
+
.default('last_price'),
|
|
428
|
+
sortDir: z.enum(['asc', 'desc']).default('desc'),
|
|
429
|
+
})
|
|
430
|
+
.strict(),
|
|
431
|
+
outputSchema: itemOutput,
|
|
432
|
+
options: [
|
|
433
|
+
{
|
|
434
|
+
flags: '--date-ms <milliseconds>',
|
|
435
|
+
description: 'trade date at Asia/Shanghai midnight',
|
|
436
|
+
type: 'integer',
|
|
437
|
+
queryName: 'date_ms',
|
|
438
|
+
},
|
|
439
|
+
{ flags: '--page <number>', description: 'page number', type: 'integer', defaultValue: 1 },
|
|
440
|
+
{
|
|
441
|
+
flags: '--size <number>',
|
|
442
|
+
description: 'page size (1-200)',
|
|
443
|
+
type: 'integer',
|
|
444
|
+
defaultValue: 50,
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
flags: '--sort-field <field>',
|
|
448
|
+
description: 'sort field',
|
|
449
|
+
type: 'string',
|
|
450
|
+
choices: ['last_price', 'continue_day_cnt', 'seal_money', 'limit_up_time'],
|
|
451
|
+
defaultValue: 'last_price',
|
|
452
|
+
queryName: 'sort_field',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
flags: '--sort-dir <direction>',
|
|
456
|
+
description: 'sort direction',
|
|
457
|
+
type: 'string',
|
|
458
|
+
choices: ['asc', 'desc'],
|
|
459
|
+
defaultValue: 'desc',
|
|
460
|
+
queryName: 'sort_dir',
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
paging: 'page',
|
|
464
|
+
window: 'none',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
id: 'special.limit-up-ladder',
|
|
468
|
+
command: ['special', 'limit-up-ladder'],
|
|
469
|
+
description: 'Query the 30-day limit-up ladder',
|
|
470
|
+
endpoint: '/api/a-share/special-data/limit-up-ladder',
|
|
471
|
+
method: 'GET',
|
|
472
|
+
inputSchema: z.object({}).strict(),
|
|
473
|
+
outputSchema: itemOutput,
|
|
474
|
+
options: [],
|
|
475
|
+
paging: 'none',
|
|
476
|
+
window: 'none',
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
id: 'special.anomaly-list',
|
|
480
|
+
command: ['special', 'anomaly-list'],
|
|
481
|
+
description: 'Query today-only anomaly analysis rows',
|
|
482
|
+
endpoint: '/api/a-share/special-data/anomaly-analysis-list',
|
|
483
|
+
method: 'GET',
|
|
484
|
+
inputSchema: z
|
|
485
|
+
.object({
|
|
486
|
+
tagCodes: z
|
|
487
|
+
.string()
|
|
488
|
+
.refine((value) => value
|
|
489
|
+
.split(',')
|
|
490
|
+
.every((token) => [
|
|
491
|
+
'LIMIT_UP',
|
|
492
|
+
'LIMIT_DOWN',
|
|
493
|
+
'SHARP_RISE',
|
|
494
|
+
'SHARP_FALL',
|
|
495
|
+
'RAPID_RALLY',
|
|
496
|
+
'RAPID_DECLINE',
|
|
497
|
+
].includes(token.toUpperCase()) && token.length > 0))
|
|
498
|
+
.optional(),
|
|
499
|
+
})
|
|
500
|
+
.strict(),
|
|
501
|
+
outputSchema: itemOutput,
|
|
502
|
+
options: [
|
|
503
|
+
{
|
|
504
|
+
flags: '--tag-codes <codes>',
|
|
505
|
+
description: 'comma-separated anomaly tags',
|
|
506
|
+
type: 'string',
|
|
507
|
+
queryName: 'tag_codes',
|
|
508
|
+
},
|
|
509
|
+
],
|
|
510
|
+
paging: 'none',
|
|
511
|
+
window: 'today-only',
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
id: 'special.anomaly-stock',
|
|
515
|
+
command: ['special', 'anomaly-stock'],
|
|
516
|
+
description: 'Query today-only anomalies for up to 50 raw code tokens',
|
|
517
|
+
endpoint: '/api/a-share/special-data/anomaly-analysis-stock',
|
|
518
|
+
method: 'GET',
|
|
519
|
+
inputSchema: z
|
|
520
|
+
.object({
|
|
521
|
+
thscodes: z.string().superRefine((value, context) => {
|
|
522
|
+
const tokens = value.split(',');
|
|
523
|
+
if (tokens.length > 50)
|
|
524
|
+
context.addIssue({ code: 'custom', message: 'at most 50 raw tokens' });
|
|
525
|
+
if (tokens.some((token) => !/^\d{6}\.(SH|SZ|BJ)$/iu.test(token)))
|
|
526
|
+
context.addIssue({ code: 'custom', message: 'invalid or empty A-share token' });
|
|
527
|
+
}),
|
|
528
|
+
})
|
|
529
|
+
.strict(),
|
|
530
|
+
outputSchema: itemOutput,
|
|
531
|
+
options: [
|
|
532
|
+
{
|
|
533
|
+
flags: '--thscodes <codes>',
|
|
534
|
+
description: '1-50 comma-separated A-share thscodes',
|
|
535
|
+
type: 'string',
|
|
536
|
+
required: true,
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
paging: 'none',
|
|
540
|
+
window: 'today-only',
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: 'special.skyrocket',
|
|
544
|
+
command: ['special', 'skyrocket'],
|
|
545
|
+
description: 'Query the skyrocket ranking',
|
|
546
|
+
endpoint: '/api/a-share/special-data/skyrocket-list',
|
|
547
|
+
method: 'GET',
|
|
548
|
+
inputSchema: z.object({ period: z.enum(['day', 'hour']).default('day') }).strict(),
|
|
549
|
+
outputSchema: itemOutput,
|
|
550
|
+
options: [
|
|
551
|
+
{
|
|
552
|
+
flags: '--period <period>',
|
|
553
|
+
description: 'ranking period',
|
|
554
|
+
type: 'string',
|
|
555
|
+
choices: ['day', 'hour'],
|
|
556
|
+
defaultValue: 'day',
|
|
557
|
+
},
|
|
558
|
+
],
|
|
559
|
+
paging: 'none',
|
|
560
|
+
window: 'none',
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
id: 'special.hot-stock',
|
|
564
|
+
command: ['special', 'hot-stock'],
|
|
565
|
+
description: 'Query the current hot-stock ranking',
|
|
566
|
+
endpoint: '/api/a-share/special-data/hot-stock-list',
|
|
567
|
+
method: 'GET',
|
|
568
|
+
inputSchema: z.object({ period: z.enum(['day', 'hour']).default('day') }).strict(),
|
|
569
|
+
outputSchema: itemOutput,
|
|
570
|
+
options: [
|
|
571
|
+
{
|
|
572
|
+
flags: '--period <period>',
|
|
573
|
+
description: 'ranking period',
|
|
574
|
+
type: 'string',
|
|
575
|
+
choices: ['day', 'hour'],
|
|
576
|
+
defaultValue: 'day',
|
|
577
|
+
},
|
|
578
|
+
],
|
|
579
|
+
paging: 'none',
|
|
580
|
+
window: 'none',
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
id: 'special.hot-stock-history',
|
|
584
|
+
command: ['special', 'hot-stock-history'],
|
|
585
|
+
description: 'Query a historical hot-stock ranking',
|
|
586
|
+
endpoint: '/api/a-share/special-data/hot-stock-list-history',
|
|
587
|
+
method: 'GET',
|
|
588
|
+
inputSchema: z.object({ date: isoDate }).strict(),
|
|
589
|
+
outputSchema: itemOutput,
|
|
590
|
+
options: [
|
|
591
|
+
{
|
|
592
|
+
flags: '--date <date>',
|
|
593
|
+
description: 'trade date YYYY-MM-DD',
|
|
594
|
+
type: 'string',
|
|
595
|
+
required: true,
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
paging: 'none',
|
|
599
|
+
window: 'one-year',
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: 'special.hot-stock-trend',
|
|
603
|
+
command: ['special', 'hot-stock-trend'],
|
|
604
|
+
description: 'Query one stock hot-rank trend',
|
|
605
|
+
endpoint: '/api/a-share/special-data/hot-stock-rank-trend',
|
|
606
|
+
method: 'GET',
|
|
607
|
+
inputSchema: z
|
|
608
|
+
.object({ thscode: aShareCode, startDate: isoDate, endDate: isoDate })
|
|
609
|
+
.strict()
|
|
610
|
+
.refine((value) => value.startDate <= value.endDate, {
|
|
611
|
+
message: 'start-date must be <= end-date',
|
|
612
|
+
}),
|
|
613
|
+
outputSchema: itemOutput,
|
|
614
|
+
options: [
|
|
615
|
+
{
|
|
616
|
+
flags: '--thscode <code>',
|
|
617
|
+
description: 'single A-share thscode',
|
|
618
|
+
type: 'string',
|
|
619
|
+
required: true,
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
flags: '--start-date <date>',
|
|
623
|
+
description: 'start date YYYY-MM-DD',
|
|
624
|
+
type: 'string',
|
|
625
|
+
required: true,
|
|
626
|
+
queryName: 'start_date',
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
flags: '--end-date <date>',
|
|
630
|
+
description: 'end date YYYY-MM-DD',
|
|
631
|
+
type: 'string',
|
|
632
|
+
required: true,
|
|
633
|
+
queryName: 'end_date',
|
|
634
|
+
},
|
|
635
|
+
],
|
|
636
|
+
paging: 'none',
|
|
637
|
+
window: 'one-year',
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
id: 'special.dragon-tiger',
|
|
641
|
+
command: ['special', 'dragon-tiger'],
|
|
642
|
+
description: 'Query dragon-tiger board records',
|
|
643
|
+
endpoint: '/api/a-share/special-data/dragon-tiger-list',
|
|
644
|
+
method: 'GET',
|
|
645
|
+
inputSchema: z
|
|
646
|
+
.object({
|
|
647
|
+
boardType: z.enum(['all', 'org', 'hot_money']).default('all'),
|
|
648
|
+
date: isoDate.optional(),
|
|
649
|
+
})
|
|
650
|
+
.strict(),
|
|
651
|
+
outputSchema: objectOutput,
|
|
652
|
+
options: [
|
|
653
|
+
{
|
|
654
|
+
flags: '--board-type <type>',
|
|
655
|
+
description: 'board category',
|
|
656
|
+
type: 'string',
|
|
657
|
+
choices: ['all', 'org', 'hot_money'],
|
|
658
|
+
defaultValue: 'all',
|
|
659
|
+
queryName: 'board_type',
|
|
660
|
+
},
|
|
661
|
+
{ flags: '--date <date>', description: 'optional trade date YYYY-MM-DD', type: 'string' },
|
|
662
|
+
],
|
|
663
|
+
paging: 'none',
|
|
664
|
+
window: 'one-year',
|
|
665
|
+
},
|
|
666
|
+
];
|
|
667
|
+
//# sourceMappingURL=remote-capabilities.js.map
|