daxiapi-cli 2.5.0 → 2.6.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/commands/sector.js +80 -1
- package/lib/api.js +10 -1
- package/package.json +1 -1
package/commands/sector.js
CHANGED
|
@@ -7,7 +7,7 @@ module.exports = function (program) {
|
|
|
7
7
|
const sectorCmd = program
|
|
8
8
|
.command('sector')
|
|
9
9
|
.description(
|
|
10
|
-
'获取A
|
|
10
|
+
'获取A股板块热力图、行业板块(详情)、概念板块(详情)、板块内个股排名等多维度板块数据,用于板块轮动分析与热点追踪。支持同花顺和东方财富分类。'
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
sectorCmd
|
|
@@ -52,6 +52,7 @@ module.exports = function (program) {
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
|
|
55
56
|
sectorCmd
|
|
56
57
|
.command('stocks')
|
|
57
58
|
.description('获取A股指定板块内股票排名,支持BK0428、0428、881155等多种板块代码格式。支持按强度(cs)、涨跌幅(zdf)、市值(sm)、成交额(cg)、换手率(cr)、SCTR排名等多种维度排序。返回板块内前20只股票的详细数据,可用于板块内强势股筛选和个股分析。')
|
|
@@ -122,4 +123,82 @@ module.exports = function (program) {
|
|
|
122
123
|
process.exit(1);
|
|
123
124
|
}
|
|
124
125
|
});
|
|
126
|
+
|
|
127
|
+
sectorCmd
|
|
128
|
+
.command('bk_info')
|
|
129
|
+
.description('获取A股行业板块详情数据,支持同花顺(ths)和东方财富(dfcf)两个数据源。可通过板块ID(code)或板块名称(name)查询,返回板块的CS强度、多日涨跌幅、市场宽度、主力资金净流入等详细数据。可用于板块深度分析和资金流向追踪。')
|
|
130
|
+
.option('--type <type>', '数据源类型 (dfcf|ths)', 'dfcf')
|
|
131
|
+
.option('--code <bkCode>', '板块ID')
|
|
132
|
+
.option('--name <bkName>', '板块名称(支持模糊匹配)')
|
|
133
|
+
.action(async options => {
|
|
134
|
+
try {
|
|
135
|
+
const token = config.getToken();
|
|
136
|
+
if (!token) {
|
|
137
|
+
const error = new Error('未配置 API Token');
|
|
138
|
+
error.response = { status: 401 };
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!['dfcf', 'ths'].includes(options.type)) {
|
|
143
|
+
throw createParameterError(
|
|
144
|
+
'参数无效',
|
|
145
|
+
["参数 'type' 必须是 dfcf 或 ths"],
|
|
146
|
+
['daxiapi sector bk_info --type ths', 'daxiapi sector bk_info --type dfcf']
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!options.code && !options.name) {
|
|
151
|
+
throw createParameterError(
|
|
152
|
+
'参数缺失',
|
|
153
|
+
['必须提供 --code 或 --name 参数'],
|
|
154
|
+
['daxiapi sector bk_info --code BK0428', 'daxiapi sector bk_info --name 工程建筑']
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const data = await api.getBkInfo(token, options.type, options.code, options.name);
|
|
159
|
+
output(data);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
handleError(error);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
sectorCmd
|
|
167
|
+
.command('gn_info')
|
|
168
|
+
.description('获取A股概念板块详情数据,支持同花顺(ths)和东方财富(dfcf)两个数据源。可通过板块ID(code)或板块名称(name)查询,返回板块的CS强度、多日涨跌幅、涨幅7%以上股票数、突破箱体股票数等详细数据。可用于概念板块深度分析和热点追踪。')
|
|
169
|
+
.option('--type <type>', '数据源类型 (dfcf|ths)', 'dfcf')
|
|
170
|
+
.option('--code <gnCode>', '概念板块ID')
|
|
171
|
+
.option('--name <gnName>', '概念板块名称(支持模糊匹配)')
|
|
172
|
+
.action(async options => {
|
|
173
|
+
try {
|
|
174
|
+
const token = config.getToken();
|
|
175
|
+
if (!token) {
|
|
176
|
+
const error = new Error('未配置 API Token');
|
|
177
|
+
error.response = { status: 401 };
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (!['dfcf', 'ths'].includes(options.type)) {
|
|
182
|
+
throw createParameterError(
|
|
183
|
+
'参数无效',
|
|
184
|
+
["参数 'type' 必须是 dfcf 或 ths"],
|
|
185
|
+
['daxiapi sector gn_info --type ths', 'daxiapi sector gn_info --type dfcf']
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!options.code && !options.name) {
|
|
190
|
+
throw createParameterError(
|
|
191
|
+
'参数缺失',
|
|
192
|
+
['必须提供 --code 或 --name 参数'],
|
|
193
|
+
['daxiapi sector gn_info --code 888123', 'daxiapi sector gn_info --name 人工智能']
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const data = await api.getGnInfo(token, options.type, options.code, options.name);
|
|
198
|
+
output(data);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
handleError(error);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
125
204
|
};
|
package/lib/api.js
CHANGED
|
@@ -62,7 +62,14 @@ async function getBkData(token) {
|
|
|
62
62
|
const client = createClient(token);
|
|
63
63
|
return get(client, '/get_bk_data');
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
async function getBkInfo(token, type, code, name) {
|
|
66
|
+
const client = createClient(token);
|
|
67
|
+
return post(client, '/get_bk_info', { type, code, name });
|
|
68
|
+
}
|
|
69
|
+
async function getGnInfo(token, type, code, name) {
|
|
70
|
+
const client = createClient(token);
|
|
71
|
+
return post(client, '/get_gn_info', { type, code, name });
|
|
72
|
+
}
|
|
66
73
|
async function getSectorData(token, orderBy = 'cs', limit = 5) {
|
|
67
74
|
const client = createClient(token);
|
|
68
75
|
return post(client, '/get_sector_data', {orderBy, lmt: limit});
|
|
@@ -485,6 +492,8 @@ async function getNewsReport(code, pageSize = 25, pageIndex = 1, beginTime = '20
|
|
|
485
492
|
module.exports = {
|
|
486
493
|
getCapitalFlow,
|
|
487
494
|
getMarketData,
|
|
495
|
+
getBkInfo,
|
|
496
|
+
getGnInfo,
|
|
488
497
|
getMarketTemp,
|
|
489
498
|
getCompassData,
|
|
490
499
|
getMarketStyle,
|