quote-observer 1.4.0 → 1.5.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/futu.js CHANGED
@@ -24,5 +24,5 @@ function apply(name) {
24
24
  });
25
25
  }
26
26
 
27
- exports.position = () => apply('position');
28
- exports.following = () => apply('following');
27
+ exports.position = () => global.config?.opts?.holder ? apply('position') : {};
28
+ exports.following = () => global.config?.opts?.follow ? apply('following') : [];
package/cmd/ma.js CHANGED
@@ -134,16 +134,14 @@ function start(codes) {
134
134
  });
135
135
  }
136
136
 
137
- const args = (name) => {
138
- return ((global.config || {}).args || {})[name];
139
- };
140
-
141
137
  function market_match(stock, markets) {
142
138
  return markets.includes(String(stock.code).toUpperCase().split('.').shift());
143
139
  }
144
140
 
145
141
  module.exports = () => {
146
- const markets = args('market').map(v => v.toUpperCase());
142
+ // SH,SZ,HK,US => [ 'SH', 'SZ', 'HK', 'US' ]
143
+ const markets = String(global.config?.opts?.market || '').trim()
144
+ .split(',').map(v => v.trim().toUpperCase()).filter(v => v);
147
145
  Promise.all([Api.futu.position(), Api.futu.following()]).then(([holders, follows]) => {
148
146
  [
149
147
  ...Object.values(holders),
package/index.js CHANGED
@@ -12,16 +12,17 @@ global.config = require('rc')('stock');
12
12
  const { program } = require('commander');
13
13
  const pkg = require('./package.json');
14
14
  const cmd = require('./cmd');
15
- const mkt = `sh,sz,hk,us`;
16
-
17
- const split = v => v.toLowerCase().split(',');
18
15
 
19
16
  program
20
17
  .version(pkg.version)
21
- .option('-m, --market <items>', `Stock market (default ${mkt})`, split, split(mkt));
18
+ .option('-H, --holder', `show stock holder`, true)
19
+ .option(' --no-holder', `hide stock holder`)
20
+ .option('-F, --follow', `show stock follow`, false)
21
+ .option(' --no-follow', `hide stock follow`)
22
+ .option('-m, --market <items>', `stock market`, `sh,sz,hk,us`);
22
23
 
23
24
  program.parse(process.argv);
24
- global.config.args = program.opts();
25
+ global.config.opts = program.opts();
25
26
 
26
27
  // https://stackoverflow.com/questions/62499125/how-to-clear-terminal-and-scroll-back-in-nodejs
27
28
  console.reset = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quote-observer",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "quote observer",
5
5
  "main": "index.js",
6
6
  "scripts": {