daxiapi-cli 2.0.0 → 2.0.2

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/commands/kline.js CHANGED
@@ -6,7 +6,7 @@ const {output} = require('../lib/output');
6
6
  module.exports = function(program) {
7
7
  program
8
8
  .command('kline <code>')
9
- .description('K线数据')
9
+ .description('获取A股股票、指数、板块的K线数据,支持股票代码、指数代码、板块代码。默认返回上证指数(000001)的K线,可指定K线条数(1-500,默认60)。返回开盘价、收盘价、最高价、最低价、成交量等K线数据,可用于技术分析和趋势判断。')
10
10
  .action(async (code) => {
11
11
  try {
12
12
  const token = config.getToken();
@@ -1,13 +1,16 @@
1
1
  const config = require('../lib/config');
2
2
  const api = require('../lib/api');
3
- const { handleError } = require('../lib/error');
4
- const { output } = require('../lib/output');
3
+ const {handleError} = require('../lib/error');
4
+ const {output} = require('../lib/output');
5
5
 
6
- module.exports = function(program) {
6
+ module.exports = function (program) {
7
7
  const marketCmd = program.command('market');
8
8
 
9
9
  marketCmd
10
- .description('市场数据')
10
+ .command('index')
11
+ .description(
12
+ '获取A股市场主流指数数据,包括上证指数、深证成指、沪深300、上证50、中证500、创业板指、科创50等指数的强度值和多日涨跌幅。可用于市场风格判断、趋势分析、强弱排名、板块轮动分析和投资决策辅助。'
13
+ )
11
14
  .action(async () => {
12
15
  try {
13
16
  const token = config.getToken();
@@ -27,7 +30,9 @@ module.exports = function(program) {
27
30
 
28
31
  marketCmd
29
32
  .command('temp')
30
- .description('市场温度')
33
+ .description(
34
+ '获取A股市场温度数据,包括估值温度、恐贪指数、趋势温度、动量温度等核心指标。可用于判断市场整体情绪、风险水平、趋势强度和动量状态,为投资决策提供参考。'
35
+ )
31
36
  .action(async () => {
32
37
  try {
33
38
  const token = config.getToken();
@@ -47,7 +52,9 @@ module.exports = function(program) {
47
52
 
48
53
  marketCmd
49
54
  .command('style')
50
- .description('市场风格')
55
+ .description(
56
+ '获取A股市场风格数据,计算中证500(小盘)与沪深300(大盘)的涨跌幅差值。当差值为正时表示小盘强于大盘,为负时表示大盘强于小盘,可用于判断市场风格偏向和风格轮动趋势。'
57
+ )
51
58
  .action(async () => {
52
59
  try {
53
60
  const token = config.getToken();
@@ -67,7 +74,9 @@ module.exports = function(program) {
67
74
 
68
75
  marketCmd
69
76
  .command('value')
70
- .description('市场估值')
77
+ .description(
78
+ '获取A股主要指数估值数据,包括市盈率(PE)、市净率(PB)、估值温度、PE百分位、PB百分位等核心估值指标。支持对红利类指数的特殊估值计算,可用于判断指数当前估值水平和投资价值。'
79
+ )
71
80
  .action(async () => {
72
81
  try {
73
82
  const token = config.getToken();
@@ -6,7 +6,7 @@ const {output} = require('../lib/output');
6
6
  module.exports = function (program) {
7
7
  program
8
8
  .command('search <keyword>')
9
- .description('搜索股票或板块代码')
9
+ .description('搜索A股股票或板块,支持关键词模糊查询(股票名称、拼音缩写等)。支持两种搜索类型:stock(股票)和bk(板块),默认搜索股票。从东方财富API获取数据,返回代码、名称、类型、拼音等信息,最多返回10条结果。可用于快速查找股票代码和板块信息。')
10
10
  .option('-t, --type <type>', '搜索类型:stock(股票)或 bk(板块)', 'stock')
11
11
  .action(async (keyword, options) => {
12
12
  try {
package/commands/secid.js CHANGED
@@ -1,30 +1,20 @@
1
- const config = require('../lib/config');
2
- const api = require('../lib/api');
3
1
  const {handleError, createParameterError} = require('../lib/error');
4
2
  const {output} = require('../lib/output');
3
+ const {getSecid} = require('../lib/utils');
5
4
 
6
- module.exports = function(program) {
5
+ module.exports = function (program) {
7
6
  program
8
7
  .command('secid <code>')
9
- .description('代码转换')
10
- .action(async (code) => {
8
+ .description(
9
+ '将各种股票代码格式转换为标准secid格式,支持以下格式:6位数字股票代码(000001)、sh/sz前缀(sh000001)、BK开头板块代码(BK0428)、纯数字板块代码(428)。返回标准secid格式,如1.600000(沪市)、0.000001(深市)、90.BK0428(板块)。可用于统一代码格式和K线数据查询。'
10
+ )
11
+ .action(async code => {
11
12
  try {
12
- const token = config.getToken();
13
- if (!token) {
14
- const error = new Error('未配置 API Token');
15
- error.response = {status: 401};
16
- throw error;
17
- }
18
-
19
13
  if (!code) {
20
- throw createParameterError(
21
- '参数无效',
22
- ["参数 'code' 不能为空"],
23
- ['daxiapi secid 000001']
24
- );
14
+ throw createParameterError('参数无效', ["参数 'code' 不能为空"], ['daxiapi secid 000001']);
25
15
  }
26
16
 
27
- const data = await api.getSecId(token, code);
17
+ const data = getSecid(code);
28
18
  output(data);
29
19
  } catch (error) {
30
20
  handleError(error);
@@ -7,7 +7,8 @@ module.exports = function (program) {
7
7
  const sectorCmd = program.command('sector');
8
8
 
9
9
  sectorCmd
10
- .description('板块数据')
10
+ .command('heatmap')
11
+ .description('获取A股板块热力图数据(同花顺分类),支持按强度(cs)、涨跌幅(zdf)等多个维度排序,可查询1-30天数据。返回板块强度热力图、涨跌幅热力图、箱体突破板块统计、强度与均线交叉板块等信息。可用于板块轮动分析、强势板块识别和热点追踪。')
11
12
  .option('--order <field>', '排序字段', 'cs')
12
13
  .option('--limit <num>', '数量限制', 5)
13
14
  .action(async options => {
@@ -29,7 +30,7 @@ module.exports = function (program) {
29
30
 
30
31
  sectorCmd
31
32
  .command('bk')
32
- .description('行业板块数据')
33
+ .description('获取A股行业板块数据(同花顺分类),包括行业名称、今日涨幅、5日涨幅、20日涨幅、CS强度、CS均线、强度指标(QD)等核心数据。数据按今日涨幅降序排列,可用于板块轮动分析、强势板块识别和行业配置参考。')
33
34
  .action(async () => {
34
35
  try {
35
36
  const token = config.getToken();
@@ -49,7 +50,7 @@ module.exports = function (program) {
49
50
 
50
51
  sectorCmd
51
52
  .command('stocks')
52
- .description('板块个股排名')
53
+ .description('获取A股指定板块内股票排名,支持BK0428、0428、881155等多种板块代码格式。支持按强度(cs)、涨跌幅(zdf)、市值(sm)、成交额(cg)、换手率(cr)、SCTR排名等多种维度排序。返回板块内前20只股票的详细数据,可用于板块内强势股筛选和个股分析。')
53
54
  .requiredOption('--code <bkCode>', '板块代码')
54
55
  .option('--order <field>', '排序字段', 'cs')
55
56
  .action(async options => {
@@ -71,7 +72,7 @@ module.exports = function (program) {
71
72
 
72
73
  sectorCmd
73
74
  .command('top')
74
- .description('热门股票')
75
+ .description('获取A股热门股票数据,筛选当日涨幅>7%且IBS>50的强势股,按板块分组展示每个板块内强度排名前10的股票。返回股票名称、代码、涨幅、5/10/20日涨跌幅、所属板块、概念等信息,可用于短线热点追踪和强势股挖掘。')
75
76
  .action(async () => {
76
77
  try {
77
78
  const token = config.getToken();
@@ -91,7 +92,7 @@ module.exports = function (program) {
91
92
 
92
93
  sectorCmd
93
94
  .command('gn')
94
- .description('热门概念')
95
+ .description('获取A股热门概念板块列表,支持同花顺(ths)和东方财富(dfcf)两个数据源。按板块内涨幅7%以上股票个数降序排序,返回前20个概念板块的名称、今日涨幅、7%+股票数、5/10/20日涨幅、强度指标(QD)、CS强度等信息。可用于概念板块热度分析和热点追踪。')
95
96
  .option('--type <type>', '数据源类型 (dfcf|ths)', 'ths')
96
97
  .action(async options => {
97
98
  try {
package/commands/stock.js CHANGED
@@ -7,7 +7,8 @@ module.exports = function(program) {
7
7
  const stockCmd = program.command('stock');
8
8
 
9
9
  stockCmd
10
- .description('股票数据查询')
10
+ .command('info')
11
+ .description('根据股票代码获取A股详细信息,支持多个代码用逗号分隔(最多20只),支持6位数字代码和116.xxx格式。返回股票名称、代码、涨跌幅、CS强度、SCTR排名、所属板块、概念、市值、成交额等详细数据。可用于个股分析和多只股票对比。')
11
12
  .argument('<codes...>', '股票代码(支持多个)')
12
13
  .action(async (codes) => {
13
14
  try {
@@ -23,8 +24,8 @@ module.exports = function(program) {
23
24
  '参数无效',
24
25
  ["参数 'codes' 不能为空"],
25
26
  [
26
- 'daxiapi stock 000001',
27
- 'daxiapi stock 000001 600031 300750'
27
+ 'daxiapi stock info 000001',
28
+ 'daxiapi stock info 000001 600031 300750'
28
29
  ]
29
30
  );
30
31
  }
@@ -39,7 +40,7 @@ module.exports = function(program) {
39
40
 
40
41
  stockCmd
41
42
  .command('gn <gnId>')
42
- .description('概念股查询')
43
+ .description('根据概念板块ID获取该概念下的所有股票数据,支持同花顺(881155)和东方财富(BK0428)两种格式的板块ID。自动根据ID格式选择数据源,返回股票名称、代码、涨跌幅、CS强度、SCTR排名等详细信息,最多返回300只股票。可用于概念板块成分股分析和板块内股票筛选。')
43
44
  .option('--type <type>', '数据源类型 (dfcf|ths)', 'ths')
44
45
  .action(async (gnId, options) => {
45
46
  try {
package/commands/zdt.js CHANGED
@@ -6,8 +6,8 @@ const {output} = require('../lib/output');
6
6
  module.exports = function(program) {
7
7
  program
8
8
  .command('zdt')
9
- .description('涨跌停池')
10
- .option('--type <type>', '类型 (zt|dt)', 'zt')
9
+ .description('获取A股涨跌停股票池数据,支持查询涨停(zt)、跌停(dt)、炸板(zb)三类股票。返回股票代码、名称、涨停统计、所属行业、概念、CS强度、SCTR排名等信息,并提供市场整体涨跌停统计。可用于短线热点追踪和市场情绪分析。')
10
+ .option('--type <type>', '类型 (zt|dt|zb)', 'zt')
11
11
  .action(async (options) => {
12
12
  try {
13
13
  const token = config.getToken();
@@ -17,13 +17,14 @@ module.exports = function(program) {
17
17
  throw error;
18
18
  }
19
19
 
20
- if (!['zt', 'dt'].includes(options.type)) {
20
+ if (!['zt', 'dt', 'zb'].includes(options.type)) {
21
21
  throw createParameterError(
22
22
  '参数无效',
23
- ["参数 'type' 必须是 zt 或 dt"],
23
+ ["参数 'type' 必须是 zt、dtzb"],
24
24
  [
25
25
  'daxiapi zdt --type zt',
26
- 'daxiapi zdt --type dt'
26
+ 'daxiapi zdt --type dt',
27
+ 'daxiapi zdt --type zb'
27
28
  ]
28
29
  );
29
30
  }
package/lib/api.js CHANGED
@@ -99,11 +99,6 @@ async function getZdtPool(token, type = 'zt') {
99
99
  return post(client, '/get_zdt_pool', {type});
100
100
  }
101
101
 
102
- async function getSecId(token, code) {
103
- const client = createClient(token);
104
- return post(client, '/get_sec_id', {code});
105
- }
106
-
107
102
  async function queryStockData(token, q, type = 'stock') {
108
103
  const client = createClient(token);
109
104
  return post(client, '/query_stock_data', {q, type});
@@ -123,6 +118,5 @@ module.exports = {
123
118
  getGainianStock,
124
119
  getKline,
125
120
  getZdtPool,
126
- getSecId,
127
121
  queryStockData
128
122
  };
package/lib/utils.js ADDED
@@ -0,0 +1,31 @@
1
+ function getSecid(code) {
2
+ code = String(code);
3
+ if (code.indexOf('.') !== -1) {
4
+ const parts = code.split('.');
5
+ const stockCode = parts[0];
6
+ const suffix = parts[1].toUpperCase();
7
+ if (suffix === 'SH') {
8
+ return `1.${stockCode}`;
9
+ } else if (suffix === 'SZ') {
10
+ return `0.${stockCode}`;
11
+ }
12
+ return code;
13
+ }
14
+ if (code[0] === 'B' && code[1] === 'K') {
15
+ return '90.' + code;
16
+ }
17
+ if (code.length < 6) {
18
+ return '90.BK' + ('0000' + code).slice(-4);
19
+ }
20
+ if (code[0] === '6' || code[0] === '5') {
21
+ return `1.${code}`;
22
+ }
23
+ if (code[0].toLowerCase() === 's') {
24
+ return code.replace(/^sh/i, '1.').replace(/^sz/i, '0.');
25
+ }
26
+ return `0.${code}`;
27
+ }
28
+
29
+ module.exports = {
30
+ getSecid
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daxiapi-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "大虾皮金融数据API命令行工具",
5
5
  "bin": {
6
6
  "daxiapi": "./bin/index.js",
@@ -27,4 +27,4 @@
27
27
  "engines": {
28
28
  "node": ">=14.0.0"
29
29
  }
30
- }
30
+ }