quote-observer 1.3.5 → 1.4.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 +4 -0
- package/cmd/ma.js +19 -9
- package/package.json +1 -1
- package/fetch/futu.js +0 -27
- package/fetch/index.js +0 -10
package/api/quote.js
CHANGED
|
@@ -25,6 +25,10 @@ const fix_id = (id) => global.MARKET[id] || id;
|
|
|
25
25
|
|
|
26
26
|
function kline_dayqfq(id, days = 10) {
|
|
27
27
|
let [mkt, code] = id.split('.');
|
|
28
|
+
if (!code) {
|
|
29
|
+
logger.info(`Query ${id}: index skip`);
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
28
32
|
let _id = fix_id(`${mkt.toLowerCase()}${code}${'US' === mkt ? '.OQ' : ''}`);
|
|
29
33
|
let _var = 'kline_dayqfq';
|
|
30
34
|
let params = {
|
package/cmd/ma.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const logger = require('../logger')();
|
|
9
|
-
const Fetch = require('../fetch');
|
|
10
9
|
const Api = require('../api');
|
|
11
10
|
|
|
12
11
|
// https://github.com/Marak/colors.js/blob/56de9f0983f68cd0a08c5b76d10a783e4b881716/lib/styles.js
|
|
@@ -54,7 +53,7 @@ function marginal_value(datas) {
|
|
|
54
53
|
|
|
55
54
|
const padding = [
|
|
56
55
|
16,
|
|
57
|
-
|
|
56
|
+
24,
|
|
58
57
|
15,
|
|
59
58
|
15,
|
|
60
59
|
15,
|
|
@@ -72,7 +71,7 @@ const pad = (items) => {
|
|
|
72
71
|
}).join('');
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
const LINE = new Array(
|
|
74
|
+
const LINE = new Array(128).fill('=').join('');
|
|
76
75
|
|
|
77
76
|
const STOCKS_MAP = new Map();
|
|
78
77
|
function holding(code) {
|
|
@@ -87,7 +86,7 @@ function roc(MV) {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
function ceil(v, d = 2) {
|
|
90
|
-
return Math.ceil(Math.abs(v)).toString().padStart(d, '0');
|
|
89
|
+
return Math.ceil(Math.abs(v)).toString().padStart(d, '0').slice(-d);
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
function sale_signal(code, now) {
|
|
@@ -135,13 +134,24 @@ function start(codes) {
|
|
|
135
134
|
});
|
|
136
135
|
}
|
|
137
136
|
|
|
137
|
+
const args = (name) => {
|
|
138
|
+
return ((global.config || {}).args || {})[name];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
function market_match(stock, markets) {
|
|
142
|
+
return markets.includes(String(stock.code).toUpperCase().split('.').shift());
|
|
143
|
+
}
|
|
144
|
+
|
|
138
145
|
module.exports = () => {
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
const markets = args('market').map(v => v.toUpperCase());
|
|
147
|
+
Promise.all([Api.futu.position(), Api.futu.following()]).then(([holders, follows]) => {
|
|
148
|
+
[
|
|
141
149
|
...Object.values(holders),
|
|
142
|
-
|
|
143
|
-
]
|
|
144
|
-
|
|
150
|
+
follows,
|
|
151
|
+
]
|
|
152
|
+
.flat()
|
|
153
|
+
.filter(stock => market_match(stock, markets))
|
|
154
|
+
.forEach(stock => STOCKS_MAP.has(stock.code) || STOCKS_MAP.set(stock.code, stock));
|
|
145
155
|
start([...STOCKS_MAP.keys()]);
|
|
146
156
|
});
|
|
147
157
|
};
|
package/package.json
CHANGED
package/fetch/futu.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: kael
|
|
3
|
-
* @Date: 2020-11-05 19:19:13
|
|
4
|
-
* @Last Modified by: kael
|
|
5
|
-
* @Last Modified time: 2020-11-05 19:20:06
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const API = require('../api');
|
|
9
|
-
|
|
10
|
-
const args = (name) => {
|
|
11
|
-
return ((global.config || {}).args || {})[name];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const group = (data, mkt) => {
|
|
15
|
-
return data.filter(v => v.code.split('.')[0] === mkt);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const holders = () => {
|
|
19
|
-
return API.futu.position();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const follows = () => {
|
|
23
|
-
return API.futu.following().then(following =>
|
|
24
|
-
args('market').reduce((ret, mkt) => (ret[mkt] = group(following, mkt.toUpperCase()), ret), {}));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports = () => Promise.all([holders(), follows()]);
|