quote-observer 1.8.0 → 2.0.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.
@@ -5,8 +5,9 @@
5
5
  * @Last Modified time: 2021-11-09 10:43:03
6
6
  */
7
7
 
8
- const logger = require('../logger')();
9
- const Api = require('../api');
8
+ const logger = require('./logger')();
9
+ const Futu = require('./services/futu');
10
+ const KLine = require('./services/kline');
10
11
 
11
12
  // https://github.com/Marak/colors.js/blob/56de9f0983f68cd0a08c5b76d10a783e4b881716/lib/styles.js
12
13
  const styleCodes = {
@@ -99,7 +100,7 @@ function sale_signal(code, now) {
99
100
  }
100
101
 
101
102
  function start() {
102
- let quotes = [...STOCKS_MAP.keys()].map(code => Api.quote.kline_dayqfq(code, 10));
103
+ let quotes = [...STOCKS_MAP.keys()].map(code => KLine(code, 10));
103
104
  Promise.all(quotes).then(resps => {
104
105
  console.reset();
105
106
  console.log((new Date()).toTimeString().split(' ')[0]);
@@ -142,7 +143,8 @@ function update_stocks() {
142
143
  // SH,SZ,HK,US => [ 'SH', 'SZ', 'HK', 'US' ]
143
144
  const markets = String(global.config?.opts?.market || '').trim()
144
145
  .split(',').map(v => v.trim().toUpperCase()).filter(v => v);
145
- return Promise.all([Api.futu.position(), Api.futu.following()]).then(([holders, follows]) => {
146
+ return Promise.all([Futu.position(), Futu.following()]).then(([holders, follows]) => {
147
+ STOCKS_MAP.clear();
146
148
  [
147
149
  ...Object.values(holders),
148
150
  follows,
package/index.js CHANGED
@@ -11,7 +11,6 @@ global.MARKET = {};
11
11
  global.config = require('rc')('stock');
12
12
  const { program } = require('commander');
13
13
  const pkg = require('./package.json');
14
- const cmd = require('./cmd');
15
14
 
16
15
  program
17
16
  .version(pkg.version)
@@ -31,4 +30,4 @@ console.reset = function () {
31
30
  console.clear();
32
31
  };
33
32
 
34
- cmd.ma();
33
+ require('./core')();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quote-observer",
3
- "version": "1.8.0",
3
+ "version": "2.0.0",
4
4
  "description": "quote observer",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,16 +5,17 @@
5
5
  * @Last Modified time: 2021-06-01 14:30:29
6
6
  */
7
7
 
8
- // http://web.ifzq.gtimg.cn/appstock/app/usfqkline/get?_var=kline_dayqfq&param=usTSLA.OQ,day,,,10,qfq&r=0.2834233560574715
9
- // http://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get?_var=kline_dayqfq&param=hk00700,day,,,10,qfq&r=0.283423356057471500
10
- // http://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq&param=sz399006,day,,,10,qfq&r=0.4519900299757633000
8
+ // https://web.ifzq.gtimg.cn/appstock/app/usfqkline/get?_var=kline_dayqfq&param=usTSLA.OQ,day,,,10,qfq&r=0.2834233560574715
9
+ // https://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get?_var=kline_dayqfq&param=hk00700,day,,,10,qfq&r=0.283423356057471500
10
+ // https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq&param=sz399006,day,,,10,qfq&r=0.4519900299757633000
11
11
 
12
12
  const fs = require('fs');
13
13
  const axios = require('axios');
14
14
  const logger = require('../logger')();
15
15
  const querystring = require('querystring');
16
+ const quote_conf = global.config.quote || {};
16
17
 
17
- const base_url = `http://web.ifzq.gtimg.cn/appstock/app`;
18
+ const base_url = quote_conf.base_url || `https://web.ifzq.gtimg.cn/appstock/app`;
18
19
  const path_mkt = {
19
20
  SH: `/fqkline/get`,
20
21
  SZ: `/fqkline/get`,
@@ -29,8 +30,7 @@ const save_resp = (data) => {
29
30
  try {
30
31
  const root = global.config?.opts?.save;
31
32
  if (root) {
32
- const { fid, id, info } = data;
33
- fs.writeFileSync(`${root}/stock-quote-${data.fid}.json`, JSON.stringify({ fid, id, info }));
33
+ fs.writeFileSync(`${root}/stock-quote-${data.fid}.json`, JSON.stringify(data));
34
34
  }
35
35
  } catch (error) {
36
36
  logger.error(`Save resp error:`, error);
@@ -39,7 +39,7 @@ const save_resp = (data) => {
39
39
  }
40
40
  };
41
41
 
42
- function kline_dayqfq(id, days = 10) {
42
+ function kline(id, days = 10) {
43
43
  let [mkt, code] = id.split('.');
44
44
  if (!code) {
45
45
  logger.info(`Query ${id}: index skip`);
@@ -69,6 +69,4 @@ function kline_dayqfq(id, days = 10) {
69
69
  });
70
70
  }
71
71
 
72
- module.exports = {
73
- kline_dayqfq,
74
- };
72
+ module.exports = kline;
package/api/index.js DELETED
@@ -1,11 +0,0 @@
1
- /*
2
- * @Author: kael
3
- * @Date: 2020-11-05 18:25:47
4
- * @Last Modified by: kael
5
- * @Last Modified time: 2020-11-06 17:50:17
6
- */
7
-
8
- module.exports = {
9
- futu: require('./futu'),
10
- quote: require('./quote'),
11
- };
package/cmd/index.js DELETED
@@ -1,10 +0,0 @@
1
- /*
2
- * @Author: kael
3
- * @Date: 2020-11-05 18:19:53
4
- * @Last Modified by: kael
5
- * @Last Modified time: 2020-11-05 18:20:25
6
- */
7
-
8
- module.exports = {
9
- ma: require('./ma'),
10
- };
File without changes