@fugle/node-twstock 3.0.0-alpha.3 → 3.0.0-alpha.4

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.
@@ -3,6 +3,7 @@ export interface StockSplits {
3
3
  exchange: string;
4
4
  symbol: string;
5
5
  name: string;
6
+ splitType: 'split' | 'reverse-split';
6
7
  previousClose: number;
7
8
  referencePrice: number;
8
9
  limitUpPrice: number;
@@ -403,6 +403,7 @@ class TpexScraper extends scraper_1.Scraper {
403
403
  data.exchange = enums_1.Exchange.TPEx;
404
404
  data.symbol = symbol;
405
405
  data.name = name.trim();
406
+ data.splitType = 'split';
406
407
  data.previousClose = numeral(values[0]).value();
407
408
  data.referencePrice = numeral(values[1]).value();
408
409
  data.limitUpPrice = numeral(values[2]).value();
@@ -429,6 +430,7 @@ class TpexScraper extends scraper_1.Scraper {
429
430
  data.exchange = enums_1.Exchange.TPEx;
430
431
  data.symbol = symbol;
431
432
  data.name = name.trim();
433
+ data.splitType = 'reverse-split';
432
434
  data.previousClose = numeral(values[0]).value();
433
435
  data.referencePrice = numeral(values[1]).value();
434
436
  data.limitUpPrice = numeral(values[2]).value();
@@ -607,20 +607,20 @@ class TwseScraper extends scraper_1.Scraper {
607
607
  data.exchange = enums_1.Exchange.TWSE;
608
608
  data.symbol = symbol;
609
609
  data.name = name.trim();
610
- data.type = type;
611
610
  data.previousClose = (0, utils_1.parseNumeric)(values[0]);
612
611
  data.referencePrice = (0, utils_1.parseNumeric)(values[1]);
613
612
  data.limitUpPrice = (0, utils_1.parseNumeric)(values[2]);
614
613
  data.limitDownPrice = (0, utils_1.parseNumeric)(values[3]);
615
614
  data.openingReferencePrice = (0, utils_1.parseNumeric)(values[4]);
615
+ const inferredType = type || (data.previousClose > data.referencePrice ? '分割' : '反分割');
616
+ data.splitType = inferredType === '分割' ? 'split' : 'reverse-split';
616
617
  return data;
617
618
  })
618
619
  .filter((row) => {
619
620
  if (splitType === 'all')
620
621
  return true;
621
- return splitType === 'split' ? row.type === '分割' : row.type === '反分割';
622
- })
623
- .map((row) => _.omit(row, ['type']));
622
+ return row.splitType === splitType;
623
+ });
624
624
  return symbol ? data.filter((data) => data.symbol === symbol) : data;
625
625
  }
626
626
  async fetchStocksSplitAnnouncement(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugle/node-twstock",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.4",
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",