@fugle/node-twstock 2.2.1-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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1837 -0
  3. package/lib/enums/exchange.enum.d.ts +5 -0
  4. package/lib/enums/exchange.enum.js +9 -0
  5. package/lib/enums/futopt.enum.d.ts +34 -0
  6. package/lib/enums/futopt.enum.js +38 -0
  7. package/lib/enums/index.d.ts +6 -0
  8. package/lib/enums/index.enum.d.ts +67 -0
  9. package/lib/enums/index.enum.js +71 -0
  10. package/lib/enums/index.js +22 -0
  11. package/lib/enums/industry.enum.d.ts +40 -0
  12. package/lib/enums/industry.enum.js +44 -0
  13. package/lib/enums/market.enum.d.ts +5 -0
  14. package/lib/enums/market.enum.js +9 -0
  15. package/lib/enums/scraper.enum.d.ts +10 -0
  16. package/lib/enums/scraper.enum.js +14 -0
  17. package/lib/index.d.ts +2 -0
  18. package/lib/index.js +18 -0
  19. package/lib/interfaces/futopt-exchange-rates.interface.d.ts +13 -0
  20. package/lib/interfaces/futopt-exchange-rates.interface.js +2 -0
  21. package/lib/interfaces/futopt-historical.interface.d.ts +23 -0
  22. package/lib/interfaces/futopt-historical.interface.js +2 -0
  23. package/lib/interfaces/futopt-institutional.interface.d.ts +21 -0
  24. package/lib/interfaces/futopt-institutional.interface.js +2 -0
  25. package/lib/interfaces/futopt-large-traders.interface.d.ts +16 -0
  26. package/lib/interfaces/futopt-large-traders.interface.js +2 -0
  27. package/lib/interfaces/futopt-mxf-retail-position.interface.d.ts +7 -0
  28. package/lib/interfaces/futopt-mxf-retail-position.interface.js +2 -0
  29. package/lib/interfaces/futopt-quote.interface.d.ts +31 -0
  30. package/lib/interfaces/futopt-quote.interface.js +2 -0
  31. package/lib/interfaces/futopt-tmf-retail-position.interface.d.ts +7 -0
  32. package/lib/interfaces/futopt-tmf-retail-position.interface.js +2 -0
  33. package/lib/interfaces/futopt-txo-put-call-ratio.interface.d.ts +9 -0
  34. package/lib/interfaces/futopt-txo-put-call-ratio.interface.js +2 -0
  35. package/lib/interfaces/futopt.interface.d.ts +7 -0
  36. package/lib/interfaces/futopt.interface.js +2 -0
  37. package/lib/interfaces/index-historical.interface.d.ts +11 -0
  38. package/lib/interfaces/index-historical.interface.js +2 -0
  39. package/lib/interfaces/index-quote.interface.d.ts +13 -0
  40. package/lib/interfaces/index-quote.interface.js +2 -0
  41. package/lib/interfaces/index-trades.interface.d.ts +9 -0
  42. package/lib/interfaces/index-trades.interface.js +2 -0
  43. package/lib/interfaces/index.d.ts +37 -0
  44. package/lib/interfaces/index.js +53 -0
  45. package/lib/interfaces/market-breadth.interface.d.ts +11 -0
  46. package/lib/interfaces/market-breadth.interface.js +2 -0
  47. package/lib/interfaces/market-institutional.interface.d.ts +10 -0
  48. package/lib/interfaces/market-institutional.interface.js +2 -0
  49. package/lib/interfaces/market-margin-trades.interface.d.ts +19 -0
  50. package/lib/interfaces/market-margin-trades.interface.js +2 -0
  51. package/lib/interfaces/market-trades.interface.d.ts +7 -0
  52. package/lib/interfaces/market-trades.interface.js +2 -0
  53. package/lib/interfaces/rate-limit-options.interface.d.ts +4 -0
  54. package/lib/interfaces/rate-limit-options.interface.js +2 -0
  55. package/lib/interfaces/stock-capital-reductions.interface.d.ts +23 -0
  56. package/lib/interfaces/stock-capital-reductions.interface.js +2 -0
  57. package/lib/interfaces/stock-dividends.interface.d.ts +27 -0
  58. package/lib/interfaces/stock-dividends.interface.js +2 -0
  59. package/lib/interfaces/stock-eps.interface.d.ts +8 -0
  60. package/lib/interfaces/stock-eps.interface.js +2 -0
  61. package/lib/interfaces/stock-fini-holdings.interface.d.ts +12 -0
  62. package/lib/interfaces/stock-fini-holdings.interface.js +2 -0
  63. package/lib/interfaces/stock-futopt.interface.d.ts +8 -0
  64. package/lib/interfaces/stock-futopt.interface.js +2 -0
  65. package/lib/interfaces/stock-historical.interface.d.ts +14 -0
  66. package/lib/interfaces/stock-historical.interface.js +2 -0
  67. package/lib/interfaces/stock-institutional.interface.d.ts +12 -0
  68. package/lib/interfaces/stock-institutional.interface.js +2 -0
  69. package/lib/interfaces/stock-margin-trades.interface.d.ts +20 -0
  70. package/lib/interfaces/stock-margin-trades.interface.js +2 -0
  71. package/lib/interfaces/stock-quote.interface.d.ts +19 -0
  72. package/lib/interfaces/stock-quote.interface.js +2 -0
  73. package/lib/interfaces/stock-revenue.interface.d.ts +8 -0
  74. package/lib/interfaces/stock-revenue.interface.js +2 -0
  75. package/lib/interfaces/stock-shareholders.interface.d.ts +11 -0
  76. package/lib/interfaces/stock-shareholders.interface.js +2 -0
  77. package/lib/interfaces/stock-short-sales.interface.d.ts +19 -0
  78. package/lib/interfaces/stock-short-sales.interface.js +2 -0
  79. package/lib/interfaces/stock-splits.interface.d.ts +12 -0
  80. package/lib/interfaces/stock-splits.interface.js +2 -0
  81. package/lib/interfaces/stock-values.interface.d.ts +10 -0
  82. package/lib/interfaces/stock-values.interface.js +2 -0
  83. package/lib/interfaces/stock.interface.d.ts +8 -0
  84. package/lib/interfaces/stock.interface.js +2 -0
  85. package/lib/interfaces/stocks-capital-reduction-announcement.interface.d.ts +19 -0
  86. package/lib/interfaces/stocks-capital-reduction-announcement.interface.js +2 -0
  87. package/lib/interfaces/stocks-dividends-announcement.interface.d.ts +21 -0
  88. package/lib/interfaces/stocks-dividends-announcement.interface.js +2 -0
  89. package/lib/interfaces/stocks-etf-split-announcement.interface.d.ts +11 -0
  90. package/lib/interfaces/stocks-etf-split-announcement.interface.js +2 -0
  91. package/lib/interfaces/stocks-listing-application.interface.d.ts +16 -0
  92. package/lib/interfaces/stocks-listing-application.interface.js +2 -0
  93. package/lib/interfaces/stocks-split-announcement.interface.d.ts +11 -0
  94. package/lib/interfaces/stocks-split-announcement.interface.js +2 -0
  95. package/lib/interfaces/ticker.interface.d.ts +10 -0
  96. package/lib/interfaces/ticker.interface.js +2 -0
  97. package/lib/scrapers/index.d.ts +10 -0
  98. package/lib/scrapers/index.js +26 -0
  99. package/lib/scrapers/isin-scraper.d.ts +13 -0
  100. package/lib/scrapers/isin-scraper.js +76 -0
  101. package/lib/scrapers/mis-taifex-scraper.d.ts +17 -0
  102. package/lib/scrapers/mis-taifex-scraper.js +126 -0
  103. package/lib/scrapers/mis-twse-scraper.d.ts +15 -0
  104. package/lib/scrapers/mis-twse-scraper.js +97 -0
  105. package/lib/scrapers/mops-scraper.d.ts +17 -0
  106. package/lib/scrapers/mops-scraper.js +64 -0
  107. package/lib/scrapers/scraper-factory.d.ts +25 -0
  108. package/lib/scrapers/scraper-factory.js +62 -0
  109. package/lib/scrapers/scraper.d.ts +6 -0
  110. package/lib/scrapers/scraper.js +20 -0
  111. package/lib/scrapers/taifex-scraper.d.ts +44 -0
  112. package/lib/scrapers/taifex-scraper.js +406 -0
  113. package/lib/scrapers/tdcc-scraper.d.ts +11 -0
  114. package/lib/scrapers/tdcc-scraper.js +82 -0
  115. package/lib/scrapers/tpex-scraper.d.ts +95 -0
  116. package/lib/scrapers/tpex-scraper.js +786 -0
  117. package/lib/scrapers/twse-scraper.d.ts +110 -0
  118. package/lib/scrapers/twse-scraper.js +967 -0
  119. package/lib/twstock.d.ts +229 -0
  120. package/lib/twstock.js +507 -0
  121. package/lib/utils/as-exchange.util.d.ts +2 -0
  122. package/lib/utils/as-exchange.util.js +15 -0
  123. package/lib/utils/as-index.util.d.ts +1 -0
  124. package/lib/utils/as-index.util.js +178 -0
  125. package/lib/utils/as-industry.util.d.ts +2 -0
  126. package/lib/utils/as-industry.util.js +49 -0
  127. package/lib/utils/date-converter.util.d.ts +47 -0
  128. package/lib/utils/date-converter.util.js +113 -0
  129. package/lib/utils/html-cleaner.util.d.ts +29 -0
  130. package/lib/utils/html-cleaner.util.js +45 -0
  131. package/lib/utils/index.d.ts +7 -0
  132. package/lib/utils/index.js +23 -0
  133. package/lib/utils/is-warrant.util.d.ts +1 -0
  134. package/lib/utils/is-warrant.util.js +25 -0
  135. package/lib/utils/parse-numeric.util.d.ts +21 -0
  136. package/lib/utils/parse-numeric.util.js +58 -0
  137. package/package.json +70 -0
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asIndex = void 0;
4
+ const enums_1 = require("../enums");
5
+ function asIndex(index) {
6
+ const indices = {
7
+ '發行量加權股價指數': enums_1.Index.TAIEX,
8
+ '未含金融指數': enums_1.Index.NonFinance,
9
+ '未含電子指數': enums_1.Index.NonElectronics,
10
+ '未含金融電子指數': enums_1.Index.NonFinanceNonElectronics,
11
+ '水泥類指數': enums_1.Index.Cement,
12
+ '食品類指數': enums_1.Index.Food,
13
+ '塑膠類指數': enums_1.Index.Plastic,
14
+ '水泥窯製類指數': enums_1.Index.CementAndCeramic,
15
+ '塑膠化工類指數': enums_1.Index.PlasticAndChemical,
16
+ '機電類指數': enums_1.Index.Electrical,
17
+ '紡織纖維類指數': enums_1.Index.Textiles,
18
+ '電機機械類指數': enums_1.Index.ElectricMachinery,
19
+ '電器電纜類指數': enums_1.Index.ElectricalAndCable,
20
+ '化學生技醫療類指數': enums_1.Index.ChemicalBiotechnologyAndMedicalCare,
21
+ '化學類指數': enums_1.Index.Chemical,
22
+ '生技醫療類指數': enums_1.Index.BiotechnologyAndMedicalCare,
23
+ '玻璃陶瓷類指數': enums_1.Index.GlassAndCeramic,
24
+ '造紙類指數': enums_1.Index.PaperAndPulp,
25
+ '鋼鐵類指數': enums_1.Index.IronAndSteel,
26
+ '橡膠類指數': enums_1.Index.Rubber,
27
+ '汽車類指數': enums_1.Index.Automobile,
28
+ '電子工業類指數': enums_1.Index.Electronics,
29
+ '半導體類指數': enums_1.Index.Semiconductors,
30
+ '電腦及週邊設備類指數': enums_1.Index.ComputerAndPeripheralEquipment,
31
+ '光電類指數': enums_1.Index.Optoelectronics,
32
+ '通信網路類指數': enums_1.Index.CommunicationsTechnologyAndInternet,
33
+ '電子零組件類指數': enums_1.Index.ElectronicPartsComponents,
34
+ '電子通路類指數': enums_1.Index.ElectronicProductsDistirbution,
35
+ '資訊服務類指數': enums_1.Index.InformationService,
36
+ '其他電子類指數': enums_1.Index.OtherElectronics,
37
+ '建材營造類指數': enums_1.Index.BuildingMaterialsAndConstruction,
38
+ '航運類指數': enums_1.Index.ShippingAndTransportation,
39
+ '觀光餐旅類指數': enums_1.Index.TourismAndHospitality,
40
+ '金融保險類指數': enums_1.Index.FinancialAndInsurance,
41
+ '貿易百貨類指數': enums_1.Index.TradingAndConsumerGoods,
42
+ '油電燃氣類指數': enums_1.Index.OilGasAndElectricity,
43
+ '其他類指數': enums_1.Index.Other,
44
+ '綠能環保類指數': enums_1.Index.GreenEnergyAndEnvironmentalServices,
45
+ '數位雲端類指數': enums_1.Index.DigitalAndCloudServices,
46
+ '運動休閒類指數': enums_1.Index.SportsAndLeisure,
47
+ '居家生活類指數': enums_1.Index.Household,
48
+ '櫃買指數': enums_1.Index.TPEX,
49
+ '櫃買紡纖類指數': enums_1.Index.TPExTextiles,
50
+ '櫃買機械類指數': enums_1.Index.TPExElectricMachinery,
51
+ '櫃買鋼鐵類指數': enums_1.Index.TPExIronAndSteel,
52
+ '櫃買電子類指數': enums_1.Index.TPExElectronic,
53
+ '櫃買營建類指數': enums_1.Index.TPExBuildingMaterialsAndConstruction,
54
+ '櫃買航運類指數': enums_1.Index.TPExShippingAndTransportation,
55
+ '櫃買觀光餐旅類指數': enums_1.Index.TPExTourismAndHospitality,
56
+ '櫃買化工類指數': enums_1.Index.TPExChemical,
57
+ '櫃買生技醫療類指數': enums_1.Index.TPExBiotechnologyAndMedicalCare,
58
+ '櫃買半導體類指數': enums_1.Index.TPExSemiconductors,
59
+ '櫃買電腦及週邊類指數': enums_1.Index.TPExComputerAndPeripheralEquipment,
60
+ '櫃買光電業類指數': enums_1.Index.TPExOptoelectronic,
61
+ '櫃買通信網路類指數': enums_1.Index.TPExCommunicationsAndInternet,
62
+ '櫃買電子零組件類指數': enums_1.Index.TPExElectronicPartsComponents,
63
+ '櫃買電子通路類指數': enums_1.Index.TPExElectronicProductsDistribution,
64
+ '櫃買資訊服務類指數': enums_1.Index.TPExInformationService,
65
+ '櫃買文化創意業類指數': enums_1.Index.TPExCulturalAndCreative,
66
+ '櫃買其他電子類指數': enums_1.Index.TPExOtherElectronic,
67
+ '櫃買其他類指數': enums_1.Index.TPExOther,
68
+ '櫃買綠能環保類指數': enums_1.Index.TPExGreenEnergyAndEnvironmentalServices,
69
+ '櫃買數位雲端類指數': enums_1.Index.TPExDigitalAndCloudServices,
70
+ '櫃買居家生活類指數': enums_1.Index.TPExHousehold,
71
+ /* 其他別稱 */
72
+ '加權股價': enums_1.Index.TAIEX,
73
+ '未含金融': enums_1.Index.NonFinance,
74
+ '未含電子': enums_1.Index.NonElectronics,
75
+ '未含金融電子': enums_1.Index.NonFinanceNonElectronics,
76
+ '綜合平均': '綜合平均',
77
+ '工業平均': '工業平均',
78
+ '水泥類': enums_1.Index.Cement,
79
+ '水泥工業': enums_1.Index.Cement,
80
+ '水泥工業類': enums_1.Index.Cement,
81
+ '食品類': enums_1.Index.Food,
82
+ '食品工業': enums_1.Index.Food,
83
+ '食品工業類': enums_1.Index.Food,
84
+ '塑膠類': enums_1.Index.Plastic,
85
+ '塑膠工業': enums_1.Index.Plastic,
86
+ '塑膠工業類': enums_1.Index.Plastic,
87
+ '紡織纖維': enums_1.Index.Textiles,
88
+ '紡織纖維類': enums_1.Index.Textiles,
89
+ '電機機械': enums_1.Index.ElectricMachinery,
90
+ '電機機械類': enums_1.Index.ElectricMachinery,
91
+ '電器電纜': enums_1.Index.ElectricalAndCable,
92
+ '電器電纜類': enums_1.Index.ElectricalAndCable,
93
+ '化學工業類': enums_1.Index.ChemicalBiotechnologyAndMedicalCare,
94
+ '化學生技醫': enums_1.Index.ChemicalBiotechnologyAndMedicalCare,
95
+ '化學生技醫療': enums_1.Index.ChemicalBiotechnologyAndMedicalCare,
96
+ '化學生技醫療類': enums_1.Index.ChemicalBiotechnologyAndMedicalCare,
97
+ '玻璃陶瓷': enums_1.Index.GlassAndCeramic,
98
+ '玻璃陶瓷類': enums_1.Index.GlassAndCeramic,
99
+ '造紙類': enums_1.Index.PaperAndPulp,
100
+ '造紙工業': enums_1.Index.PaperAndPulp,
101
+ '造紙工業類': enums_1.Index.PaperAndPulp,
102
+ '鋼鐵類': enums_1.Index.IronAndSteel,
103
+ '鋼鐵工業': enums_1.Index.IronAndSteel,
104
+ '鋼鐵工業類': enums_1.Index.IronAndSteel,
105
+ '橡膠類': enums_1.Index.Rubber,
106
+ '橡膠工業': enums_1.Index.Rubber,
107
+ '橡膠工業類': enums_1.Index.Rubber,
108
+ '汽車類': enums_1.Index.Automobile,
109
+ '汽車工業': enums_1.Index.Automobile,
110
+ '汽車工業類': enums_1.Index.Automobile,
111
+ '電子類': enums_1.Index.Electronics,
112
+ '電子工業': enums_1.Index.Electronics,
113
+ '電子工業類': enums_1.Index.Electronics,
114
+ '建材營造': enums_1.Index.BuildingMaterialsAndConstruction,
115
+ '營造建材類': enums_1.Index.BuildingMaterialsAndConstruction,
116
+ '建材營造類': enums_1.Index.BuildingMaterialsAndConstruction,
117
+ '運輸類': enums_1.Index.ShippingAndTransportation,
118
+ '航運業': enums_1.Index.ShippingAndTransportation,
119
+ '航運業類': enums_1.Index.ShippingAndTransportation,
120
+ '觀光類': enums_1.Index.TourismAndHospitality,
121
+ '觀光事業': enums_1.Index.TourismAndHospitality,
122
+ '觀光事業類': enums_1.Index.TourismAndHospitality,
123
+ '金融保險': enums_1.Index.FinancialAndInsurance,
124
+ '金融保險類': enums_1.Index.FinancialAndInsurance,
125
+ '貿易百貨': enums_1.Index.TradingAndConsumerGoods,
126
+ '百貨貿易類': enums_1.Index.TradingAndConsumerGoods,
127
+ '貿易百貨類': enums_1.Index.TradingAndConsumerGoods,
128
+ '百貨貿易類指數': enums_1.Index.TradingAndConsumerGoods,
129
+ '其它': enums_1.Index.Other,
130
+ '其它類': enums_1.Index.Other,
131
+ '其他': enums_1.Index.Other,
132
+ '其他類': enums_1.Index.Other,
133
+ '化學工業': enums_1.Index.Chemical,
134
+ '生技醫療': enums_1.Index.BiotechnologyAndMedicalCare,
135
+ '油電燃氣': enums_1.Index.OilGasAndElectricity,
136
+ '半導體': enums_1.Index.Semiconductors,
137
+ '電腦及週邊設備': enums_1.Index.ComputerAndPeripheralEquipment,
138
+ '光電': enums_1.Index.Optoelectronics,
139
+ '通信網路': enums_1.Index.CommunicationsTechnologyAndInternet,
140
+ '電子零組件': enums_1.Index.ElectronicPartsComponents,
141
+ '電子通路': enums_1.Index.ElectronicProductsDistirbution,
142
+ '資訊服務': enums_1.Index.InformationService,
143
+ '其他電子': enums_1.Index.OtherElectronics,
144
+ '未含金融保險股指數': enums_1.Index.NonFinance,
145
+ '未含電子股指數': enums_1.Index.NonElectronics,
146
+ '未含金融電子股指數': enums_1.Index.NonFinanceNonElectronics,
147
+ '電子類指數': enums_1.Index.Electronics,
148
+ '觀光類指數': enums_1.Index.TourismAndHospitality,
149
+ '航運業類指數': enums_1.Index.ShippingAndTransportation,
150
+ '觀光事業類指數': enums_1.Index.TourismAndHospitality,
151
+ '櫃買觀光類指數': enums_1.Index.TPExTourismAndHospitality,
152
+ '櫃買生技類指數': enums_1.Index.TPExBiotechnologyAndMedicalCare,
153
+ '櫃買電腦週邊類指數': enums_1.Index.TPExComputerAndPeripheralEquipment,
154
+ '櫃買光電類指數': enums_1.Index.TPExOptoelectronic,
155
+ '櫃買電子零件類指數': enums_1.Index.TPExElectronicPartsComponents,
156
+ '櫃買文化創意類指數': enums_1.Index.TPExCulturalAndCreative,
157
+ '櫃買紡織纖維類指數': enums_1.Index.TPExTextiles,
158
+ '櫃買電機機械類指數': enums_1.Index.TPExElectricMachinery,
159
+ '櫃買鋼鐵工業類指數': enums_1.Index.TPExIronAndSteel,
160
+ '櫃買建材營造類指數': enums_1.Index.TPExBuildingMaterialsAndConstruction,
161
+ '櫃買航運業類指數': enums_1.Index.TPExShippingAndTransportation,
162
+ '櫃買化學工業類指數': enums_1.Index.TPExChemical,
163
+ '櫃買半導體業類指數': enums_1.Index.TPExSemiconductors,
164
+ '櫃買電腦週邊業類指數': enums_1.Index.TPExComputerAndPeripheralEquipment,
165
+ '櫃買通信網路業類指數': enums_1.Index.TPExCommunicationsAndInternet,
166
+ '櫃買電子零組件業類指數': enums_1.Index.TPExElectronicPartsComponents,
167
+ '櫃買電子通路業類指數': enums_1.Index.TPExElectronicProductsDistribution,
168
+ '櫃買資訊服務業類指數': enums_1.Index.TPExInformationService,
169
+ '櫃買其他電子業類指數': enums_1.Index.TPExOtherElectronic,
170
+ '櫃買電子工業類指數': enums_1.Index.TPExElectronic,
171
+ '櫃買電腦及週邊設備業類指數': enums_1.Index.TPExComputerAndPeripheralEquipment,
172
+ '櫃買觀光事業類指數': enums_1.Index.TPExTourismAndHospitality,
173
+ '櫃買紡纖纖維類指數': enums_1.Index.TPExTextiles,
174
+ '櫃買線上遊戲類指數': enums_1.Index.TPExGame,
175
+ };
176
+ return indices[index];
177
+ }
178
+ exports.asIndex = asIndex;
@@ -0,0 +1,2 @@
1
+ import { Industry } from '../enums';
2
+ export declare function asIndustry(industry: string): Industry;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asIndustry = void 0;
4
+ const enums_1 = require("../enums");
5
+ function asIndustry(industry) {
6
+ var _a;
7
+ const industries = {
8
+ '水泥工業': enums_1.Industry.Cement,
9
+ '食品工業': enums_1.Industry.Food,
10
+ '塑膠工業': enums_1.Industry.Plastic,
11
+ '紡織纖維': enums_1.Industry.Textiles,
12
+ '電機機械': enums_1.Industry.ElectricMachinery,
13
+ '電器電纜': enums_1.Industry.ElectricalAndCable,
14
+ '玻璃陶瓷': enums_1.Industry.GlassAndCeramic,
15
+ '造紙工業': enums_1.Industry.PaperAndPulp,
16
+ '鋼鐵工業': enums_1.Industry.IronAndSteel,
17
+ '橡膠工業': enums_1.Industry.Rubber,
18
+ '汽車工業': enums_1.Industry.Automobile,
19
+ '建材營造業': enums_1.Industry.BuildingMaterialsAndConstruction,
20
+ '航運業': enums_1.Industry.ShippingAndTransportation,
21
+ '觀光餐旅': enums_1.Industry.TourismAndHospitality,
22
+ '金融保險業': enums_1.Industry.FinancialAndInsurance,
23
+ '貿易百貨業': enums_1.Industry.TradingAndConsumerGoods,
24
+ '綜合': enums_1.Industry.Miscellaneous,
25
+ '其他業': enums_1.Industry.Other,
26
+ '化學工業': enums_1.Industry.Chemical,
27
+ '生技醫療業': enums_1.Industry.BiotechnologyAndMedicalCare,
28
+ '油電燃氣業': enums_1.Industry.OilGasAndElectricity,
29
+ '半導體業': enums_1.Industry.Semiconductors,
30
+ '電腦及週邊設備業': enums_1.Industry.ComputerAndPeripheralEquipment,
31
+ '光電業': enums_1.Industry.Optoelectronics,
32
+ '通信網路業': enums_1.Industry.CommunicationsTechnologyAndInternet,
33
+ '電子零組件業': enums_1.Industry.ElectronicPartsComponents,
34
+ '電子通路業': enums_1.Industry.ElectronicProductsDistirbution,
35
+ '資訊服務業': enums_1.Industry.InformationService,
36
+ '其他電子業': enums_1.Industry.OtherElectronics,
37
+ '文化創意業': enums_1.Industry.CulturalAndCreative,
38
+ '農業科技業': enums_1.Industry.AgriculturalTechnology,
39
+ '電子商務': enums_1.Industry.Ecommerce,
40
+ '綠能環保': enums_1.Industry.GreenEnergyAndEnvironmentalServices,
41
+ '數位雲端': enums_1.Industry.DigitalAndCloudServices,
42
+ '運動休閒': enums_1.Industry.SportsAndLeisure,
43
+ '居家生活': enums_1.Industry.Household,
44
+ '管理股票': enums_1.Industry.ManagedStock,
45
+ '無所屬產業': enums_1.Industry.None,
46
+ };
47
+ return (_a = industries[industry]) !== null && _a !== void 0 ? _a : enums_1.Industry.None;
48
+ }
49
+ exports.asIndustry = asIndustry;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Convert ROC (Republic of China) date to Western (Gregorian) calendar date
3
+ *
4
+ * @param rocDate - ROC date string in formats:
5
+ * - "114年01月02日" (year/month/day with Chinese characters)
6
+ * - "114/01/02" (slash format)
7
+ * - "114年1月2日" (without leading zeros)
8
+ * @returns ISO format date string "YYYY-MM-DD" or original string if format not recognized
9
+ *
10
+ * @example
11
+ * rocToWestern("114年01月02日") // "2025-01-02"
12
+ * rocToWestern("114/01/02") // "2025-01-02"
13
+ * rocToWestern("114年1月2日") // "2025-01-02"
14
+ */
15
+ export declare function rocToWestern(rocDate: string): string;
16
+ /**
17
+ * Convert Western (Gregorian) calendar date to ROC (Republic of China) date
18
+ *
19
+ * @param westernDate - Western date string in ISO format "YYYY-MM-DD"
20
+ * @param format - Output format: "chinese" (default) or "slash"
21
+ * @returns ROC date string or original string if format not recognized
22
+ *
23
+ * @example
24
+ * westernToRoc("2025-01-02") // "114年01月02日"
25
+ * westernToRoc("2025-01-02", "slash") // "114/01/02"
26
+ * westernToRoc("2025-01-02", "chinese") // "114年01月02日"
27
+ */
28
+ export declare function westernToRoc(westernDate: string, format?: 'chinese' | 'slash'): string;
29
+ /**
30
+ * Parse financial report date that may contain HTML link
31
+ *
32
+ * @param value - Date string that may contain HTML link in parentheses
33
+ * - "113年06月28日(https://mops.twse.com.tw/mops/web/t78sb35)" (date format)
34
+ * - "114年第3季(https://mops.twse.com.tw/mops/web/t163sb01)" (quarterly format)
35
+ * - "113年06月28日" (date without link)
36
+ * - "114年第3季" (quarter without link)
37
+ * - "N/A" or empty string
38
+ * @returns ISO format date string "YYYY-MM-DD", quarterly string "XXX年第X季", or null
39
+ *
40
+ * @example
41
+ * parseFinancialReportDate("113年06月28日(https://...)") // "2024-06-28"
42
+ * parseFinancialReportDate("114年第3季(https://...)") // "114年第3季"
43
+ * parseFinancialReportDate("113年06月28日") // "2024-06-28"
44
+ * parseFinancialReportDate("114年第1季") // "114年第1季"
45
+ * parseFinancialReportDate("N/A") // null
46
+ */
47
+ export declare function parseFinancialReportDate(value: string): string | null;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFinancialReportDate = exports.westernToRoc = exports.rocToWestern = void 0;
4
+ /**
5
+ * Convert ROC (Republic of China) date to Western (Gregorian) calendar date
6
+ *
7
+ * @param rocDate - ROC date string in formats:
8
+ * - "114年01月02日" (year/month/day with Chinese characters)
9
+ * - "114/01/02" (slash format)
10
+ * - "114年1月2日" (without leading zeros)
11
+ * @returns ISO format date string "YYYY-MM-DD" or original string if format not recognized
12
+ *
13
+ * @example
14
+ * rocToWestern("114年01月02日") // "2025-01-02"
15
+ * rocToWestern("114/01/02") // "2025-01-02"
16
+ * rocToWestern("114年1月2日") // "2025-01-02"
17
+ */
18
+ function rocToWestern(rocDate) {
19
+ if (!rocDate || typeof rocDate !== 'string') {
20
+ return rocDate;
21
+ }
22
+ // Format: "114年01月02日" or "114年1月2日"
23
+ const yearMonthDayMatch = rocDate.match(/(\d+)年(\d+)月(\d+)日/);
24
+ if (yearMonthDayMatch) {
25
+ const [, year, month, day] = yearMonthDayMatch;
26
+ const westernYear = parseInt(year) + 1911;
27
+ return `${westernYear}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
28
+ }
29
+ // Format: "114/01/02" or "114/1/2"
30
+ const slashMatch = rocDate.match(/^(\d+)\/(\d+)\/(\d+)$/);
31
+ if (slashMatch) {
32
+ const [, year, month, day] = slashMatch;
33
+ const westernYear = parseInt(year) + 1911;
34
+ return `${westernYear}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
35
+ }
36
+ // Format: "1141231" (YYYMMDD - 3-digit year + 2-digit month + 2-digit day)
37
+ const compactMatch = rocDate.match(/^(\d{3})(\d{2})(\d{2})$/);
38
+ if (compactMatch) {
39
+ const [, year, month, day] = compactMatch;
40
+ const westernYear = parseInt(year) + 1911;
41
+ return `${westernYear}-${month}-${day}`;
42
+ }
43
+ // Return original if format not recognized
44
+ return rocDate;
45
+ }
46
+ exports.rocToWestern = rocToWestern;
47
+ /**
48
+ * Convert Western (Gregorian) calendar date to ROC (Republic of China) date
49
+ *
50
+ * @param westernDate - Western date string in ISO format "YYYY-MM-DD"
51
+ * @param format - Output format: "chinese" (default) or "slash"
52
+ * @returns ROC date string or original string if format not recognized
53
+ *
54
+ * @example
55
+ * westernToRoc("2025-01-02") // "114年01月02日"
56
+ * westernToRoc("2025-01-02", "slash") // "114/01/02"
57
+ * westernToRoc("2025-01-02", "chinese") // "114年01月02日"
58
+ */
59
+ function westernToRoc(westernDate, format = 'chinese') {
60
+ if (!westernDate || typeof westernDate !== 'string') {
61
+ return westernDate;
62
+ }
63
+ // Format: "YYYY-MM-DD"
64
+ const match = westernDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
65
+ if (!match) {
66
+ return westernDate;
67
+ }
68
+ const [, year, month, day] = match;
69
+ const rocYear = parseInt(year) - 1911;
70
+ if (rocYear < 1) {
71
+ // Date before 1912 cannot be represented in ROC calendar
72
+ return westernDate;
73
+ }
74
+ if (format === 'slash') {
75
+ return `${rocYear}/${month}/${day}`;
76
+ }
77
+ return `${rocYear}年${month}月${day}日`;
78
+ }
79
+ exports.westernToRoc = westernToRoc;
80
+ /**
81
+ * Parse financial report date that may contain HTML link
82
+ *
83
+ * @param value - Date string that may contain HTML link in parentheses
84
+ * - "113年06月28日(https://mops.twse.com.tw/mops/web/t78sb35)" (date format)
85
+ * - "114年第3季(https://mops.twse.com.tw/mops/web/t163sb01)" (quarterly format)
86
+ * - "113年06月28日" (date without link)
87
+ * - "114年第3季" (quarter without link)
88
+ * - "N/A" or empty string
89
+ * @returns ISO format date string "YYYY-MM-DD", quarterly string "XXX年第X季", or null
90
+ *
91
+ * @example
92
+ * parseFinancialReportDate("113年06月28日(https://...)") // "2024-06-28"
93
+ * parseFinancialReportDate("114年第3季(https://...)") // "114年第3季"
94
+ * parseFinancialReportDate("113年06月28日") // "2024-06-28"
95
+ * parseFinancialReportDate("114年第1季") // "114年第1季"
96
+ * parseFinancialReportDate("N/A") // null
97
+ */
98
+ function parseFinancialReportDate(value) {
99
+ if (!value || value === 'N/A' || value.trim() === '') {
100
+ return null;
101
+ }
102
+ // Extract content before the link: "113年06月28日(https://..." or "114年第3季(https://..."
103
+ const contentMatch = value.match(/^(.+?)\(/);
104
+ const content = contentMatch ? contentMatch[1].trim() : value.trim();
105
+ // Check if it's a quarterly format: "114年第3季"
106
+ const quarterMatch = content.match(/^\d+年第[1-4]季$/);
107
+ if (quarterMatch) {
108
+ return content; // Return original quarterly string
109
+ }
110
+ // Otherwise, try to convert as date format
111
+ return rocToWestern(content);
112
+ }
113
+ exports.parseFinancialReportDate = parseFinancialReportDate;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Strip HTML tags from a string
3
+ *
4
+ * Removes all HTML tags and trims whitespace.
5
+ * Useful for cleaning HTML content in API responses.
6
+ *
7
+ * @param html - String potentially containing HTML tags
8
+ * @returns Plain text with HTML tags removed and whitespace trimmed
9
+ *
10
+ * @example
11
+ * stripHtmlTags("<p>Hello</p>") // "Hello"
12
+ * stripHtmlTags("<p style='color:red;'>World</p>") // "World"
13
+ * stripHtmlTags("<p>待公告實際收益分配金額</p>") // "待公告實際收益分配金額"
14
+ * stripHtmlTags("Plain text") // "Plain text"
15
+ */
16
+ export declare function stripHtmlTags(html: string | null | undefined): string;
17
+ /**
18
+ * Extract text content from table cell that may contain HTML
19
+ *
20
+ * This is a convenience wrapper around stripHtmlTags specifically
21
+ * for extracting text from table cells in scraped data.
22
+ *
23
+ * @param cell - Cell content that may contain HTML
24
+ * @returns Plain text content
25
+ *
26
+ * @example
27
+ * extractTextFromCell("<p style='text-align:center;'>待公告</p>") // "待公告"
28
+ */
29
+ export declare function extractTextFromCell(cell: string | null | undefined): string;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTextFromCell = exports.stripHtmlTags = void 0;
4
+ /**
5
+ * Strip HTML tags from a string
6
+ *
7
+ * Removes all HTML tags and trims whitespace.
8
+ * Useful for cleaning HTML content in API responses.
9
+ *
10
+ * @param html - String potentially containing HTML tags
11
+ * @returns Plain text with HTML tags removed and whitespace trimmed
12
+ *
13
+ * @example
14
+ * stripHtmlTags("<p>Hello</p>") // "Hello"
15
+ * stripHtmlTags("<p style='color:red;'>World</p>") // "World"
16
+ * stripHtmlTags("<p>待公告實際收益分配金額</p>") // "待公告實際收益分配金額"
17
+ * stripHtmlTags("Plain text") // "Plain text"
18
+ */
19
+ function stripHtmlTags(html) {
20
+ if (html == null) {
21
+ return '';
22
+ }
23
+ const strValue = String(html);
24
+ // Remove all HTML tags
25
+ const withoutTags = strValue.replace(/<[^>]*>/g, '');
26
+ // Trim whitespace
27
+ return withoutTags.trim();
28
+ }
29
+ exports.stripHtmlTags = stripHtmlTags;
30
+ /**
31
+ * Extract text content from table cell that may contain HTML
32
+ *
33
+ * This is a convenience wrapper around stripHtmlTags specifically
34
+ * for extracting text from table cells in scraped data.
35
+ *
36
+ * @param cell - Cell content that may contain HTML
37
+ * @returns Plain text content
38
+ *
39
+ * @example
40
+ * extractTextFromCell("<p style='text-align:center;'>待公告</p>") // "待公告"
41
+ */
42
+ function extractTextFromCell(cell) {
43
+ return stripHtmlTags(cell);
44
+ }
45
+ exports.extractTextFromCell = extractTextFromCell;
@@ -0,0 +1,7 @@
1
+ export * from './as-index.util';
2
+ export * from './as-industry.util';
3
+ export * from './as-exchange.util';
4
+ export * from './is-warrant.util';
5
+ export * from './date-converter.util';
6
+ export * from './parse-numeric.util';
7
+ export * from './html-cleaner.util';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./as-index.util"), exports);
18
+ __exportStar(require("./as-industry.util"), exports);
19
+ __exportStar(require("./as-exchange.util"), exports);
20
+ __exportStar(require("./is-warrant.util"), exports);
21
+ __exportStar(require("./date-converter.util"), exports);
22
+ __exportStar(require("./parse-numeric.util"), exports);
23
+ __exportStar(require("./html-cleaner.util"), exports);
@@ -0,0 +1 @@
1
+ export declare function isWarrant(symbol: string): boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWarrant = void 0;
4
+ function isWarrant(symbol) {
5
+ const rules = [
6
+ /^0[3-8][0-9][0-9][0-9][0-9]$/,
7
+ /^0[3-8][0-9][0-9][0-9]P$/,
8
+ /^0[3-8][0-9][0-9][0-9]F$/,
9
+ /^0[3-8][0-9][0-9][0-9]Q$/,
10
+ /^0[3-8][0-9][0-9][0-9]C$/,
11
+ /^0[3-8][0-9][0-9][0-9]B$/,
12
+ /^0[3-8][0-9][0-9][0-9]X$/,
13
+ /^0[3-8][0-9][0-9][0-9]Y$/,
14
+ /^7[0-3][0-9][0-9][0-9][0-9]$/,
15
+ /^7[0-3][0-9][0-9][0-9]P$/,
16
+ /^7[0-3][0-9][0-9][0-9]F$/,
17
+ /^7[0-3][0-9][0-9][0-9]Q$/,
18
+ /^7[0-3][0-9][0-9][0-9]C$/,
19
+ /^7[0-3][0-9][0-9][0-9]B$/,
20
+ /^7[0-3][0-9][0-9][0-9]X$/,
21
+ /^7[0-3][0-9][0-9][0-9]Y$/, // 上櫃國內標的可展延上限型認售權證
22
+ ];
23
+ return rules.some(regex => regex.test(symbol));
24
+ }
25
+ exports.isWarrant = isWarrant;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Parse numeric value from string with null-safe handling
3
+ *
4
+ * Handles various empty/invalid representations:
5
+ * - Empty string, null, undefined
6
+ * - "--" (common placeholder)
7
+ * - "N/A" (not applicable)
8
+ * - Whitespace-only strings
9
+ *
10
+ * @param value - String value to parse
11
+ * @returns Parsed number or null if value is empty/invalid
12
+ *
13
+ * @example
14
+ * parseNumeric("123.45") // 123.45
15
+ * parseNumeric("--") // null
16
+ * parseNumeric("") // null
17
+ * parseNumeric("N/A") // null
18
+ * parseNumeric(" ") // null
19
+ * parseNumeric("0") // 0
20
+ */
21
+ export declare function parseNumeric(value: string | null | undefined): number | null;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseNumeric = void 0;
4
+ const numeral = require("numeral");
5
+ /**
6
+ * Parse numeric value from string with null-safe handling
7
+ *
8
+ * Handles various empty/invalid representations:
9
+ * - Empty string, null, undefined
10
+ * - "--" (common placeholder)
11
+ * - "N/A" (not applicable)
12
+ * - Whitespace-only strings
13
+ *
14
+ * @param value - String value to parse
15
+ * @returns Parsed number or null if value is empty/invalid
16
+ *
17
+ * @example
18
+ * parseNumeric("123.45") // 123.45
19
+ * parseNumeric("--") // null
20
+ * parseNumeric("") // null
21
+ * parseNumeric("N/A") // null
22
+ * parseNumeric(" ") // null
23
+ * parseNumeric("0") // 0
24
+ */
25
+ function parseNumeric(value) {
26
+ // Check for null/undefined
27
+ if (value == null) {
28
+ return null;
29
+ }
30
+ // Convert to string if needed
31
+ const strValue = String(value).trim();
32
+ // Check for empty or placeholder values
33
+ if (isEmptyValue(strValue)) {
34
+ return null;
35
+ }
36
+ // Parse using numeral
37
+ const parsed = numeral(strValue).value();
38
+ // Validate result
39
+ if (parsed === null || isNaN(parsed)) {
40
+ return null;
41
+ }
42
+ return parsed;
43
+ }
44
+ exports.parseNumeric = parseNumeric;
45
+ /**
46
+ * Check if a value represents an empty/invalid numeric value
47
+ *
48
+ * @param value - String value to check
49
+ * @returns true if value is considered empty/invalid
50
+ */
51
+ function isEmptyValue(value) {
52
+ if (!value || value.trim() === '') {
53
+ return true;
54
+ }
55
+ // Common placeholder values
56
+ const placeholders = ['--', 'N/A', 'n/a', '--', '尚未公告', '待公告'];
57
+ return placeholders.includes(value);
58
+ }