daxiapi-cli 2.1.0 → 2.2.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/README.md CHANGED
@@ -71,7 +71,7 @@ daxiapi sector --order zdf --limit 10
71
71
  daxiapi sector bk
72
72
 
73
73
  # 板块内个股排名
74
- daxiapi sector stocks --code BK0477
74
+ daxiapi sector stocks --code BK0457
75
75
 
76
76
  # 热门股票(各板块领涨股)
77
77
  daxiapi sector top
@@ -94,13 +94,13 @@ daxiapi search 平安
94
94
  daxiapi search 锂电 --type bk
95
95
 
96
96
  # 查询单个股票
97
- daxiapi stock 000001
97
+ daxiapi stock info 000001
98
98
 
99
99
  # 查询多个股票
100
- daxiapi stock 000001 600031 300750
100
+ daxiapi stock info 000001 600031 300750
101
101
 
102
102
  # 概念股查询
103
- daxiapi stock gn GN1234
103
+ daxiapi stock gn 881273
104
104
 
105
105
  # 技术形态筛选股票
106
106
  daxiapi stock pattern vcp
package/lib/api.js CHANGED
@@ -138,14 +138,16 @@ async function getDividendScore(token, code) {
138
138
  throw new Error('Invalid code: code must be a non-empty string');
139
139
  }
140
140
 
141
- const klineData = await getKline(token, code);
142
-
143
- if (!klineData || !Array.isArray(klineData.klines)) {
144
- throw new Error('Invalid kline data structure: klines must be an array');
141
+ let rawData = await axios.get(`${BASE_URL}/sk/${code}.json`);
142
+ if(!rawData.data){
143
+ throw new Error('Failed to get kline data');
145
144
  }
146
-
147
- const {klines} = klineData;
148
- const scores = calculateScores(klines);
145
+ const klineData = rawData.data;
146
+ const klines = klineData.k || '';
147
+ const scores = calculateScores(klines.split(';').map(a=>{
148
+ const [date, open,close, high, low, volume] = a.split(',');
149
+ return {date, close: Number(close), open: Number(open), high, low, vol: Number(volume)};
150
+ }));
149
151
  const recentScores = scores.slice(-60);
150
152
 
151
153
  return {
@@ -154,8 +156,8 @@ async function getDividendScore(token, code) {
154
156
  scores: recentScores.map(item => ({
155
157
  date: item.date,
156
158
  score: item.totalScore,
157
- cs: item.cs,
158
- rsi: item.rsi
159
+ cs: item.cs.toFixed(2),
160
+ rsi: item.rsi.toFixed(2)
159
161
  }))
160
162
  };
161
163
  }
@@ -278,7 +280,6 @@ function calculateScores(data) {
278
280
  const {cs} = calculateEMA(DIVIDEND_SCORE_CONSTANTS.EMA_PERIOD, dataCopy);
279
281
  const [_, ma80Bias] = calculateMA(DIVIDEND_SCORE_CONSTANTS.MA_PERIOD, dataCopy);
280
282
  const rsi = calculateRSI(closes, DIVIDEND_SCORE_CONSTANTS.RSI_PERIOD);
281
-
282
283
  for (let i = 0; i < dataCopy.length; i++) {
283
284
  dataCopy[i].cs = cs[i] === '-' ? null : parseFloat(cs[i]);
284
285
  dataCopy[i].ma80Bias = ma80Bias[i] === '-' ? null : parseFloat(ma80Bias[i]);
package/lib/output.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function output(data) {
2
2
  // 检查是否是dividend score结果
3
3
  if (data && data.scores && Array.isArray(data.scores)) {
4
- console.log(`查询到${data.name || data.code}的最近60个交易日打分情况:`);
4
+ console.log(`查询到${data.name || data.code}(${data.code})的最近60个交易日打分情况:`);
5
5
  console.log('');
6
6
  console.log('```toon');
7
7
  console.log('[60]{"日期","分数","cs值","rsi值"}:');
@@ -12,7 +12,7 @@ function output(data) {
12
12
 
13
13
  console.log('```');
14
14
  } else {
15
- console.log(JSON.stringify(data, null, 2));
15
+ console.log(data);
16
16
  }
17
17
  }
18
18
 
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
- "name": "daxiapi-cli",
3
- "version": "2.1.0",
4
- "description": "大虾皮金融数据API命令行工具",
5
- "bin": {
6
- "daxiapi": "./bin/index.js",
7
- "dxp": "./bin/index.js"
8
- },
9
- "scripts": {
10
- "test": "node bin/index.js --help"
11
- },
12
- "keywords": [
13
- "stock",
14
- "api",
15
- "daxiapi",
16
- "cli",
17
- "finance"
18
- ],
19
- "author": "daxiapi.com",
20
- "license": "MIT",
21
- "dependencies": {
22
- "axios": "^1.6.0",
23
- "chalk": "^4.1.2",
24
- "commander": "^11.1.0",
25
- "conf": "^10.2.0"
26
- },
27
- "engines": {
28
- "node": ">=14.0.0"
29
- },
30
- "files": [
31
- "bin",
32
- "commands",
33
- "lib",
34
- "README.md"
35
- ]
36
- }
2
+ "name": "daxiapi-cli",
3
+ "version": "2.2.0",
4
+ "description": "大虾皮金融数据API命令行工具",
5
+ "bin": {
6
+ "daxiapi": "./bin/index.js",
7
+ "dxp": "./bin/index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "node bin/index.js --help"
11
+ },
12
+ "keywords": [
13
+ "stock",
14
+ "api",
15
+ "daxiapi",
16
+ "cli",
17
+ "finance"
18
+ ],
19
+ "author": "daxiapi.com",
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "axios": "^1.6.0",
23
+ "chalk": "^4.1.2",
24
+ "commander": "^11.1.0",
25
+ "conf": "^10.2.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=14.0.0"
29
+ },
30
+ "files": [
31
+ "bin",
32
+ "commands",
33
+ "lib",
34
+ "README.md"
35
+ ]
36
+ }