quote-observer 1.5.0 → 1.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/api/quote.js +16 -1
- package/index.js +1 -0
- package/package.json +1 -1
package/api/quote.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// http://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get?_var=kline_dayqfq¶m=hk00700,day,,,10,qfq&r=0.283423356057471500
|
|
10
10
|
// http://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq¶m=sz399006,day,,,10,qfq&r=0.4519900299757633000
|
|
11
11
|
|
|
12
|
+
const fs = require('fs');
|
|
12
13
|
const axios = require('axios');
|
|
13
14
|
const logger = require('../logger')();
|
|
14
15
|
const querystring = require('querystring');
|
|
@@ -23,6 +24,20 @@ const path_mkt = {
|
|
|
23
24
|
|
|
24
25
|
const fix_id = (id) => global.MARKET[id] || id;
|
|
25
26
|
|
|
27
|
+
// Storage response into file
|
|
28
|
+
const save_resp = (data) => {
|
|
29
|
+
try {
|
|
30
|
+
const root = global.config?.opts?.save;
|
|
31
|
+
if (root) {
|
|
32
|
+
fs.writeFileSync(`${root}/stock-quote-${data.fid}.json`, JSON.stringify(data));
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
logger.error(`Save resp error:`, error);
|
|
36
|
+
} finally {
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
26
41
|
function kline_dayqfq(id, days = 10) {
|
|
27
42
|
let [mkt, code] = id.split('.');
|
|
28
43
|
if (!code) {
|
|
@@ -45,7 +60,7 @@ function kline_dayqfq(id, days = 10) {
|
|
|
45
60
|
let resp = JSON.parse(raw.data.toString().replace(`${_var}=`, ''));
|
|
46
61
|
let data = (resp || {}).data[_id] || [];
|
|
47
62
|
let info = (data.qt || {})[_id] || [];
|
|
48
|
-
return { fid: id, id: _id, info, data: (data.day || data.qfqday).reverse() };
|
|
63
|
+
return save_resp({ fid: id, id: _id, info, data: (data.day || data.qfqday || []).reverse() });
|
|
49
64
|
} catch (error) {
|
|
50
65
|
logger.error(id, error);
|
|
51
66
|
return {};
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ const cmd = require('./cmd');
|
|
|
15
15
|
|
|
16
16
|
program
|
|
17
17
|
.version(pkg.version)
|
|
18
|
+
.option('-S, --save <root>', `save response into root`, '')
|
|
18
19
|
.option('-H, --holder', `show stock holder`, true)
|
|
19
20
|
.option(' --no-holder', `hide stock holder`)
|
|
20
21
|
.option('-F, --follow', `show stock follow`, false)
|