daxiapi-cli 2.2.0 → 2.3.1
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 +56 -0
- package/bin/index.js +3 -0
- package/commands/config.js +7 -17
- package/commands/dividend.js +3 -1
- package/commands/hotrank.js +63 -0
- package/commands/market.js +5 -3
- package/commands/report.js +32 -0
- package/commands/sector.js +5 -1
- package/commands/stock.js +4 -2
- package/commands/turnover.js +18 -0
- package/lib/api.js +178 -187
- package/lib/caibao.js +69 -0
- package/lib/dividendUtils.js +216 -0
- package/lib/iconv.js +4 -0
- package/lib/output.js +4 -2
- package/lib/request.js +44 -0
- package/lib/thsUtils.js +148 -0
- package/lib/utils.js +58 -2
- package/package.json +39 -35
package/README.md
CHANGED
|
@@ -164,6 +164,62 @@ daxiapi zdt
|
|
|
164
164
|
daxiapi zdt --type dt
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
### 成交额
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# 获取A股市场成交额数据
|
|
171
|
+
daxiapi turnover
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 热榜数据
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# 热股榜(默认:1小时、大家都在看)
|
|
178
|
+
daxiapi hotrank stock
|
|
179
|
+
|
|
180
|
+
# 热股榜 - 24小时维度
|
|
181
|
+
daxiapi hotrank stock --type day
|
|
182
|
+
|
|
183
|
+
# 热股榜 - 快速飙升个股
|
|
184
|
+
daxiapi hotrank stock --list-type skyrocket
|
|
185
|
+
|
|
186
|
+
# 热股榜 - 趋势投资派关注个股
|
|
187
|
+
daxiapi hotrank stock --list-type trend
|
|
188
|
+
|
|
189
|
+
# 热股榜 - 价值派关注个股
|
|
190
|
+
daxiapi hotrank stock --list-type value
|
|
191
|
+
|
|
192
|
+
# 热股榜 - 技术派关注个股
|
|
193
|
+
daxiapi hotrank stock --list-type tech
|
|
194
|
+
|
|
195
|
+
# 概念板块热榜
|
|
196
|
+
daxiapi hotrank concept
|
|
197
|
+
|
|
198
|
+
# 行业板块热榜
|
|
199
|
+
daxiapi hotrank board
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### 热股榜榜单类型(list-type)
|
|
203
|
+
|
|
204
|
+
| 榜单类型 | 说明 |
|
|
205
|
+
|---------|------|
|
|
206
|
+
| normal | 大家都在看(默认) |
|
|
207
|
+
| skyrocket | 快速飙升个股 |
|
|
208
|
+
| trend | 趋势投资派关注个股 |
|
|
209
|
+
| value | 价值派关注个股 |
|
|
210
|
+
| tech | 技术派关注个股 |
|
|
211
|
+
|
|
212
|
+
### 财报数据
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# 获取个股财务报表数据
|
|
216
|
+
daxiapi report finance 300014
|
|
217
|
+
|
|
218
|
+
# 查询其他股票
|
|
219
|
+
daxiapi report finance 600036
|
|
220
|
+
daxiapi report finance 000001
|
|
221
|
+
```
|
|
222
|
+
|
|
167
223
|
### 工具
|
|
168
224
|
|
|
169
225
|
```bash
|
package/bin/index.js
CHANGED
|
@@ -18,5 +18,8 @@ require('../commands/zdt')(program);
|
|
|
18
18
|
require('../commands/secid')(program);
|
|
19
19
|
require('../commands/search')(program);
|
|
20
20
|
require('../commands/dividend')(program);
|
|
21
|
+
require('../commands/hotrank')(program);
|
|
22
|
+
require('../commands/turnover')(program);
|
|
23
|
+
require('../commands/report')(program);
|
|
21
24
|
|
|
22
25
|
program.parse(process.argv);
|
package/commands/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const config = require('../lib/config');
|
|
2
|
-
const {
|
|
2
|
+
const {handleError, createParameterError} = require('../lib/error');
|
|
3
3
|
|
|
4
|
-
module.exports = function(program) {
|
|
5
|
-
const configCmd = program.command('config');
|
|
4
|
+
module.exports = function (program) {
|
|
5
|
+
const configCmd = program.command('config').description('配置管理,添加daxiapi.com接口api_token');
|
|
6
6
|
|
|
7
7
|
configCmd
|
|
8
8
|
.command('set <key> <value>')
|
|
@@ -12,14 +12,8 @@ module.exports = function(program) {
|
|
|
12
12
|
if (!key || !value) {
|
|
13
13
|
throw createParameterError(
|
|
14
14
|
'参数无效',
|
|
15
|
-
[
|
|
16
|
-
|
|
17
|
-
"参数 'value' 不能为空"
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
'daxiapi config set token YOUR_TOKEN',
|
|
21
|
-
'daxiapi config set baseUrl https://daxiapi.com'
|
|
22
|
-
]
|
|
15
|
+
["参数 'key' 不能为空", "参数 'value' 不能为空"],
|
|
16
|
+
['daxiapi config set token YOUR_TOKEN', 'daxiapi config set baseUrl https://daxiapi.com']
|
|
23
17
|
);
|
|
24
18
|
}
|
|
25
19
|
|
|
@@ -47,14 +41,10 @@ module.exports = function(program) {
|
|
|
47
41
|
configCmd
|
|
48
42
|
.command('delete <key>')
|
|
49
43
|
.description('删除配置项')
|
|
50
|
-
.action(
|
|
44
|
+
.action(key => {
|
|
51
45
|
try {
|
|
52
46
|
if (!key) {
|
|
53
|
-
throw createParameterError(
|
|
54
|
-
'参数无效',
|
|
55
|
-
["参数 'key' 不能为空"],
|
|
56
|
-
['daxiapi config delete token']
|
|
57
|
-
);
|
|
47
|
+
throw createParameterError('参数无效', ["参数 'key' 不能为空"], ['daxiapi config delete token']);
|
|
58
48
|
}
|
|
59
49
|
|
|
60
50
|
config.delete(key);
|
package/commands/dividend.js
CHANGED
|
@@ -4,7 +4,9 @@ const {handleError} = require('../lib/error');
|
|
|
4
4
|
const {output} = require('../lib/output');
|
|
5
5
|
|
|
6
6
|
module.exports = function (program) {
|
|
7
|
-
const dividendCmd = program
|
|
7
|
+
const dividendCmd = program
|
|
8
|
+
.command('dividend')
|
|
9
|
+
.description('获取红利类指数打分数据,用于判断红利指数超买超卖状态与投资机会。');
|
|
8
10
|
|
|
9
11
|
dividendCmd
|
|
10
12
|
.command('score')
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const api = require('../lib/api');
|
|
2
|
+
const {handleError} = require('../lib/error');
|
|
3
|
+
const {output, encode} = require('../lib/output');
|
|
4
|
+
|
|
5
|
+
module.exports = function (program) {
|
|
6
|
+
const hotrankCmd = program
|
|
7
|
+
.command('hotrank')
|
|
8
|
+
.description('获取A股热股榜、概念板块热榜、行业板块热榜数据,用于发现市场热点与资金流向。');
|
|
9
|
+
|
|
10
|
+
hotrankCmd
|
|
11
|
+
.command('stock')
|
|
12
|
+
.description('获取A股热股榜数据,支持不同时间维度和榜单类型。可用于发现市场热点、跟踪资金流向、识别强势个股。')
|
|
13
|
+
.option(
|
|
14
|
+
'-t, --type <type>',
|
|
15
|
+
'时间类型:hour(1小时) 或 day(24小时),仅对 normal 和 skyrocket 榜单有效,默认为 hour',
|
|
16
|
+
'hour'
|
|
17
|
+
)
|
|
18
|
+
.option(
|
|
19
|
+
'-l, --list-type <listType>',
|
|
20
|
+
'榜单类型:normal(默认,大家都在看)、skyrocket(快速飙升个股)、trend(趋势投资派关注个股)、value(价值派关注个股)、tech(技术派关注个股)',
|
|
21
|
+
'normal'
|
|
22
|
+
)
|
|
23
|
+
.action(async options => {
|
|
24
|
+
try {
|
|
25
|
+
const data = await api.getStockRank(options.type, options.listType);
|
|
26
|
+
console.log('```toon\n' + encode(data) + '\n```');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
handleError(error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
hotrankCmd
|
|
34
|
+
.command('concept')
|
|
35
|
+
.description(
|
|
36
|
+
'获取A股概念板块热榜数据,展示当前市场热门概念板块排名。可用于把握市场热点、识别题材轮动、辅助主题投资决策。'
|
|
37
|
+
)
|
|
38
|
+
.action(async () => {
|
|
39
|
+
try {
|
|
40
|
+
const data = await api.getPlateRank('concept');
|
|
41
|
+
console.log('```toon\n' + encode(data) + '\n```');
|
|
42
|
+
} catch (error) {
|
|
43
|
+
handleError(error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
hotrankCmd
|
|
49
|
+
.command('board')
|
|
50
|
+
.description(
|
|
51
|
+
'获取A股行业板块热榜数据,展示当前市场热门行业板块排名。可用于分析行业轮动、把握板块机会、辅助行业配置决策。'
|
|
52
|
+
)
|
|
53
|
+
.option('-t, --type <type>', '板块类型:industry(行业) 或其他类型', 'industry')
|
|
54
|
+
.action(async options => {
|
|
55
|
+
try {
|
|
56
|
+
const data = await api.getPlateRank(options.type);
|
|
57
|
+
console.log('```toon\n' + encode(data) + '\n```');
|
|
58
|
+
} catch (error) {
|
|
59
|
+
handleError(error);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
package/commands/market.js
CHANGED
|
@@ -4,7 +4,11 @@ const {handleError} = require('../lib/error');
|
|
|
4
4
|
const {output} = require('../lib/output');
|
|
5
5
|
|
|
6
6
|
module.exports = function (program) {
|
|
7
|
-
const marketCmd = program
|
|
7
|
+
const marketCmd = program
|
|
8
|
+
.command('market')
|
|
9
|
+
.description(
|
|
10
|
+
'获取A股市场全景数据,涵盖指数行情、市场温度、风格轮动、估值水平等多维度分析,用于市场整体研判与投资决策辅助。'
|
|
11
|
+
);
|
|
8
12
|
|
|
9
13
|
marketCmd
|
|
10
14
|
.command('index')
|
|
@@ -93,6 +97,4 @@ module.exports = function (program) {
|
|
|
93
97
|
process.exit(1);
|
|
94
98
|
}
|
|
95
99
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
100
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const api = require('../lib/api');
|
|
2
|
+
const {handleError, createParameterError} = require('../lib/error');
|
|
3
|
+
const {encode} = require('../lib/output');
|
|
4
|
+
|
|
5
|
+
module.exports = function (program) {
|
|
6
|
+
const reportCmd = program
|
|
7
|
+
.command('report')
|
|
8
|
+
.description('获取A股个股财报数据,包括主要财务指标、盈利能力、偿债能力等,用于基本面分析。');
|
|
9
|
+
|
|
10
|
+
reportCmd
|
|
11
|
+
.command('finance <code>')
|
|
12
|
+
.description(
|
|
13
|
+
'获取指定股票的财务报表数据,包括报告期、营业收入、净利润、每股收益、净资产收益率等核心财务指标。数据来源于同花顺,可用于个股基本面分析和财务健康评估。'
|
|
14
|
+
)
|
|
15
|
+
.action(async code => {
|
|
16
|
+
try {
|
|
17
|
+
if (!code) {
|
|
18
|
+
throw createParameterError(
|
|
19
|
+
'参数无效',
|
|
20
|
+
["参数 'code' 不能为空"],
|
|
21
|
+
['daxiapi report finance 300014', 'daxiapi report finance 600036']
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const data = await api.getFinanceReportDetail(code);
|
|
26
|
+
console.log('```toon\n' + encode(data) + '\n```');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
handleError(error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
package/commands/sector.js
CHANGED
|
@@ -4,7 +4,11 @@ const {handleError, createParameterError} = require('../lib/error');
|
|
|
4
4
|
const {output} = require('../lib/output');
|
|
5
5
|
|
|
6
6
|
module.exports = function (program) {
|
|
7
|
-
const sectorCmd = program
|
|
7
|
+
const sectorCmd = program
|
|
8
|
+
.command('sector')
|
|
9
|
+
.description(
|
|
10
|
+
'获取A股板块热力图、行业板块、概念板块、板块内个股排名等多维度板块数据,用于板块轮动分析与热点追踪。'
|
|
11
|
+
);
|
|
8
12
|
|
|
9
13
|
sectorCmd
|
|
10
14
|
.command('heatmap')
|
package/commands/stock.js
CHANGED
|
@@ -34,7 +34,9 @@ const SUPPORTED_PATTERNS = [
|
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
module.exports = function (program) {
|
|
37
|
-
const stockCmd = program
|
|
37
|
+
const stockCmd = program
|
|
38
|
+
.command('stock')
|
|
39
|
+
.description('获取A股个股详情、概念股成分、技术形态选股等多维度股票数据,用于个股分析与量化筛选。');
|
|
38
40
|
|
|
39
41
|
stockCmd
|
|
40
42
|
.command('info')
|
|
@@ -71,7 +73,7 @@ module.exports = function (program) {
|
|
|
71
73
|
stockCmd
|
|
72
74
|
.command('gn <gnId>')
|
|
73
75
|
.description(
|
|
74
|
-
'根据概念板块ID获取该概念下的所有股票数据,支持同花顺(
|
|
76
|
+
'根据概念板块ID获取该概念下的所有股票数据,支持同花顺(8开头code)和东方财富(BK开头)两种格式的板块ID。' +
|
|
75
77
|
'自动根据ID格式选择数据源,返回股票名称、代码、涨跌幅、CS强度、SCTR排名等详细信息,最多返回300只股票。' +
|
|
76
78
|
'可用于概念板块成分股分析和板块内股票筛选。'
|
|
77
79
|
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const api = require('../lib/api');
|
|
2
|
+
const {handleError} = require('../lib/error');
|
|
3
|
+
const {encode} = require('../lib/output');
|
|
4
|
+
|
|
5
|
+
module.exports = function (program) {
|
|
6
|
+
const turnoverCmd = program
|
|
7
|
+
.command('turnover')
|
|
8
|
+
.description('获取A股市场成交额数据,对比当日与上一交易日成交额变化。')
|
|
9
|
+
.action(async () => {
|
|
10
|
+
try {
|
|
11
|
+
const data = await api.getTurnoverData();
|
|
12
|
+
console.log('```toon\n' + encode(data) + '\n```');
|
|
13
|
+
} catch (error) {
|
|
14
|
+
handleError(error);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|