@kamuira/stock-analyzer 1.2.5 → 1.2.6

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/analyze.js CHANGED
@@ -354,5 +354,5 @@ if (require.main === module) {
354
354
 
355
355
  module.exports = {
356
356
  fetchRealtime, fetchHistory, fetchTWRealtime, fetchTWHistory,
357
- getMarketEnvironment, resolveCode, formatReport, WATCH_LIST,
357
+ getMarketEnvironment, resolveCode, formatReport, WATCH_LIST, main,
358
358
  };
package/backtest.js CHANGED
@@ -377,4 +377,4 @@ if (require.main === module) {
377
377
  main().catch(e => console.error('回测出错:', e.message));
378
378
  }
379
379
 
380
- module.exports = { backtest, formatBacktestReport, resolveCode, getMarketEnvAtDate };
380
+ module.exports = { backtest, formatBacktestReport, resolveCode, getMarketEnvAtDate, main };
package/bin/analyze.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  const path = require('path');
3
3
  process.chdir(path.join(__dirname, '..'));
4
- require('../analyze.js');
4
+ require('../analyze.js').main().catch(e => {
5
+ console.error('分析出错:', e.message);
6
+ process.exit(1);
7
+ });
package/bin/backtest.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  const path = require('path');
3
3
  process.chdir(path.join(__dirname, '..'));
4
- require('../backtest.js');
4
+ require('../backtest.js').main().catch(e => {
5
+ console.error('回测出错:', e.message);
6
+ process.exit(1);
7
+ });
package/bin/server.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  const path = require('path');
3
3
  process.chdir(path.join(__dirname, '..'));
4
- require('../server.js');
4
+ require('../server.js').main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamuira/stock-analyzer",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "preferGlobal": true,
5
5
  "description": "A股/台股综合技术分析工具 - 支持实时分析、回测验证、买卖建议",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -252,8 +252,12 @@ function startServer(port) {
252
252
  });
253
253
  }
254
254
 
255
- if (require.main === module) {
255
+ function main() {
256
256
  startServer(PORT);
257
257
  }
258
258
 
259
- module.exports = { server, startServer, searchStock, resolveStockCode };
259
+ if (require.main === module) {
260
+ main();
261
+ }
262
+
263
+ module.exports = { server, startServer, searchStock, resolveStockCode, main };