@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
package/README.md ADDED
@@ -0,0 +1,1837 @@
1
+ # node-twstock
2
+
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![Build Status][action-image]][action-url]
5
+ [![Coverage Status][codecov-image]][codecov-url]
6
+
7
+ > A client library for scraping Taiwan stock market data
8
+
9
+ 專為擷取台灣股市資料而設計的客戶端程式庫。使用前請務必詳細閱讀相關的 [使用規範與聲明](#disclaimer)。
10
+
11
+ ## Table of Contents
12
+
13
+ * [Installation](#installation)
14
+ * [Usage](#usage)
15
+ * [API](#api)
16
+ * [new TwStock([options])](#new-twstockoptions)
17
+ * [.stocks.list([options])](#stockslistoptions)
18
+ * [.stocks.quote(options)](#stocksquoteoptions)
19
+ * [.stocks.historical(options)](#stockshistoricaloptions)
20
+ * [.stocks.institutional(options)](#stocksinstitutionaloptions)
21
+ * [.stocks.finiHoldings(options)](#stocksfiniholdingsoptions)
22
+ * [.stocks.marginTrades(options)](#stocksmargintradesoptions)
23
+ * [.stocks.shortSales(options)](#stocksshortsalesoptions)
24
+ * [.stocks.values(options)](#stocksvaluesoptions)
25
+ * [.stocks.shareholders(options)](#stocksshareholdersoptions)
26
+ * [.stocks.eps(options)](#stocksepsoptions)
27
+ * [.stocks.revenue(options)](#stocksrevenueoptions)
28
+ * [.stocks.dividends(options)](#stocksdividendsoptions)
29
+ * [.stocks.dividendsAnnouncement([options])](#stocksdividendsannouncementoptions)
30
+ * [.stocks.capitalReductions(options)](#stockscapitalreductionoptions)
31
+ * [.stocks.capitalReductionAnnouncement([options])](#stockscapitalreductionannouncementoptions)
32
+ * [.stocks.splits(options)](#stockssplitsoptions)
33
+ * [.stocks.splitAnnouncement([options])](#stockssplitannouncementoptions)
34
+ * [.stocks.etfSplits(options)](#stocksetfsplitsoptions)
35
+ * [.stocks.etfSplitAnnouncement([options])](#stocksetfsplitannouncementoptions)
36
+ * [.indices.list([options])](#indiceslistoptions)
37
+ * [.indices.quote(options)](#indicesquoteoptions)
38
+ * [.indices.historical(options)](#indiceshistoricaloptions)
39
+ * [.indices.trades(options)](#indicestradesoptions)
40
+ * [.market.trades(options)](#markettradesoptions)
41
+ * [.market.breadth(options)](#marketbreadthoptions)
42
+ * [.market.institutional(options)](#marketinstitutionaloptions)
43
+ * [.market.marginTrades(options)](#marketmargintradesoptions)
44
+ * [.futopt.list(options)](#futoptlist)
45
+ * [.futopt.quote(options)](#futoptquoteoptions)
46
+ * [.futopt.historical(options)](#futopthistoricaloptions)
47
+ * [.futopt.institutional(options)](#futoptinstitutionaloptions)
48
+ * [.futopt.largeTraders(options)](#futoptlargetradersoptions)
49
+ * [.futopt.mxfRetailPosition(options)](#futoptmxfretailpositionoptions)
50
+ * [.futopt.tmfRetailPosition(options)](#futopttmfretailpositionoptions)
51
+ * [.futopt.txoPutCallRatio(options)](#futopttxoputcallratiooptions)
52
+ * [.futopt.exchangeRates(options)](#futoptexchangeratesoptions)
53
+ * [Manual Testing](#manual-testing)
54
+ * [Disclaimer](#disclaimer)
55
+ * [Changelog](#changelog)
56
+ * [License](#license)
57
+
58
+ ## Installation
59
+
60
+ ```sh
61
+ $ npm install --save node-twstock
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ ```js
67
+ const { TwStock } = require('node-twstock');
68
+ ```
69
+
70
+ ## API
71
+
72
+ ### `new TwStock([options])`
73
+
74
+ 建立 `TwStock` 實例,用於取得台灣股票市場資料。
75
+
76
+ * `options`: {Object} 可配置選項,用於設定速率限制 (Rate Limiting)
77
+ - `ttl`: 每個請求持續的毫秒數。**Default:** `5000`
78
+ - `limit`: 在 TTL 限制內的最大請求數。**Default:** `1`
79
+
80
+ > 注意:過於頻繁的請求可能導致被交易所禁止訪問。預設設定為每 5 秒最多發送 1 個請求。
81
+
82
+ ```js
83
+ const twstock = new TwStock({ ttl: 5000, limit: 3 });
84
+ ```
85
+
86
+ ### `.stocks.list([options])`
87
+
88
+ 取得上市(櫃)股票列表。
89
+
90
+ * `options`: {Object}
91
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
92
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
93
+ * `symbol`: {string} 股票代號
94
+ * `name`: {string} 股票名稱
95
+ * `exchange`: {string} 市場別
96
+ * `type`: {string} 有價證券別
97
+ * `industry`: {string} 產業別 (參閱 [產業別代碼](#產業別代碼))
98
+ * `listedDate`: {string} 上市(櫃)日期
99
+
100
+ ```js
101
+ twstock.stocks.list({ exchange: 'TWSE' })
102
+ .then(data => console.log(data));
103
+ // Prints:
104
+ // [
105
+ // {
106
+ // symbol: '0050',
107
+ // name: '元大台灣50',
108
+ // exchange: 'TWSE',
109
+ // type: 'ETF',
110
+ // industry: '00',
111
+ // listedDate: '2003-06-30'
112
+ // },
113
+ // ... more items
114
+ // ]
115
+ ```
116
+
117
+ #### 產業別代碼
118
+
119
+ | 代碼 | 產業別 | 代碼 | 產業別 | 代碼 | 產業別 |
120
+ |:---:|-----|:---:|-----|:-----:|-----|
121
+ | 01 | 水泥工業 | 16 | 觀光餐旅 | 29 | 電子通路業 |
122
+ | 02 | 食品工業 | 17 | 金融保險 | 30 | 資訊服務業 |
123
+ | 03 | 塑膠工業 | 18 | 貿易百貨 | 31 | 其他電子業 |
124
+ | 04 | 紡織纖維 | 19 | 綜合 | 32 | 文化創意業 |
125
+ | 05 | 電機機械 | 20 | 其他 | 33 | 農業科技業 |
126
+ | 06 | 電器電纜 | 21 | 化學工業 | 34 | 電子商務 |
127
+ | 08 | 玻璃陶瓷 | 22 | 生技醫療業 | 35 | 綠能環保 |
128
+ | 09 | 造紙工業 | 23 | 油電燃氣業 | 36 | 數位雲端 |
129
+ | 10 | 鋼鐵工業 | 24 | 半導體業 | 37 | 運動休閒 |
130
+ | 11 | 橡膠工業 | 25 | 電腦及週邊設備業 | 38 | 居家生活 |
131
+ | 12 | 汽車工業 | 26 | 光電業 |
132
+ | 14 | 建材營造 | 27 | 通信網路業 |
133
+ | 15 | 航運業 | 28 | 電子零組件業 |
134
+
135
+ ### `.stocks.quote(options)`
136
+
137
+ 取得股票行情報價。
138
+
139
+ * `options`: {Object}
140
+ * `symbol`: {string} 股票代號
141
+ * `odd` (optional): {boolean} 盤中零股交易
142
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
143
+ * `date`: {string} 日期
144
+ * `symbol`: {string} 股票代號
145
+ * `name`: {string} 股票名稱
146
+ * `referencePrice`: {number} 參考價
147
+ * `limitUpPrice`: {number} 漲停價
148
+ * `limitDownPrice`: {number} 跌停價
149
+ * `openPrice`: {number} 開盤價
150
+ * `highPrice`: {number} 最高價
151
+ * `lowPrice`: {number} 最低價
152
+ * `lastPrice`: {number} 最後成交價格
153
+ * `lastSize`: {number} 最後成交數量
154
+ * `totalVoluem`: {number} 總成交量
155
+ * `bidPrice`: {number[]} 最佳委買價格
156
+ * `askPrice`: {number[]} 最佳委賣價格
157
+ * `bidSize`: {number[]} 最佳委買數量
158
+ * `askSize`: {number[]} 最佳委賣數量
159
+ * `lastUpdated`: {number} 最後更新時間
160
+
161
+ ```js
162
+ twstock.stocks.quote({ symbol: '2330' })
163
+ .then(data => console.log(data));
164
+ // Prints:
165
+ // {
166
+ // date: '2023-12-29',
167
+ // symbol: '2330',
168
+ // name: '台積電',
169
+ // referencePrice: 593,
170
+ // limitUpPrice: 652,
171
+ // limitDownPrice: 534,
172
+ // openPrice: 589,
173
+ // highPrice: 593,
174
+ // lowPrice: 589,
175
+ // lastPrice: 593,
176
+ // lastSize: 4174,
177
+ // totalVoluem: 18323,
178
+ // bidPrice: [ 592, 591, 590, 589, 588 ],
179
+ // askPrice: [ 593, 594, 595, 596, 597 ],
180
+ // bidSize: [ 827, 768, 1137, 554, 446 ],
181
+ // askSize: [ 1938, 1465, 2925, 2407, 921 ],
182
+ // lastUpdated: 1703831400000
183
+ // }
184
+ ```
185
+
186
+ ### `.stocks.historical(options)`
187
+
188
+ 取得股票在特定日期的收盤行情。
189
+
190
+ * `options`: {Object}
191
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
192
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
193
+ * `symbol` (optional): {string} 股票代號
194
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
195
+ * `date`: {string} 日期
196
+ * `exchange`: {string} 市場別
197
+ * `symbol`: {string} 股票代號
198
+ * `name`: {string} 股票名稱
199
+ * `open`: {number} 開盤價
200
+ * `high`: {number} 最高價
201
+ * `low`: {number} 最低價
202
+ * `close`: {number} 收盤價
203
+ * `volume`: {number} 成交股數
204
+ * `turnover`: {number} 成交金額
205
+ * `transaction`: {number} 成交筆數
206
+ * `change`: {number} 漲跌
207
+
208
+ ```js
209
+ twstock.stocks.historical({ date: '2023-01-30', symbol: '2330' })
210
+ .then(data => console.log(data));
211
+ // Prints:
212
+ // {
213
+ // date: '2023-01-30',
214
+ // exchange: 'TWSE',
215
+ // symbol: '2330',
216
+ // name: '台積電',
217
+ // open: 542,
218
+ // high: 543,
219
+ // low: 534,
220
+ // close: 543,
221
+ // volume: 148413161,
222
+ // turnover: 80057158264,
223
+ // transaction: 153125,
224
+ // change: 40
225
+ // }
226
+ ```
227
+
228
+ ### `.stocks.institutional(options)`
229
+
230
+ 取得股票在特定日期的三大法人買賣超。
231
+
232
+ * `options`: {Object}
233
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
234
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
235
+ * `symbol` (optional): {string} 股票代號
236
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
237
+ * `date`: {string} 日期
238
+ * `exchange`: {string} 市場別
239
+ * `symbol`: {string} 股票代號
240
+ * `name`: {string} 股票名稱
241
+ * `institutional`: {Object[]} 三大法人買賣金額統計,其中 `Object` 包含以下屬性:
242
+ * `investor`: {number} 單位名稱
243
+ * `totalBuy`: {number} 買進金額
244
+ * `totalSell`: {number} 賣出金額
245
+ * `difference`: {number} 買賣差額
246
+
247
+ ```js
248
+ twstock.stocks.institutional({ date: '2023-01-30', symbol: '2330' })
249
+ .then(data => console.log(data));
250
+ // Prints:
251
+ // {
252
+ // date: '2023-01-30',
253
+ // symbol: '2330',
254
+ // exchange: 'TWSE',
255
+ // name: '台積電',
256
+ // institutional: [
257
+ // {
258
+ // investor: '外資及陸資(不含外資自營商)',
259
+ // totalBuy: 133236588,
260
+ // totalSell: 52595539,
261
+ // difference: 80641049
262
+ // },
263
+ // {
264
+ // investor: '外資自營商',
265
+ // totalBuy: 0,
266
+ // totalSell: 0,
267
+ // difference: 0
268
+ // },
269
+ // {
270
+ // investor: '外資自營商',
271
+ // totalBuy: 0,
272
+ // totalSell: 0,
273
+ // difference: 0
274
+ // },
275
+ // {
276
+ // investor: '投信',
277
+ // totalBuy: 1032000,
278
+ // totalSell: 94327,
279
+ // difference: 937673
280
+ // },
281
+ // {
282
+ // investor: '自營商',
283
+ // difference: 880408
284
+ // },
285
+ // {
286
+ // investor: '自營商(自行買賣)',
287
+ // totalBuy: 978000,
288
+ // totalSell: 537000,
289
+ // difference: 441000
290
+ // },
291
+ // {
292
+ // investor: '自營商(避險)',
293
+ // totalBuy: 1227511,
294
+ // totalSell: 788103,
295
+ // difference: 439408
296
+ // },
297
+ // {
298
+ // investor: '三大法人',
299
+ // difference: 82459130
300
+ // }
301
+ // ]
302
+ // }
303
+ ```
304
+
305
+ ### `.stocks.finiHoldings(options)`
306
+
307
+ 取得股票在特定日期的外資持股比例。
308
+
309
+ * `options`: {Object}
310
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
311
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
312
+ * `symbol` (optional): {string} 股票代號
313
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
314
+ * `date`: {string} 日期
315
+ * `exchange`: {string} 市場別
316
+ * `symbol`: {string} 股票代號
317
+ * `name`: {string} 股票名稱
318
+ * `issuedShares`: {number} 發行股數
319
+ * `availableShares`: {number} 外資及陸資尚可投資股數
320
+ * `sharesHeld`: {number} 全體外資及陸資持有股數
321
+ * `availablePercent`: {number} 外資及陸資尚可投資比率
322
+ * `heldPercent`: {number} 全體外資及陸資持股比率
323
+ * `upperLimitPercent`: {number} 外資及陸資共用法令投資上限比率
324
+
325
+ ```js
326
+ twstock.stocks.finiHoldings({ date: '2023-01-30', symbol: '2330' })
327
+ .then(data => console.log(data));
328
+ // Prints:
329
+ // {
330
+ // date: '2023-01-30',
331
+ // exchange: 'TWSE',
332
+ // symbol: '2330',
333
+ // name: '台積電',
334
+ // issuedShares: 25930380458,
335
+ // availableShares: 7329280055,
336
+ // sharesHeld: 18601100403,
337
+ // availablePercent: 28.26,
338
+ // heldPercent: 71.73,
339
+ // upperLimitPercent: 100
340
+ // }
341
+ ```
342
+
343
+ ### `.stocks.marginTrades(options)`
344
+
345
+ 取得股票在特定日期的融資融券餘額。
346
+
347
+ * `options`: {Object}
348
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
349
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
350
+ * `symbol` (optional): {string} 股票代號
351
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
352
+ * `date`: {string} 日期
353
+ * `exchange`: {string} 市場別
354
+ * `symbol`: {string} 股票代號
355
+ * `name`: {string} 股票名稱
356
+ * `marginBuy`: {number} 融資買進
357
+ * `marginSell`: {number} 融資賣出
358
+ * `marginRedeem`: {number} 現金償還
359
+ * `marginBalancePrev`: {number} 前日融資餘額
360
+ * `marginBalance`: {number} 今日融資餘額
361
+ * `marginQuota`: {number} 融資限額
362
+ * `shortBuy`: {number} 融券買進
363
+ * `shortSell`: {number} 融券賣出
364
+ * `shortRedeem`: {number} 現券償還
365
+ * `shortBalancePrev`: {number} 前日融券餘額
366
+ * `shortBalance`: {number} 今日融券餘額
367
+ * `shortQuota`: {number} 融券限額
368
+ * `offset`: {number} 資券互抵
369
+ * `note`: {string} 備註 (參閱 [融資融券符號說明](#融資融券符號說明))
370
+
371
+ #### 融資融券符號說明
372
+
373
+ | 符號 | 說明 |
374
+ |:---:|-----|
375
+ | O | 停止融資 |
376
+ | X | 停止融券 |
377
+ | @ | 融資分配 |
378
+ | % | 融券分配 |
379
+ | ! | 停止買賣 |
380
+
381
+ ```js
382
+ twstock.stocks.marginTrades({ date: '2023-01-30', symbol: '2330' })
383
+ .then(data => console.log(data));
384
+ // Prints:
385
+ // {
386
+ // date: '2023-01-30',
387
+ // exchange: 'TWSE',
388
+ // symbol: '2330',
389
+ // name: '台積電',
390
+ // marginBuy: 1209,
391
+ // marginSell: 2295,
392
+ // marginRedeem: 74,
393
+ // marginBalancePrev: 20547,
394
+ // marginBalance: 19387,
395
+ // marginQuota: 6482595,
396
+ // shortBuy: 56,
397
+ // shortSell: 284,
398
+ // shortRedeem: 101,
399
+ // shortBalancePrev: 1506,
400
+ // shortBalance: 1633,
401
+ // shortQuota: 6482595,
402
+ // offset: 7,
403
+ // note: ''
404
+ // }
405
+ ```
406
+
407
+ ### `.stocks.shortSales(options)`
408
+
409
+ 取得股票在特定日期的融券借券賣出餘額。
410
+
411
+ * `options`: {Object}
412
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
413
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
414
+ * `symbol` (optional): {string} 股票代號
415
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
416
+ * `date`: {string} 日期
417
+ * `exchange`: {string} 市場別
418
+ * `symbol`: {string} 股票代號
419
+ * `name`: {string} 股票名稱
420
+ * `marginShortBalancePrev`: {number} 融券前日餘額
421
+ * `marginShortSell`: {number} 融券賣出
422
+ * `marginShortBuy`: {number} 融券買進
423
+ * `marginShortRedeem`: {number} 現券償還
424
+ * `marginShortBalance`: {number} 融券當日餘額
425
+ * `marginShortQuota`: {number} 融資限額
426
+ * `sblShortBalancePrev`: {number} 借券賣出前日餘額
427
+ * `sblShortSale`: {number} 借券賣出當日賣出
428
+ * `sblShortReturn`: {number} 借券賣出當日還券
429
+ * `sblShortAdjustment`: {number} 借券賣出當日調整
430
+ * `sblShortBalance`: {number} 借券賣出當日餘額
431
+ * `sblShortQuota`: {number} 次一營業日可借券賣出限額
432
+ * `note`: {string} 備註 (參閱 [融券借券符號說明](#融券借券符號說明))
433
+
434
+ #### 融券借券符號說明
435
+
436
+ | 符號 | 說明 |
437
+ |:---:|-----|
438
+ | X | 停券 |
439
+ | Y | 未取得信用交易資格 |
440
+ | V | 不得借券交易且無借券餘額停止借券賣出 |
441
+ | % | 信用額度分配 |
442
+ | Z | 借券賣出餘額已達總量控管標準或初次上市無賣出額度暫停借券賣出 |
443
+ | ! | 停止買賣 |
444
+
445
+ ```js
446
+ twstock.stocks.shortSales({ date: '2023-01-30', symbol: '2330' })
447
+ .then(data => console.log(data));
448
+ // Prints:
449
+ // {
450
+ // date: '2023-01-30',
451
+ // exchange: 'TWSE',
452
+ // symbol: '2330',
453
+ // name: '台積電',
454
+ // marginShortBalancePrev: 1506000,
455
+ // marginShortSell: 284000,
456
+ // marginShortBuy: 56000,
457
+ // marginShortRedeem: 101000,
458
+ // marginShortBalance: 1633000,
459
+ // marginShortQuota: 6482595114,
460
+ // sblShortBalancePrev: 30846988,
461
+ // sblShortSale: 286000,
462
+ // sblShortReturn: 742000,
463
+ // sblShortAdjustment: 0,
464
+ // sblShortBalance: 30390988,
465
+ // sblShortQuota: 3399967,
466
+ // note: ''
467
+ // }
468
+ ```
469
+
470
+ ### `.stocks.values(options)`
471
+
472
+ 取得股票在特定日期的本益比、殖利率及股價淨值比。
473
+
474
+ * `options`: {Object}
475
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
476
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
477
+ * `symbol` (optional): {string} 股票代號
478
+ * Returns: {Promise} 成功時以 {Object[] | Object} 履行,其中 `Object` 包含以下屬性:
479
+ * `date`: {string} 日期
480
+ * `exchange`: {string} 市場別
481
+ * `symbol`: {string} 股票代號
482
+ * `name`: {string} 股票名稱
483
+ * `peRatio`: {number} 本益比
484
+ * `pbRatio`: {number} 股價淨值比
485
+ * `dividendYield`: {number} 殖利率
486
+ * `dividendYear`: {number} 股利年度
487
+
488
+ ```js
489
+ twstock.stocks.values({ date: '2023-01-30', symbol: '2330' })
490
+ .then(data => console.log(data));
491
+ // Prints:
492
+ // {
493
+ // date: '2023-01-30',
494
+ // exchange: 'TWSE',
495
+ // symbol: '2330',
496
+ // name: '台積電',
497
+ // peRatio: 15.88,
498
+ // pbRatio: 5.14,
499
+ // dividendYield: 2.03,
500
+ // dividendYear: 2021
501
+ // }
502
+ ```
503
+
504
+ ### `.stocks.shareholders(options)`
505
+
506
+ 取得股票在特定日期的集保分佈。
507
+
508
+ * `options`: {Object}
509
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
510
+ * `symbol`: {string} 股票代號
511
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
512
+ * `date`: {string} 日期
513
+ * `symbol`: {string} 股票代號
514
+ * `shareholders`: {Object[]} 集保分佈資料,其中 `Object` 包含以下屬性:
515
+ * `level`: {string} 持股分級
516
+ * `holders`: {number} 持股人數
517
+ * `shares`: {number} 持股股數
518
+ * `proportion`: {number} 持股比例
519
+
520
+ #### 持股分級表
521
+
522
+ | 持股分級 | 說明 |
523
+ |---:|-----|
524
+ | 1 | 1-999 |
525
+ | 2 | 1,000-5,000 |
526
+ | 3 | 5,001-10,000 |
527
+ | 4 | 10,001-15,000 |
528
+ | 5 | 15,001-20,000 |
529
+ | 6 | 20,001-30,000 |
530
+ | 7 | 30,001-40,000 |
531
+ | 8 | 40,001-50,000 |
532
+ | 9 | 50,001-100,000 |
533
+ | 10 | 100,001-200,000 |
534
+ | 11 | 200,001-400,000 |
535
+ | 12 | 400,001-600,000 |
536
+ | 13 | 600,001-800,000 |
537
+ | 14 | 800,001-1,000,000 |
538
+ | 15 | 1,000,001以上 |
539
+ | 16 | 差異數調整 |
540
+ | 17 | 合 計 |
541
+
542
+ ```js
543
+ twstock.stocks.shareholders({ date: '2023-12-29', symbol: '2330' })
544
+ .then(data => console.log(data));
545
+ // Prints:
546
+ // {
547
+ // date: '2023-12-29',
548
+ // symbol: '2330',
549
+ // name: '台積電',
550
+ // shareholders: [
551
+ // {
552
+ // level: 1,
553
+ // holders: 731332,
554
+ // shares: 136341404,
555
+ // proportion: 0.52
556
+ // },
557
+ // ... more items
558
+ // ]
559
+ // }
560
+ ```
561
+
562
+ ### `.stocks.eps(options)`
563
+
564
+ 取得上市(櫃)股票在特定年度季度每股盈餘。
565
+
566
+ * `options`: {Object}
567
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
568
+ * `symbol` (optional): {string} 股票代號
569
+ * `year`: {number} 年度
570
+ * `quarter`: {number} 季度
571
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
572
+ * `exchange`: {string} 市場別
573
+ * `symbol`: {string} 股票代號
574
+ * `name`: {string} 股票名稱
575
+ * `eps`: {number} 每股盈餘
576
+ * `year`: {number} 年度
577
+ * `quarter`: {number} 季度
578
+
579
+ ```js
580
+ twstock.stocks.eps({ symbol: '2330', year: 2023, quarter: 1 })
581
+ .then(data => console.log(data));
582
+ // Prints:
583
+ // {
584
+ // exchange: 'TWSE',
585
+ // symbol: '2330',
586
+ // name: '台積電',
587
+ // eps: 7.98,
588
+ // year: 2023,
589
+ // quarter: 1
590
+ // }
591
+ ```
592
+
593
+ ### `.stocks.revenue(options)`
594
+
595
+ 取得上市(櫃)股票在特定年度月份營業收入。
596
+
597
+ * `options`: {Object}
598
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
599
+ * `symbol` (optional): {string} 股票代號
600
+ * `year`: {number} 年度
601
+ * `month`: {number} 月份
602
+ * `foreign` (optional): {boolean} 外國公司股票
603
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
604
+ * `exchange`: {string} 市場別
605
+ * `symbol`: {string} 股票代號
606
+ * `name`: {string} 股票名稱
607
+ * `revenue`: {number} 營業收入
608
+ * `year`: {number} 年度
609
+ * `month`: {number} 月份
610
+
611
+ ```js
612
+ twstock.stocks.revenue({ symbol: '2330', year: 2023, month: 1 })
613
+ .then(data => console.log(data));
614
+ // Prints:
615
+ // {
616
+ // exchange: 'TWSE',
617
+ // symbol: '2330',
618
+ // name: '台積電',
619
+ // revenue: 200050544,
620
+ // year: 2023,
621
+ // month: 1
622
+ // }
623
+ ```
624
+
625
+ ### `.stocks.dividends(options)`
626
+
627
+ 取得上市(櫃)股票在特定期間的除權除息資料。
628
+
629
+ * `options`: {Object}
630
+ * `startDate`: {string} 開始日期 (`'YYYY-MM-DD'`)
631
+ * `endDate`: {string} 結束日期 (`'YYYY-MM-DD'`)
632
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
633
+ * `symbol` (optional): {string} 股票代號
634
+ * `includeDetail` (optional): {boolean} 是否包含詳細資料 (預設: `true`)。設為 `false` 可顯著加快查詢速度,但僅適用於上市股票
635
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
636
+ * `date`: {string} 資料日期
637
+ * `exchange`: {string} 市場別
638
+ * `symbol`: {string} 股票代號
639
+ * `name`: {string} 股票名稱
640
+ * `previousClose`: {number} 除權息前收盤價
641
+ * `referencePrice`: {number} 除權息參考價
642
+ * `dividend`: {number} 權值+息值
643
+ * `dividendType`: {string} 權/息
644
+ * `limitUpPrice`: {number} 漲停價格
645
+ * `limitDownPrice`: {number} 跌停價格
646
+ * `openingReferencePrice`: {number} 開盤競價基準
647
+ * `exdividendReferencePrice`: {number} 減除股利參考價
648
+ * `cashDividend`: {number} 現金股利
649
+ * `stockDividendShares`: {number} 每仟股無償配股
650
+ * `latestFinancialReportDate`: {string} 最近一次申報資料日期 (可能為 `null`)
651
+ * `latestNetAssetValuePerShare`: {number} 最近一次申報每股(單位)淨值 (可能為 `null`)
652
+ * `latestEarningsPerShare`: {number} 最近一次申報每股(單位)盈餘 (可能為 `null`)
653
+ * **當 `includeDetail=true` 時(預設),額外包含以下欄位:**
654
+ * `capitalIncreaseRight`: {string} 增資配股除權 (可能為 `null`)
655
+ * `employeeBonusShares`: {number} 員工紅利轉增資 (可能為 `null`)
656
+ * `paidCapitalIncrease`: {number} 有償現金增資 (可能為 `null`)
657
+ * `subscriptionPrice`: {number} 每股認購金額 (可能為 `null`)
658
+ * `publicOffering`: {number} 公開承銷 (可能為 `null`)
659
+ * `employeeSubscription`: {number} 員工認購 (可能為 `null`)
660
+ * `existingShareholderSubscription`: {number} 原股東認購 (可能為 `null`)
661
+ * `sharesPerThousand`: {number} 按股東持股比例每千股認購 (可能為 `null`)
662
+
663
+ **說明**: `latestFinancialReportDate`、`latestNetAssetValuePerShare`、`latestEarningsPerShare` 欄位提供基本面分析所需的財報資訊,無需額外 API 呼叫即可取得。這些欄位對於 ETF 可能顯示為 `null`。現金增資相關欄位 (capitalIncreaseRight 至 sharesPerThousand) 在大多數情況下為 0 或 null,僅在有現金增資配股時才有實際數值。
664
+
665
+ ```js
666
+ twstock.stocks.dividends({ startDate: '2023-01-01', endDate: '2023-01-31', symbol: '0050' })
667
+ .then(data => console.log(data));
668
+ // Prints:
669
+ // [
670
+ // {
671
+ // date: '2023-01-30',
672
+ // exchange: 'TWSE',
673
+ // symbol: '0050',
674
+ // name: '元大台灣50',
675
+ // previousClose: 118.1,
676
+ // referencePrice: 115.5,
677
+ // dividend: 2.6,
678
+ // dividendType: '息',
679
+ // limitUpPrice: 127.05,
680
+ // limitDownPrice: 103.95,
681
+ // openingReferencePrice: 115.5,
682
+ // exdividendReferencePrice: 115.5,
683
+ // cashDividend: 2.6,
684
+ // stockDividendShares: 0
685
+ // }
686
+ // ]
687
+ ```
688
+
689
+ ### `.stocks.dividendsAnnouncement([options])`
690
+
691
+ 取得上市(櫃)股票的除權除息預告資料。此 API 提供未來即將發生的除權除息事件。
692
+
693
+ * `options`: {Object}
694
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃,預設為 `'TWSE'`)
695
+ * `symbol` (optional): {string} 股票代號
696
+ * `includeDetail` (optional): {boolean} 是否包含詳細資料(預設為 `false`)。**注意**: TPEx 的 API 直接返回所有欄位,此參數對 TPEx 無實際作用
697
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
698
+ * `symbol`: {string} 股票代號
699
+ * `name`: {string} 股票名稱
700
+ * `exchange`: {string} 市場別 (`'TWSE'` 或 `'TPEx'`)
701
+ * `exdividendDate`: {string} 除權除息日期
702
+ * `dividendType`: {string} 除權息類型 (`'權'`、`'息'`、`'權息'`)
703
+ * `stockDividendRatio`: {number} 無償配股率
704
+ * `cashCapitalIncreaseRatio`: {number} 現金增資配股率
705
+ * `subscriptionPrice`: {number} 現金增資認購價
706
+ * `cashDividend`: {number} 現金股利
707
+ * **當 `includeDetail=true` 時,額外包含以下欄位:**
708
+ * `stockDividendShares`: {number} 按普通股股東持股比例每千股無償配股
709
+ * `employeeBonusShares`: {number} 員工紅利轉增資
710
+ * `paidCapitalIncrease`: {number} 有償現金增資
711
+ * `publicOffering`: {number} 公開承銷
712
+ * `employeeSubscription`: {number} 員工認購
713
+ * `existingShareholderSubscription`: {number} 原股東認購
714
+ * `sharesPerThousand`: {number} 按股東持股比例每千股認購
715
+
716
+ ```js
717
+ twstock.stocks.dividendsAnnouncement({ symbol: '2330' })
718
+ .then(data => console.log(data));
719
+ // Prints:
720
+ // [
721
+ // {
722
+ // symbol: '2330',
723
+ // name: '台積電',
724
+ // exchange: 'TWSE',
725
+ // exdividendDate: '2026-01-15',
726
+ // dividendType: '息',
727
+ // stockDividendRatio: 0,
728
+ // cashCapitalIncreaseRatio: 0,
729
+ // subscriptionPrice: 0,
730
+ // cashDividend: 3.5
731
+ // }
732
+ // ]
733
+ ```
734
+
735
+ ### `.stocks.capitalReductions(options)`
736
+
737
+ 取得上市(櫃)股票在特定期間的普通股減資資料。
738
+
739
+ * `options`: {Object}
740
+ * `startDate`: {string} 開始日期 (`'YYYY-MM-DD'`)
741
+ * `endDate`: {string} 結束日期 (`'YYYY-MM-DD'`)
742
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
743
+ * `symbol` (optional): {string} 股票代號
744
+ * `includeDetail` (optional): {boolean} 是否包含詳細資料 (預設: `true`)。設為 `false` 可顯著加快查詢速度,但僅適用於上市股票
745
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
746
+ * `resumeDate`: {string} 恢復買賣日期
747
+ * `exchange`: {string} 市場別
748
+ * `symbol`: {string} 股票代號
749
+ * `name`: {string} 股票名稱
750
+ * `previousClose`: {number} 停止買賣前收盤價格
751
+ * `referencePrice`: {number} 恢復買賣參考價
752
+ * `limitUpPrice`: {number} 漲停價格
753
+ * `limitDownPrice`: {number} 跌停價格
754
+ * `openingReferencePrice`: {number} 開盤競價基準
755
+ * `exrightReferencePrice`: {number} 除權參考價
756
+ * `reason`: {string} 減資原因
757
+ * `haltDate`: {string} 停止買賣日期
758
+ * `sharesPerThousand`: {number} 每壹仟股換發新股票
759
+ * `refundPerShare`: {number} 每股退還股款
760
+ * **當 `includeDetail=true` 時(預設),額外包含以下欄位:**
761
+ * `cashDividendPerShare`: {number} 原股每股配發現金股利 (可能為 `null`)
762
+ * `paidCapitalIncrease`: {number} 減資並有償現金增資 (可能為 `null`)
763
+ * `subscriptionPrice`: {number} 每股認購金額 (可能為 `null`)
764
+ * `publicOffering`: {number} 公開承銷 (可能為 `null`)
765
+ * `employeeSubscription`: {number} 員工認購 (可能為 `null`)
766
+ * `existingShareholderSubscription`: {number} 原股東認購 (可能為 `null`)
767
+ * `sharesPerThousandSubscription`: {number} 按股東持股比例每千股認購 (可能為 `null`)
768
+
769
+ **說明**: 現金增資相關欄位 (cashDividendPerShare 至 sharesPerThousandSubscription) 在大多數情況下為 0 或 null,僅在減資同時進行現金增資時才有實際數值。
770
+
771
+ ```js
772
+ twstock.stocks.capitalReductions({ startDate: '2023-02-01', endDate: '2023-02-28', exchange: 'TWSE' })
773
+ .then(data => console.log(data));
774
+ // Prints:
775
+ // [
776
+ // {
777
+ // resumeDate: '2023-02-17',
778
+ // exchange: 'TWSE',
779
+ // symbol: '2321',
780
+ // name: '東訊',
781
+ // previousClose: 6.38,
782
+ // referencePrice: 19.93,
783
+ // limitUpPrice: 21.9,
784
+ // limitDownPrice: 17.95,
785
+ // openingReferencePrice: 19.95,
786
+ // exrightReferencePrice: null,
787
+ // reason: '彌補虧損',
788
+ // haltDate: '2023-02-09',
789
+ // sharesPerThousand: 320,
790
+ // refundPerShare: 0
791
+ // }
792
+ // ]
793
+ ```
794
+
795
+ ### `.stocks.capitalReductionAnnouncement([options])`
796
+
797
+ 取得上市(櫃)股票的普通股減資預告資料。此 API 提供已公告但尚未執行的減資計畫。
798
+
799
+ * `options`: {Object}
800
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃,預設為 `'TWSE'`)
801
+ * `symbol` (optional): {string} 股票代號
802
+ * `includeDetail` (optional): {boolean} 是否包含詳細資料(預設為 `false`)。**注意**: TPEx 的 API 直接返回所有欄位,此參數對 TPEx 無實際作用
803
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
804
+ * `symbol`: {string} 股票代號
805
+ * `name`: {string} 股票名稱
806
+ * `exchange`: {string} 市場別 (`'TWSE'` 或 `'TPEx'`)
807
+ * `haltDate`: {string} 停止買賣日期
808
+ * `resumeDate`: {string} 恢復買賣日期
809
+ * `reductionRatio`: {number} 減資換股率 (每股換發新股數)
810
+ * `reason`: {string} 減資原因 (例如: `'退還股款'`、`'彌補虧損'`)
811
+ * `refundPerShare`: {number} 每股退還股款 (元)
812
+ * `cashIncreaseRatioAfterReduction`: {number} 減資後現金增資配股率
813
+ * `subscriptionPrice`: {number} 現金增資認購價 (元)
814
+ * **當 `includeDetail=true` 時,額外包含以下欄位:**
815
+ * `sharesPerThousand`: {number} 每壹仟股換發新股票
816
+ * `cashDividendPerShare`: {number} 原股每股配發現金股利
817
+ * `paidCapitalIncrease`: {number} 減資並(有償)現金增資
818
+ * `publicOffering`: {number} 公開承銷
819
+ * `employeeSubscription`: {number} 員工認購
820
+ * `existingShareholderSubscription`: {number} 原股東認購
821
+ * `sharesPerThousandSubscription`: {number} 按股東持股比例每千股認購
822
+
823
+ ```js
824
+ twstock.stocks.capitalReductionAnnouncement({ symbol: '1414' })
825
+ .then(data => console.log(data));
826
+ // Prints:
827
+ // [
828
+ // {
829
+ // symbol: '1414',
830
+ // name: '東和',
831
+ // exchange: 'TWSE',
832
+ // haltDate: '2025-12-31',
833
+ // resumeDate: '2026-01-12',
834
+ // reductionRatio: 0.9,
835
+ // reason: '退還股款',
836
+ // refundPerShare: 1,
837
+ // cashIncreaseRatioAfterReduction: 0,
838
+ // subscriptionPrice: 0
839
+ // }
840
+ // ]
841
+ ```
842
+
843
+ ### `.stocks.splits(options)`
844
+
845
+ 取得上市(櫃)股票在特定期間的變更股票面額資料。
846
+
847
+ * `options`: {Object}
848
+ * `startDate`: {string} 開始日期 (`'YYYY-MM-DD'`)
849
+ * `endDate`: {string} 結束日期 (`'YYYY-MM-DD'`)
850
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
851
+ * `symbol` (optional): {string} 股票代號
852
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
853
+ * `resumeDate`: {string} 恢復買賣日期
854
+ * `exchange`: {string} 市場別
855
+ * `symbol`: {string} 股票代號
856
+ * `name`: {string} 股票名稱
857
+ * `previousClose`: {number} 停止買賣前收盤價格
858
+ * `referencePrice`: {number} 恢復買賣參考價
859
+ * `limitUpPrice`: {number} 漲停價格
860
+ * `limitDownPrice`: {number} 跌停價格
861
+ * `openingReferencePrice`: {number} 開盤競價基準
862
+ * `haltDate`: {string} 停止買賣日期 (可能為 `null`)
863
+
864
+ ```js
865
+ twstock.stocks.splits({ startDate: '2022-07-01', endDate: '2022-07-31', exchange: 'TWSE' })
866
+ .then(data => console.log(data));
867
+ // Prints:
868
+ // [
869
+ // {
870
+ // resumeDate: '2022-07-13',
871
+ // exchange: 'TWSE',
872
+ // symbol: '6415',
873
+ // name: '矽力-KY',
874
+ // previousClose: 2485,
875
+ // referencePrice: 621.25,
876
+ // limitUpPrice: 683,
877
+ // limitDownPrice: 560,
878
+ // openingReferencePrice: 621
879
+ // }
880
+ // ]
881
+ ```
882
+
883
+ ### `.stocks.splitAnnouncement([options])`
884
+
885
+ 取得上市(櫃)股票的變更股票面額預告資料。此 API 提供股票面額變更計畫(例如從 10 元面額改為 5 元)。
886
+
887
+ * `options`: {Object}
888
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃,預設為 `'TWSE'`)
889
+ * `symbol` (optional): {string} 股票代號
890
+ * `includeDetail` (optional): {boolean} 是否包含詳細資料(預設為 `false`)。**注意**: TPEx 的 API 直接返回所有欄位,此參數對 TPEx 無實際作用
891
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
892
+ * `symbol`: {string} 股票代號
893
+ * `name`: {string} 股票名稱
894
+ * `exchange`: {string} 市場別 (`'TWSE'` 或 `'TPEx'`)
895
+ * `haltDate`: {string} 停止買賣日期
896
+ * `resumeDate`: {string} 恢復買賣日期
897
+ * `splitRatio`: {number} 每股換發新股比例
898
+ * `oldFaceValue`: {number} 舊面額 (元)
899
+ * `newFaceValue`: {number} 新面額 (元)
900
+ * `referencePrice`: {number} 恢復買賣參考價 (TPEx 提供,TWSE 為 null)
901
+ * **當 `includeDetail=true` 時 (僅適用於 TWSE),額外包含以下欄位:**
902
+ * `sharesPerOldShare`: {number} 每股換發新股票
903
+
904
+ ```js
905
+ twstock.stocks.splitAnnouncement({ symbol: '1234' })
906
+ .then(data => console.log(data));
907
+ // Prints:
908
+ // [
909
+ // {
910
+ // symbol: '1234',
911
+ // name: '測試科技',
912
+ // exchange: 'TWSE',
913
+ // haltDate: '2026-01-15',
914
+ // resumeDate: '2026-01-25',
915
+ // splitRatio: 0.5,
916
+ // oldFaceValue: 10,
917
+ // newFaceValue: 5
918
+ // }
919
+ // ]
920
+ ```
921
+
922
+ ### `.stocks.etfSplits(options)`
923
+
924
+ 取得上市(櫃) ETF 在特定期間的分割(反分割)資料。
925
+
926
+ * `options`: {Object}
927
+ * `startDate`: {string} 開始日期 (`'YYYY-MM-DD'`)
928
+ * `endDate`: {string} 結束日期 (`'YYYY-MM-DD'`)
929
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
930
+ * `symbol` (optional): {string} ETF 代號
931
+ * `reverseSplit` (optional): {boolean} 反分割
932
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
933
+ * `resumeDate`: {string} 恢復買賣日期
934
+ * `exchange`: {string} 市場別
935
+ * `symbol`: {string} ETF 代號
936
+ * `name`: {string} ETF 名稱
937
+ * `previousClose`: {number} 停止買賣前收盤價格
938
+ * `referencePrice`: {number} 恢復買賣參考價
939
+ * `limitUpPrice`: {number} 漲停價格
940
+ * `limitDownPrice`: {number} 跌停價格
941
+ * `openingReferencePrice`: {number} 開盤競價基準
942
+
943
+ ```js
944
+ twstock.stocks.etfSplits({ startDate: '2024-12-01', endDate: '2024-12-31', exchange: 'TWSE' })
945
+ .then(data => console.log(data));
946
+ ```
947
+
948
+ ### `.stocks.etfSplitAnnouncement([options])`
949
+
950
+ 取得上市(櫃) ETF 的分割(反分割)預告資料。此 API 提供 ETF 分割或反分割計畫。
951
+
952
+ * `options`: {Object}
953
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃,預設為 `'TWSE'`)
954
+ * `symbol` (optional): {string} ETF 代號
955
+ * `splitType` (optional): {string} 分割類型 (`'分割'` 或 `'反分割'`)。若未指定則返回所有類型
956
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
957
+ * `symbol`: {string} ETF 代號
958
+ * `name`: {string} ETF 名稱
959
+ * `exchange`: {string} 市場別 (`'TWSE'` 或 `'TPEx'`)
960
+ * `haltDate`: {string} 停止買賣日期
961
+ * `resumeDate`: {string} 恢復買賣日期
962
+ * `splitType`: {string} 分割類型 (`'分割'` 或 `'反分割'`)
963
+ * `splitRatio`: {number} 分割比例 (例如: 0.5 表示 1:2 分割,2.0 表示 2:1 反分割)
964
+ * `previousNav`: {number} 分割前 ETF 淨值 (TPEx 提供,TWSE 為 null)
965
+ * `newNav`: {number} 分割後 ETF 淨值 (TPEx 提供,TWSE 為 null)
966
+ * `referencePrice`: {number} 恢復買賣參考價 (TPEx 提供,TWSE 為 null)
967
+
968
+ ```js
969
+ twstock.stocks.etfSplitAnnouncement({ symbol: '00901' })
970
+ .then(data => console.log(data));
971
+ // Prints:
972
+ // [
973
+ // {
974
+ // symbol: '00901',
975
+ // name: '永豐台灣ESG',
976
+ // exchange: 'TWSE',
977
+ // haltDate: '2026-01-20',
978
+ // resumeDate: '2026-01-28',
979
+ // splitType: '分割',
980
+ // splitRatio: 0.5
981
+ // }
982
+ // ]
983
+ ```
984
+
985
+ ### `.indices.list([options])`
986
+
987
+ 取得上市(櫃)指數列表。
988
+
989
+ * `options`: {Object}
990
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
991
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
992
+ * `symbol`: {string} 指數代號
993
+ * `name`: {string} 指數名稱
994
+ * `exchange`: {string} 市場別
995
+
996
+ ```js
997
+ twstock.indices.list({ exchange: 'TWSE' })
998
+ .then(data => console.log(data));
999
+ // Prints:
1000
+ // [
1001
+ // {
1002
+ // symbol: 'IX0001',
1003
+ // name: '發行量加權股價指數',
1004
+ // exchange: 'TWSE'
1005
+ // },
1006
+ // ... more items
1007
+ // ]
1008
+ ```
1009
+
1010
+ ### `.indices.quote(options)`
1011
+
1012
+ 取得指數行情報價。
1013
+
1014
+ * `options`: {Object}
1015
+ * `symbol`: {string} 指數代號
1016
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1017
+ * `date`: {string} 日期
1018
+ * `exchange`: {string} 市場別
1019
+ * `symbol`: {string} 指數代號
1020
+ * `name`: {string} 指數名稱
1021
+ * `open`: {number} 開盤價
1022
+ * `high`: {number} 最高價
1023
+ * `low`: {number} 最低價
1024
+ * `close`: {number} 收盤價
1025
+ * `volume`: {number} 成交金額(十萬元)
1026
+ * `lastUpdated`: {number} 最後更新時間
1027
+
1028
+ ```js
1029
+ twstock.indices.quote({ symbol: 'IX0001' })
1030
+ .then(data => console.log(data));
1031
+ // Prints:
1032
+ // {
1033
+ // date: '2023-12-29',
1034
+ // exchange: 'TWSE',
1035
+ // symbol: 'IX0001',
1036
+ // name: '發行量加權股價指數',
1037
+ // previousClose: 17910.37,
1038
+ // open: 17893.63,
1039
+ // high: 17945.7,
1040
+ // low: 17864.23,
1041
+ // close: 17930.81,
1042
+ // volume: 267204,
1043
+ // lastUpdated: 1703827980000,
1044
+ // }
1045
+ ```
1046
+
1047
+ ### `.indices.historical(options)`
1048
+
1049
+ 取得指數在特定日期的收盤行情。
1050
+
1051
+ * `options`: {Object}
1052
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1053
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1054
+ * `symbol` (optional): {string} 指數代號
1055
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
1056
+ * `date`: {string} 日期
1057
+ * `exchange`: {string} 市場別
1058
+ * `symbol`: {string} 指數代號
1059
+ * `name`: {string} 指數名稱
1060
+ * `open`: {number} 開盤價
1061
+ * `high`: {number} 最高價
1062
+ * `low`: {number} 最低價
1063
+ * `close`: {number} 收盤價
1064
+ * `change`: {number} 漲跌
1065
+
1066
+ ```js
1067
+ twstock.indices.historical({ date: '2023-01-30', symbol: 'IX0001' })
1068
+ .then(data => console.log(data));
1069
+ // Prints:
1070
+ // {
1071
+ // date: '2023-01-30',
1072
+ // exchange: 'TWSE',
1073
+ // symbol: 'IX0001',
1074
+ // name: '發行量加權股價指數',
1075
+ // open: 15291.53,
1076
+ // high: 15493.82,
1077
+ // low: 15291.53,
1078
+ // close: 15493.82,
1079
+ // change: 560.89
1080
+ // }
1081
+ ```
1082
+
1083
+ ### `.indices.trades(options)`
1084
+
1085
+ 取得指數在特定日期的成交量值。
1086
+
1087
+ * `options`: {Object}
1088
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1089
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1090
+ * `symbol` (optional): {string} 指數代號
1091
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
1092
+ * `date`: {string} 日期
1093
+ * `exchange`: {string} 市場別
1094
+ * `symbol`: {string} 指數代號
1095
+ * `name`: {string} 指數名稱
1096
+ * `tradeVolume`: {number} 成交股數
1097
+ * `tradeValue`: {number} 成交金額
1098
+ * `tradeWeight`: {number} 成交比重
1099
+
1100
+ ```js
1101
+ twstock.indices.trades({ date: '2023-01-30', symbol: 'IX0028' })
1102
+ .then(data => console.log(data));
1103
+ // Prints:
1104
+ // {
1105
+ // date: '2023-01-30',
1106
+ // exchange: 'TWSE',
1107
+ // symbol: 'IX0028',
1108
+ // name: '半導體類指數',
1109
+ // tradeVolume: 770856550,
1110
+ // tradeValue: 150024105617,
1111
+ // tradeWeight: 42.28
1112
+ // }
1113
+ ```
1114
+
1115
+ ### `.market.trades(options)`
1116
+
1117
+ 取得股票市場在特定日期的成交量值。
1118
+
1119
+ * `options`: {Object}
1120
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1121
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1122
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1123
+ * `date`: {string} 日期
1124
+ * `exchange`: {string} 市場別
1125
+ * `tradeVolume`: {number} 成交股數
1126
+ * `tradeValue`: {number} 成交金額
1127
+ * `transaction`: {number} 成交筆數
1128
+
1129
+ ```js
1130
+ twstock.market.trades({ date: '2023-01-30', exchange: 'TWSE' })
1131
+ .then(data => console.log(data));
1132
+ // Prints:
1133
+ // {
1134
+ // date: '2023-01-30',
1135
+ // exchange: 'TWSE',
1136
+ // tradeVolume: 6919326963,
1137
+ // tradeValue: 354872347181,
1138
+ // transaction: 2330770
1139
+ // }
1140
+ ```
1141
+
1142
+ ### `.market.breadth(options)`
1143
+
1144
+ 取得股票市場在特定日期的上漲與下跌家數。
1145
+
1146
+ * `options`: {Object}
1147
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1148
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1149
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1150
+ * `date`: {string} 日期
1151
+ * `exchange`: {string} 市場別
1152
+ * `up`: {number} 上漲家數
1153
+ * `limitUp`: {number} 漲停家數
1154
+ * `down`: {number} 下跌家數
1155
+ * `limitDown`: {number} 跌停家數
1156
+ * `unchanged`: {number} 平盤家數
1157
+ * `unmatched`: {number} 未成交家數
1158
+ * `notApplicable`: {number} 無比價家數
1159
+
1160
+ ```js
1161
+ twstock.market.breadth({ date: '2023-01-30', exchange: 'TWSE' })
1162
+ .then(data => console.log(data));
1163
+ // Prints:
1164
+ // {
1165
+ // date: '2023-01-30',
1166
+ // exchange: 'TWSE',
1167
+ // up: 764,
1168
+ // limitUp: 14,
1169
+ // down: 132,
1170
+ // limitDown: 0,
1171
+ // unchanged: 67,
1172
+ // unmatched: 1,
1173
+ // notApplicable: 4
1174
+ // }
1175
+ ```
1176
+
1177
+ ### `.market.institutional(options)`
1178
+
1179
+ 取得股票市場在特定日期的三大法人買賣超。
1180
+
1181
+ * `options`: {Object}
1182
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1183
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1184
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1185
+ * `date`: {string} 日期
1186
+ * `exchange`: {string} 市場別
1187
+ * `institutional`: {Object[]} 三大法人買賣金額統計,其中 `Object` 包含以下屬性:
1188
+ * `investor`: {number} 單位名稱
1189
+ * `totalBuy`: {number} 買進金額
1190
+ * `totalSell`: {number} 賣出金額
1191
+ * `difference`: {number} 買賣差額
1192
+
1193
+ ```js
1194
+ twstock.market.institutional({ date: '2023-01-30', exchange: 'TWSE' })
1195
+ .then(data => console.log(data));
1196
+ // Prints:
1197
+ // {
1198
+ // date: '2023-01-30',
1199
+ // exchange: 'TWSE',
1200
+ // institutional: [
1201
+ // {
1202
+ // investor: '自營商(自行買賣)',
1203
+ // totalBuy: 4736295878,
1204
+ // totalSell: 1917624556,
1205
+ // difference: 2818671322
1206
+ // },
1207
+ // {
1208
+ // investor: '自營商(避險)',
1209
+ // totalBuy: 11451095424,
1210
+ // totalSell: 6481456459,
1211
+ // difference: 4969638965
1212
+ // },
1213
+ // {
1214
+ // investor: '投信',
1215
+ // totalBuy: 6269087553,
1216
+ // totalSell: 3179424632,
1217
+ // difference: 3089662921
1218
+ // },
1219
+ // {
1220
+ // investor: '外資及陸資(不含外資自營商)',
1221
+ // totalBuy: 203744063563,
1222
+ // totalSell: 131488377272,
1223
+ // difference: 72255686291
1224
+ // },
1225
+ // {
1226
+ // investor: '外資自營商',
1227
+ // totalBuy: 24864200,
1228
+ // totalSell: 61653250,
1229
+ // difference: -36789050
1230
+ // },
1231
+ // {
1232
+ // investor: '三大法人',
1233
+ // totalBuy: 226200542418,
1234
+ // totalSell: 143066882919,
1235
+ // difference: 83133659499
1236
+ // }
1237
+ // ]
1238
+ // }
1239
+ ```
1240
+
1241
+ ### `.market.marginTrades(options)`
1242
+
1243
+ 取得股票市場在特定日期的信用交易統計。
1244
+
1245
+ * `options`: {Object}
1246
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1247
+ * `exchange` (optional): {string} 市場別 (`'TWSE'`:上市;`'TPEx'`:上櫃)
1248
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1249
+ * `date`: {string} 日期
1250
+ * `exchange`: {string} 市場別
1251
+ * `marginBuy`: {number} 融資買進(張)
1252
+ * `marginSell`: {number} 融資賣出(張)
1253
+ * `marginRedeem`: {number} 現金償還(張)
1254
+ * `marginBalancePrev`: {number} 前日融資餘額(張)
1255
+ * `marginBalance`: {number} 今日融資餘額(張)
1256
+ * `shortBuy`: {number} 融券買進(張)
1257
+ * `shortSell`: {number} 融券賣出(張)
1258
+ * `shortRedeem`: {number} 現券償還(張)
1259
+ * `shortBalancePrev`: {number} 前日融券餘額(張)
1260
+ * `shortBalance`: {number} 今日融券餘額(張)
1261
+ * `marginBuyValue`: {number} 融資買進(仟元)
1262
+ * `marginSellValue`: {number} 融資賣出(仟元)
1263
+ * `marginRedeemValue`: {number} 現金償還(仟元)
1264
+ * `marginBalancePrevValue`: {number} 前日融資餘額(仟元)
1265
+ * `marginBalanceValue`: {number} 今日融資餘額(仟元)
1266
+
1267
+ ```js
1268
+ twstock.market.marginTrades({ date: '2023-01-30', exchange: 'TWSE' })
1269
+ .then(data => console.log(data));
1270
+ // Prints:
1271
+ // {
1272
+ // date: '2023-01-30',
1273
+ // exchange: 'TWSE',
1274
+ // marginBuy: 264023,
1275
+ // marginSell: 282873,
1276
+ // marginRedeem: 10127,
1277
+ // marginBalancePrev: 6310599,
1278
+ // marginBalance: 6281622,
1279
+ // shortBuy: 17280,
1280
+ // shortSell: 20392,
1281
+ // shortRedeem: 2075,
1282
+ // shortBalancePrev: 542895,
1283
+ // shortBalance: 543932,
1284
+ // marginBuyValue: 8514925,
1285
+ // marginSellValue: 8830493,
1286
+ // marginRedeemValue: 300879,
1287
+ // marginBalancePrevValue: 151760467,
1288
+ // marginBalanceValue: 151144020
1289
+ // }
1290
+ ```
1291
+
1292
+ ### `.futopt.list()`
1293
+
1294
+ 取得期貨與選擇權商品(契約)列表。
1295
+
1296
+ * `options`: {Object}
1297
+ * `type`: {string} 類別 (`'F'`:期貨;`'O'`:選擇權)
1298
+ * `availableContracts`: {boolean} 列出可用契約
1299
+ * Returns: {Promise} 成功時以 {Object[]} 履行,其中 `Object` 包含以下屬性:
1300
+ * `symbol`: {string} 商品(契約)代號
1301
+ * `name`: {string} 商品(契約)名稱
1302
+ * `exchange`: {string} 市場別
1303
+ * `type`: {string} 商品(契約)類別
1304
+ * `listedDate`: {string} 上市日期
1305
+
1306
+ ```js
1307
+ twstock.futopt.list({ type: 'F' })
1308
+ .then(data => console.log(data));
1309
+ // Prints:
1310
+ // [
1311
+ // {
1312
+ // symbol: 'TXF',
1313
+ // name: '臺指期',
1314
+ // exchange: 'TAIFEX',
1315
+ // type: 'F',
1316
+ // },
1317
+ // ... more items
1318
+ // ]
1319
+ ```
1320
+
1321
+ ### `.futopt.quote(options)`
1322
+
1323
+ 取得期貨與選擇權契約行情報價。
1324
+
1325
+ * `options`: {Object}
1326
+ * `symbol`: {string} 契約代號
1327
+ * `afterhours` (optional): {boolean} 盤後交易
1328
+ * Returns: {Promise} 成功時以 {Object | Object[]} 履行,其中包含以下屬性:
1329
+ * `symbol`: {string} 契約代號
1330
+ * `name`: {string} 契約名稱
1331
+ * `status`: {string} 狀態 (`'TC'`:收盤)
1332
+ * `referencePrice`: {number} 參考價
1333
+ * `limitUpPrice`: {number} 漲停價
1334
+ * `limitDownPrice`: {number} 跌停價
1335
+ * `openPrice`: {number} 開盤價
1336
+ * `highPrice`: {number} 最高價
1337
+ * `lowPrice`: {number} 最低價
1338
+ * `lastPrice`: {number} 成交價
1339
+ * `lastSize`: {number} 單量
1340
+ * `testPrice`: {number} 試撮價
1341
+ * `testSize`: {number} 試撮量
1342
+ * `testTime`: {number} 試撮時間
1343
+ * `totalVoluem`: {number} 成交量
1344
+ * `openInterest`: {number} 未平倉量
1345
+ * `bidOrders`: {number} 委買筆數
1346
+ * `askOrders`: {number} 委賣筆數
1347
+ * `bidVolume`: {number} 委買口數
1348
+ * `askVolume`: {number} 委賣口數
1349
+ * `bidPrice`: {number[]} 最佳委買價格
1350
+ * `askPrice`: {number[]} 最佳委賣價格
1351
+ * `bidSize`: {number[]} 最佳委買數量
1352
+ * `askSize`: {number[]} 最佳委賣數量
1353
+ * `extBidPrice`: {number} 最佳衍生一檔買價
1354
+ * `extAskPrice`: {number} 最佳衍生一檔賣價
1355
+ * `extBidSize`: {number} 最佳衍生一檔買量
1356
+ * `extAskSize`: {number} 最佳衍生一檔賣量
1357
+ * `lastUpdated`: {number} 最後更新時間
1358
+
1359
+ ```js
1360
+ twstock.futopt.quote({ symbol: 'TXFA4' })
1361
+ .then(data => console.log(data));
1362
+ // Prints:
1363
+ // [
1364
+ // {
1365
+ // symbol: 'TXF',
1366
+ // name: '臺指現貨',
1367
+ // status: 'TC',
1368
+ // openPrice: 17894.83,
1369
+ // highPrice: 18014.26,
1370
+ // lowPrice: 17894.83,
1371
+ // lastPrice: 18002.62,
1372
+ // referencePrice: 17875.83,
1373
+ // limitUpPrice: '',
1374
+ // limitDownPrice: '',
1375
+ // settlementPrice: '',
1376
+ // change: 126.79,
1377
+ // changePercent: 0.71,
1378
+ // amplitude: 0.67,
1379
+ // totalVoluem: '',
1380
+ // openInterest: '',
1381
+ // bestBidPrice: '',
1382
+ // bestAskPrice: '',
1383
+ // bestBidSize: '',
1384
+ // bestAskSize: '',
1385
+ // testPrice: '',
1386
+ // testSize: '',
1387
+ // lastUpdated: 1706160795000
1388
+ // },
1389
+ // ... more items
1390
+ // ]
1391
+ ```
1392
+
1393
+ ### `.futopt.historical(options)`
1394
+
1395
+ 取得期貨與選擇權契約在特定日期的收盤行情。
1396
+
1397
+ * `options`: {Object}
1398
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1399
+ * `type` (optional): {string} 類別 (`'F'`:期貨;`'O'`:選擇權)
1400
+ * `symbol` (optional): {string} 契約代號
1401
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1402
+ * `date`: {string} 日期
1403
+ * `exchange`: {string} 市場別
1404
+ * `symbol`: {string} 契約代號
1405
+ * `contractMonth`: {string} 到期月份(週別)
1406
+ * `strikePrice`: {number} 履約價
1407
+ * `type`: {string} 買賣權
1408
+ * `open`: {number} 開盤價
1409
+ * `high`: {number} 最高價
1410
+ * `low`: {number} 最低價
1411
+ * `close`: {number} 收盤價
1412
+ * `change`: {number} 漲跌
1413
+ * `changePercent`: {number} 漲跌%
1414
+ * `volume`: {number} 成交量
1415
+ * `settlementPrice`: {number} 結算價
1416
+ * `openInterest`: {number} 未沖銷契約量
1417
+ * `bestBid`: {number} 最後最佳買價
1418
+ * `bestAsk`: {number} 最後最佳賣價
1419
+ * `historicalHigh`: {number} 歷史最高價
1420
+ * `historicalLow`: {number} 歷史最低價
1421
+ * `session`: {string} 交易時段
1422
+ * `volumeSpread`: {number} 價差對價差成交量
1423
+
1424
+ ```js
1425
+ twstock.futopt.historical({ date: '2023-01-30', symbol: 'TXF' })
1426
+ .then(data => console.log(data));
1427
+ // Prints:
1428
+ // [
1429
+ // {
1430
+ // date: '2023-01-30',
1431
+ // exchange: 'TAIFEX',
1432
+ // symbol: 'TXF',
1433
+ // contractMonth: '202301',
1434
+ // open: 15558,
1435
+ // high: 15559,
1436
+ // low: 15364,
1437
+ // close: 15451,
1438
+ // change: 526,
1439
+ // changePercent: 3.52,
1440
+ // volume: 45946,
1441
+ // settlementPrice: 0,
1442
+ // openInterest: 14509,
1443
+ // bestBid: 15450,
1444
+ // bestAsk: 15451,
1445
+ // historicalHigh: 15559,
1446
+ // historicalLow: 12631,
1447
+ // session: '一般',
1448
+ // volumeSpread: null
1449
+ // },
1450
+ // ... more items
1451
+ // ]
1452
+ ```
1453
+
1454
+ ### `.futopt.institutional(options)`
1455
+
1456
+ 取得期貨與選擇權契約在特定日期的三大法人交易口數、契約金額與未平倉餘額。
1457
+
1458
+ * `options`: {Object}
1459
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1460
+ * `symbol`: {string} 契約代號
1461
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1462
+ * `date`: {string} 日期
1463
+ * `exchange`: {string} 市場別
1464
+ * `symbol`: {string} 契約代號
1465
+ * `name`: {string} 契約名稱
1466
+ * `institutional`: {Object[]} 三大法人交易口數、契約金額與未平倉餘額,其中 `Object` 包含以下屬性:
1467
+ * `investor`: {string} 單位名稱
1468
+ * `longTradeVolume`: {number} 多方交易口數
1469
+ * `longTradeValue`: {number} 多方交易契約金額(千元)
1470
+ * `shortTradeVolume`: {number} 空方交易口數
1471
+ * `shortTradeValue`: {number} 空方交易契約金額(千元)
1472
+ * `netTradeVolume`: {number} 多空交易口數淨額
1473
+ * `netTradeValue`: {number} 多空交易契約金額淨額(千元)
1474
+ * `longOiVolume`: {number} 多方未平倉口數
1475
+ * `longOiValue`: {number} 多方未平倉契約金額(千元)
1476
+ * `shortOiVolume`: {number} 空方未平倉口數
1477
+ * `shortOiValue`: {number} 空方未平倉契約金額(千元)
1478
+ * `netOiVolume`: {number} 多空未平倉口數淨額
1479
+ * `netOiValue`: {number} 多空未平倉契約金額淨額(千元)
1480
+
1481
+ ```js
1482
+ twstock.futopt.institutional({ date: '2023-01-30', symbol: 'TXF' })
1483
+ .then(data => console.log(data));
1484
+ // Prints:
1485
+ // {
1486
+ // date: '2023-01-30',
1487
+ // exchange: 'TAIFEX',
1488
+ // symbol: 'TXF',
1489
+ // name: '臺股期貨',
1490
+ // institutional: [
1491
+ // {
1492
+ // investor: '自營商',
1493
+ // longTradeVolume: 14205,
1494
+ // longTradeValue: 43588157,
1495
+ // shortTradeVolume: 17049,
1496
+ // shortTradeValue: 52346096,
1497
+ // netTradeVolume: -2844,
1498
+ // netTradeValue: -8757939,
1499
+ // longOiVolume: 10822,
1500
+ // longOiValue: 33446397,
1501
+ // shortOiVolume: 5797,
1502
+ // shortOiValue: 17917728,
1503
+ // netOiVolume: 5025,
1504
+ // netOiValue: 15528669
1505
+ // },
1506
+ // {
1507
+ // investor: '投信',
1508
+ // longTradeVolume: 2237,
1509
+ // longTradeValue: 6907887,
1510
+ // shortTradeVolume: 449,
1511
+ // shortTradeValue: 1384268,
1512
+ // netTradeVolume: 1788,
1513
+ // netTradeValue: 5523619,
1514
+ // longOiVolume: 10112,
1515
+ // longOiValue: 31260237,
1516
+ // shortOiVolume: 15995,
1517
+ // shortOiValue: 49446943,
1518
+ // netOiVolume: -5883,
1519
+ // netOiValue: -18186706
1520
+ // },
1521
+ // {
1522
+ // investor: '外資及陸資',
1523
+ // longTradeVolume: 61232,
1524
+ // longTradeValue: 187462698,
1525
+ // shortTradeVolume: 60146,
1526
+ // shortTradeValue: 184303292,
1527
+ // netTradeVolume: 1086,
1528
+ // netTradeValue: 3159406,
1529
+ // longOiVolume: 32100,
1530
+ // longOiValue: 99233073,
1531
+ // shortOiVolume: 24001,
1532
+ // shortOiValue: 74192341,
1533
+ // netOiVolume: 8099,
1534
+ // netOiValue: 25040732
1535
+ // }
1536
+ // ]
1537
+ // }
1538
+ ```
1539
+
1540
+ ### `.futopt.largeTraders(options)`
1541
+
1542
+ 取得期貨與選擇權契約在特定日期的大額交易人未沖銷部位。
1543
+
1544
+ * `options`: {Object}
1545
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1546
+ * `symbol`: {string} 契約代號
1547
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1548
+ * `date`: {string} 日期
1549
+ * `exchange`: {string} 市場別
1550
+ * `symbol`: {string} 契約代號
1551
+ * `name`: {string} 契約名稱
1552
+ * `largeTraders`: {Object} 大額交易人未沖銷部位
1553
+ * `type`: {string} 買賣權
1554
+ * `contractMonth`: {string} 到期月份(週別) (`'666666'`:週契約;`'999999'`:所有契約)
1555
+ * `traderType`: {string} 交易人類別 (`'0'`:大額交易人;`'1'`:特定法人)
1556
+ * `topFiveLongOi`: {number} 前五大交易人買方部位數
1557
+ * `topFiveShortOi`: {number} 前五大交易人賣方部位數
1558
+ * `topTenLongOi`: {number} 前十大交易人買方部位數
1559
+ * `topTenShortOi`: {number} 前十大交易人賣方部位數
1560
+ * `marketOi`: {number} 全市場未沖銷部位數
1561
+
1562
+ ```js
1563
+ twstock.futopt.largeTraders({ date: '2023-01-30', symbol: 'TXF' })
1564
+ .then(data => console.log(data));
1565
+ // Prints:
1566
+ // {
1567
+ // date: '2023-01-30',
1568
+ // exchange: 'TAIFEX',
1569
+ // symbol: 'TXF',
1570
+ // name: '臺股期貨(TX+MTX/4)',
1571
+ // largeTraders: [
1572
+ // {
1573
+ // contractMonth: '666666',
1574
+ // traderType: '0',
1575
+ // topFiveLongOi: 33,
1576
+ // topFiveShortOi: 40,
1577
+ // topTenLongOi: 43,
1578
+ // topTenShortOi: 42,
1579
+ // marketOi: 48
1580
+ // },
1581
+ // {
1582
+ // contractMonth: '666666',
1583
+ // traderType: '1',
1584
+ // topFiveLongOi: 5,
1585
+ // topFiveShortOi: 2,
1586
+ // topTenLongOi: 5,
1587
+ // topTenShortOi: 2,
1588
+ // marketOi: 48
1589
+ // },
1590
+ // {
1591
+ // contractMonth: '202302',
1592
+ // traderType: '0',
1593
+ // topFiveLongOi: 30643,
1594
+ // topFiveShortOi: 29456,
1595
+ // topTenLongOi: 40363,
1596
+ // topTenShortOi: 36869,
1597
+ // marketOi: 68173
1598
+ // },
1599
+ // {
1600
+ // contractMonth: '202302',
1601
+ // traderType: '1',
1602
+ // topFiveLongOi: 30643,
1603
+ // topFiveShortOi: 29456,
1604
+ // topTenLongOi: 38860,
1605
+ // topTenShortOi: 34209,
1606
+ // marketOi: 68173
1607
+ // },
1608
+ // {
1609
+ // contractMonth: '999999',
1610
+ // traderType: '0',
1611
+ // topFiveLongOi: 30828,
1612
+ // topFiveShortOi: 29523,
1613
+ // topTenLongOi: 40572,
1614
+ // topTenShortOi: 37209,
1615
+ // marketOi: 72437
1616
+ // },
1617
+ // {
1618
+ // contractMonth: '999999',
1619
+ // traderType: '1',
1620
+ // topFiveLongOi: 30828,
1621
+ // topFiveShortOi: 29523,
1622
+ // topTenLongOi: 39045,
1623
+ // topTenShortOi: 34493,
1624
+ // marketOi: 72437
1625
+ // }
1626
+ // ]
1627
+ // }
1628
+ ```
1629
+
1630
+ ### `.futopt.mxfRetailPosition(options)`
1631
+
1632
+ 取得特定日期的小台散戶部位數及多空比
1633
+
1634
+ * `options`: {Object}
1635
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1636
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1637
+ * `date`: {string} 日期
1638
+ * `mxfRetailLongOi`: {number} 小台散戶多單
1639
+ * `mxfRetailShortOi`: {number} 小台散戶空單
1640
+ * `mxfRetailNetOi`: {number} 小台散戶淨部位
1641
+ * `mxfRetailLongShortRatio`: {number} 小台散戶多空比
1642
+
1643
+ ```js
1644
+ twstock.futopt.mxfRetailPosition({ date: '2023-01-30' })
1645
+ .then(data => console.log(data));
1646
+ // Prints:
1647
+ // {
1648
+ // date: '2023-01-30',
1649
+ // mxfRetailLongOi: 30126,
1650
+ // mxfRetailShortOi: 38959,
1651
+ // mxfRetailNetOi: -8833,
1652
+ // mxfRetailLongShortRatio: -0.2004
1653
+ // }
1654
+ ```
1655
+
1656
+ ### `.futopt.tmfRetailPosition(options)`
1657
+
1658
+ 取得特定日期的微台散戶部位數及多空比
1659
+
1660
+ * `options`: {Object}
1661
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1662
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1663
+ * `date`: {string} 日期
1664
+ * `tmfRetailLongOi`: {number} 微台散戶多單
1665
+ * `tmfRetailShortOi`: {number} 微台散戶空單
1666
+ * `tmfRetailNetOi`: {number} 微台散戶淨部位
1667
+ * `tmfRetailLongShortRatio`: {number} 微台散戶多空比
1668
+
1669
+ ```js
1670
+ twstock.futopt.mxfRetailPosition({ date: '2024-07-29' })
1671
+ .then(data => console.log(data));
1672
+ // Prints:
1673
+ // {
1674
+ // date: '2024-07-29',
1675
+ // tmfRetailLongOi: 3039,
1676
+ // tmfRetailShortOi: 1394,
1677
+ // tmfRetailNetOi: 1645,
1678
+ // tmfRetailLongShortRatio: 0.5406
1679
+ // }
1680
+ ```
1681
+
1682
+ ### `.futopt.txoPutCallRatio(options)`
1683
+
1684
+ 取得臺指選擇權在特定日期的 Put/Call Ratio。
1685
+
1686
+ * `options`: {Object}
1687
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1688
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1689
+ * `date`: {string} 日期
1690
+ * `txoPutVolume`: {number} 賣權成交量
1691
+ * `txoCallVolume`: {number} 買權成交量
1692
+ * `txoPutCallVolumeRatio`: {number} 買賣權成交量比率
1693
+ * `txoPutOi`: {number} 賣權未平倉量
1694
+ * `txoCallOi`: {number} 買權未平倉量
1695
+ * `txoPutCallOiRatio`: {number} 買賣權未平倉量比率
1696
+
1697
+ ```js
1698
+ twstock.futopt.txoPutCallRatio({ date: '2023-01-30' })
1699
+ .then(data => console.log(data));
1700
+ // Prints:
1701
+ // {
1702
+ // date: '2023-01-30',
1703
+ // txoPutVolume: 349525,
1704
+ // txoCallVolume: 410532,
1705
+ // txoPutCallVolumeRatio: 0.8514,
1706
+ // txoPutOi: 89495,
1707
+ // txoCallOi: 87502,
1708
+ // txoPutCallOiRatio: 1.0228
1709
+ // }
1710
+ ```
1711
+
1712
+ ### `.futopt.exchangeRates(options)`
1713
+
1714
+ 取得特定日期的外幣參考匯率。
1715
+
1716
+ * `options`: {Object}
1717
+ * `date`: {string} 日期 (`'YYYY-MM-DD'`)
1718
+ * Returns: {Promise} 成功時以 {Object} 履行,包含以下屬性:
1719
+ * `date`: {string} 日期
1720
+ * `usdtwd`: {number} 美元/新台幣
1721
+ * `cnytwd`: {number} 人民幣/新台幣
1722
+ * `eurusd`: {number} 歐元/美元
1723
+ * `usdjpy`: {number} 美元/日幣
1724
+ * `gbpusd`: {number} 英鎊/美元
1725
+ * `audusd`: {number} 澳幣/美元
1726
+ * `usdhkd`: {number} 美元/港幣
1727
+ * `usdcny`: {number} 美元/人民幣
1728
+ * `usdzar`: {number} 美元/南非幣
1729
+ * `nzdusd`: {number} 紐幣/美元
1730
+
1731
+ ```js
1732
+ twstock.futopt.exchangeRates({ date: '2023-01-30' })
1733
+ .then(data => console.log(data));
1734
+ // Prints:
1735
+ // {
1736
+ // date: '2023-01-30',
1737
+ // usdtwd: 30.137,
1738
+ // cnytwd: 4.464224,
1739
+ // eurusd: 1.08835,
1740
+ // usdjpy: 129.925,
1741
+ // gbpusd: 1.23865,
1742
+ // audusd: 0.70825,
1743
+ // usdhkd: 7.83585,
1744
+ // usdcny: 6.7508,
1745
+ // usdzar: 17.2262,
1746
+ // nzdusd: 0.64805
1747
+ // }
1748
+ ```
1749
+
1750
+ ## Manual Testing
1751
+
1752
+ 專案包含三個手動測試檔案,用於測試不同交易所的 Announcement APIs:
1753
+
1754
+ ### test-twse.js
1755
+
1756
+ 測試 TWSE (上市) Announcement APIs,包含:
1757
+ - 除權除息預告 (快速 & 完整模式)
1758
+ - 減資預告 (快速 & 完整模式)
1759
+ - 變更面額預告 (快速 & 完整模式)
1760
+ - ETF 分割反分割預告
1761
+ - includeDetail 效能對比測試
1762
+
1763
+ 執行方式:
1764
+
1765
+ ```sh
1766
+ npm run build && node test-twse.js
1767
+ ```
1768
+
1769
+ ### test-tpex.js
1770
+
1771
+ 測試 TPEx (上櫃) Announcement APIs,包含:
1772
+ - 除權除息預告
1773
+ - 減資預告
1774
+ - 變更面額預告
1775
+ - ETF 分割預告
1776
+ - ETF 反分割預告
1777
+
1778
+ 執行方式:
1779
+
1780
+ ```sh
1781
+ npm run build && node test-tpex.js
1782
+ ```
1783
+
1784
+ **注意**:TPEx APIs 資料已完整,無 includeDetail 參數效能差異。
1785
+
1786
+ ### test-both.js
1787
+
1788
+ TWSE & TPEx 對比測試,同時測試兩個交易所並比較結果:
1789
+ - 除權除息預告對比
1790
+ - 減資預告對比
1791
+ - 變更面額預告對比
1792
+ - ETF 分割預告對比
1793
+ - 指定股票對比測試
1794
+
1795
+ 執行方式:
1796
+
1797
+ ```sh
1798
+ npm run build && node test-both.js
1799
+ ```
1800
+
1801
+ 輸出 JSON 檔案格式:
1802
+
1803
+ ```json
1804
+ {
1805
+ "twse": [...],
1806
+ "tpex": [...],
1807
+ "summary": {
1808
+ "twseCount": 10,
1809
+ "tpexCount": 5,
1810
+ "total": 15
1811
+ }
1812
+ }
1813
+ ```
1814
+
1815
+ **提示**:所有測試檔預設只啟用一個測試,其他測試已註解。可依需求取消註解執行特定測試。
1816
+
1817
+ ## Disclaimer
1818
+
1819
+ - 本程式所取得之資料來源包括 [臺灣證券交易所](https://www.twse.com.tw)、[證券櫃檯買賣中心](https://www.tpex.org.tw)、[臺灣期貨交易所](https://www.taifex.com.tw)、[臺灣集中保管結算所](https://www.tdcc.com.tw)、[公開資訊觀測站](https://mops.twse.com.tw)、[臺灣證券交易所-基本市況報導網站](https://mis.twse.com.tw)、[臺灣期貨交易所行情資訊網](https://mis.taifex.com.tw)。使用者應遵守各資訊來源提供者所定之資訊使用相關規範及智慧財產權相關法令。
1820
+ - 本程式僅供使用公開數據進行研究之目的,嚴禁任何組織或個人利用該技術進行智慧財產盜竊、破壞網站功能或造成其他損害。對於任何違法行為,由該組織或個人自行承擔責任,作者不負擔任何法律及連帶責任。
1821
+ - 透過本程式取得之資料僅供參考,若因任何資料之不正確或疏漏所衍生之損害或損失,使用者需自行負責。對於資料內容錯誤、更新延誤或傳輸中斷,本程式不負任何責任。
1822
+ - 使用者在使用本程式所提供之資訊時,應謹慎評估並自行承擔風險,作者保留隨時修改或更新免責聲明之權利。
1823
+
1824
+ ## Changelog
1825
+
1826
+ [Changelog](./CHANGELOG.md)
1827
+
1828
+ ## License
1829
+
1830
+ [MIT](LICENSE)
1831
+
1832
+ [npm-image]: https://img.shields.io/npm/v/node-twstock.svg
1833
+ [npm-url]: https://npmjs.com/package/node-twstock
1834
+ [action-image]: https://img.shields.io/github/actions/workflow/status/chunkai1312/node-twstock/node.js.yml?branch=main
1835
+ [action-url]: https://github.com/chunkai1312/node-twstock/actions/workflows/node.js.yml
1836
+ [codecov-image]: https://img.shields.io/codecov/c/github/chunkai1312/node-twstock.svg
1837
+ [codecov-url]: https://codecov.io/gh/chunkai1312/node-twstock