@fugle/node-twstock 3.0.0-alpha.2 → 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.
package/README.md
CHANGED
|
@@ -895,8 +895,8 @@ twstock.stocks.splits({ startDate: '2022-07-01', endDate: '2022-07-31', exchange
|
|
|
895
895
|
* `haltDate`: {string} 停止買賣日期
|
|
896
896
|
* `resumeDate`: {string} 恢復買賣日期
|
|
897
897
|
* `splitRatio`: {number} 每股換發新股比例
|
|
898
|
-
* `
|
|
899
|
-
* `
|
|
898
|
+
* `parValueBefore`: {number} 變更前面額 (元)
|
|
899
|
+
* `parValueAfter`: {number} 變更後面額 (元)
|
|
900
900
|
* `referencePrice`: {number} 恢復買賣參考價 (TPEx 提供,TWSE 為 null)
|
|
901
901
|
* **當 `includeDetail=true` 時 (僅適用於 TWSE),額外包含以下欄位:**
|
|
902
902
|
* `sharesPerOldShare`: {number} 每股換發新股票
|
|
@@ -913,8 +913,8 @@ twstock.stocks.splitAnnouncement({ symbol: '1234' })
|
|
|
913
913
|
// haltDate: '2026-01-15',
|
|
914
914
|
// resumeDate: '2026-01-25',
|
|
915
915
|
// splitRatio: 0.5,
|
|
916
|
-
//
|
|
917
|
-
//
|
|
916
|
+
// parValueBefore: 10,
|
|
917
|
+
// parValueAfter: 5
|
|
918
918
|
// }
|
|
919
919
|
// ]
|
|
920
920
|
```
|
|
@@ -5,7 +5,7 @@ export interface StocksSplitAnnouncement {
|
|
|
5
5
|
haltDate: string;
|
|
6
6
|
resumeDate: string;
|
|
7
7
|
splitRatio: number | null;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
parValueBefore: number | null;
|
|
9
|
+
parValueAfter: number | null;
|
|
10
10
|
sharesPerOldShare?: number | null;
|
|
11
11
|
}
|
|
@@ -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();
|
|
@@ -690,7 +692,7 @@ class TpexScraper extends scraper_1.Scraper {
|
|
|
690
692
|
if (!json)
|
|
691
693
|
return [];
|
|
692
694
|
const data = json.tables[0].data.map((row) => {
|
|
693
|
-
const [symbol, name, haltDate, splitRatio,
|
|
695
|
+
const [symbol, name, haltDate, splitRatio, parValueBefore, parValueAfter, resumeDate,] = row;
|
|
694
696
|
return {
|
|
695
697
|
symbol,
|
|
696
698
|
name: name.trim(),
|
|
@@ -698,8 +700,8 @@ class TpexScraper extends scraper_1.Scraper {
|
|
|
698
700
|
haltDate: (0, utils_1.rocToWestern)(haltDate),
|
|
699
701
|
resumeDate: (0, utils_1.rocToWestern)(resumeDate),
|
|
700
702
|
splitRatio: (0, utils_1.parseNumeric)(splitRatio),
|
|
701
|
-
|
|
702
|
-
|
|
703
|
+
parValueBefore: (0, utils_1.parseNumeric)(parValueBefore),
|
|
704
|
+
parValueAfter: (0, utils_1.parseNumeric)(parValueAfter),
|
|
703
705
|
};
|
|
704
706
|
});
|
|
705
707
|
return filterSymbol
|
|
@@ -505,8 +505,8 @@ class TwseScraper extends scraper_1.Scraper {
|
|
|
505
505
|
data.name = name.trim();
|
|
506
506
|
data.haltDate = (0, utils_1.rocToWestern)(values[0]);
|
|
507
507
|
data.sharesPerOldShare = (0, utils_1.parseNumeric)(values[1]);
|
|
508
|
-
data.
|
|
509
|
-
data.
|
|
508
|
+
data.parValueBefore = (0, utils_1.parseNumeric)(values[2]);
|
|
509
|
+
data.parValueAfter = (0, utils_1.parseNumeric)(values[3]);
|
|
510
510
|
return data;
|
|
511
511
|
}
|
|
512
512
|
async fetchStocksCapitalReductionAnnouncement(options) {
|
|
@@ -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
|
|
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) {
|
|
@@ -636,7 +636,7 @@ class TwseScraper extends scraper_1.Scraper {
|
|
|
636
636
|
if (!json || !json.data)
|
|
637
637
|
return [];
|
|
638
638
|
const data = await Promise.all(json.data.map(async (row) => {
|
|
639
|
-
const [haltDate, symbol, name, resumeDate, splitRatio,
|
|
639
|
+
const [haltDate, symbol, name, resumeDate, splitRatio, parValueBefore, parValueAfter, detailField1, // row[7]: "7780 ,20251230"
|
|
640
640
|
detailField2, // row[8]: "7780 ,20260109,20260119"
|
|
641
641
|
detailField3 // row[9]: ",10.00,1.00"
|
|
642
642
|
] = row;
|
|
@@ -647,8 +647,8 @@ class TwseScraper extends scraper_1.Scraper {
|
|
|
647
647
|
data.haltDate = (0, utils_1.rocToWestern)(haltDate);
|
|
648
648
|
data.resumeDate = (0, utils_1.rocToWestern)(resumeDate);
|
|
649
649
|
data.splitRatio = (0, utils_1.parseNumeric)(splitRatio);
|
|
650
|
-
data.
|
|
651
|
-
data.
|
|
650
|
+
data.parValueBefore = (0, utils_1.parseNumeric)(parValueBefore);
|
|
651
|
+
data.parValueAfter = (0, utils_1.parseNumeric)(parValueAfter);
|
|
652
652
|
// Extract detail query date from detailField1 (format: "symbol,date")
|
|
653
653
|
// Example: "7780 ,20251230" → extract "20251230"
|
|
654
654
|
let detailQueryDate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugle/node-twstock",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@commitlint/cli": "^16.3.0",
|
|
50
50
|
"@commitlint/config-conventional": "^16.2.4",
|
|
51
51
|
"@release-it/conventional-changelog": "^5.1.1",
|
|
52
|
-
"@types/jest": "^
|
|
52
|
+
"@types/jest": "^30.0.0",
|
|
53
53
|
"@types/lodash": "^4.14.200",
|
|
54
54
|
"@types/luxon": "^3.3.6",
|
|
55
55
|
"@types/node": "^16.18.18",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"codecov": "^3.8.3",
|
|
60
60
|
"eslint": "^7.32.0",
|
|
61
61
|
"husky": "^7.0.4",
|
|
62
|
-
"jest": "^
|
|
62
|
+
"jest": "^30.2.0",
|
|
63
63
|
"jest-mock-axios": "^4.7.3",
|
|
64
64
|
"release-it": "^15.10.0",
|
|
65
65
|
"rimraf": "^3.0.2",
|
|
66
|
-
"ts-jest": "^
|
|
66
|
+
"ts-jest": "^29.4.6",
|
|
67
67
|
"ts-node": "^10.9.1",
|
|
68
68
|
"typescript": "^4.9.5"
|
|
69
69
|
}
|