@fugle/node-twstock 2.2.1-alpha.1 → 3.0.0-alpha.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.
@@ -293,7 +293,7 @@ class TwseScraper extends scraper_1.Scraper {
293
293
  return symbol ? data.find(data => data.symbol === symbol) : data;
294
294
  }
295
295
  async fetchStocksDividends(options) {
296
- const { startDate, endDate, symbol, includeDetail = true } = options;
296
+ const { startDate, endDate, symbol, includeDetail = false } = options;
297
297
  const query = new URLSearchParams({
298
298
  startDate: luxon_1.DateTime.fromISO(startDate).toFormat('yyyyMMdd'),
299
299
  endDate: luxon_1.DateTime.fromISO(endDate).toFormat('yyyyMMdd'),
@@ -417,8 +417,8 @@ class TwseScraper extends scraper_1.Scraper {
417
417
  return filterSymbol ? data.filter((item) => item.symbol === filterSymbol) : data;
418
418
  }
419
419
  async fetchStocksCapitalReductions(options) {
420
- const { startDate, endDate, symbol } = options;
421
- // Note: Always fetch detail for consistency with TPEx, includeDetail parameter is ignored
420
+ const { startDate, endDate, symbol, includeDetail = false } = options;
421
+ // Note: Default false for performance, set true to include detail fields
422
422
  const query = new URLSearchParams({
423
423
  startDate: luxon_1.DateTime.fromISO(startDate).toFormat('yyyyMMdd'),
424
424
  endDate: luxon_1.DateTime.fromISO(endDate).toFormat('yyyyMMdd'),
@@ -443,16 +443,19 @@ class TwseScraper extends scraper_1.Scraper {
443
443
  data.openingReferencePrice = (0, utils_1.parseNumeric)(values[4]);
444
444
  data.exrightReferencePrice = (0, utils_1.parseNumeric)(values[5]);
445
445
  data.reason = values[6].trim();
446
- try {
447
- const [, detailDate] = values[7].split(',');
448
- const detail = await this.fetchStockCapitalReductionDetail({ symbol, date: detailDate });
449
- return Object.assign(Object.assign({}, data), detail);
450
- }
451
- catch (error) {
452
- // If detail fetch fails, return main data without detail
453
- console.warn(`Failed to fetch capital reduction detail for ${symbol}:`, error);
454
- return data;
446
+ if (includeDetail) {
447
+ try {
448
+ const [, detailDate] = values[7].split(',');
449
+ const detail = await this.fetchStockCapitalReductionDetail({ symbol, date: detailDate });
450
+ return Object.assign(Object.assign({}, data), detail);
451
+ }
452
+ catch (error) {
453
+ // If detail fetch fails, return main data without detail
454
+ console.warn(`Failed to fetch capital reduction detail for ${symbol}:`, error);
455
+ return data;
456
+ }
455
457
  }
458
+ return data;
456
459
  }));
457
460
  return symbol ? data.filter((data) => data.symbol === symbol) : data;
458
461
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugle/node-twstock",
3
- "version": "2.2.1-alpha.1",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "A client library for scraping Taiwan stock market data",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",