# Nova API > Nova API ## FugleSDK ### SDK 下載 ##### SDK 檔案載點[​](#sdk-檔案載點 "Direct link to SDK 檔案載點") ###### Python ( 支援 3.8 ~ 3.12版本 )[​](#python--支援-38--312版本- "Direct link to Python ( 支援 3.8 ~ 3.12版本 )") * Windows 64 位元 [下載](https://ml-fugle-api.masterlink.com.tw/FugleSDK/sdk/taishin_sdk-1.0.2-cp37-abi3-win_amd64.whl) * MacOs * Arm 64 位元 [下載](https://ml-fugle-api.masterlink.com.tw/FugleSDK/sdk/taishin_sdk-1.0.2-cp37-abi3-macosx_11_0_arm64.whl) * X86 64 位元 [下載](https://ml-fugle-api.masterlink.com.tw/FugleSDK/sdk/taishin_sdk-1.0.2-cp37-abi3-macosx_10_12_x86_64.whl) * Linux 64 位元 [下載](https://ml-fugle-api.masterlink.com.tw/FugleSDK/sdk/taishin_sdk-1.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl) ###### JavaScript ( 支援 Node.js 16 以上版本 )[​](#javascript--支援-nodejs-16-以上版本- "Direct link to JavaScript ( 支援 Node.js 16 以上版本 )") * taishinsdk.tgz [下載](https://ml-fugle-api.masterlink.com.tw/FugleSDK/sdk/taishin-sdk-1.0.2.tgz) --- ### Corporate Actions Capital Changes 取得上市櫃股票及 ETF 之資本變動資料(面額變更、減資、分割) ```text GET /corporate-actions/capital-changes/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ------------------------------------------------------------ | | `start_date` | string | 開始日期(格式:`yyyy-MM-dd`) | | `end_date` | string | 結束日期(格式:`yyyy-MM-dd`)可輸入未來日期取得未來預告資訊 | | `sort` | string | 排序方式(`asc`、`desc`) | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------- | | `data`\* | object\[] | 資本變動資料 | | `data.symbol` | string | 股票代號 | | `data.name` | string | 股票名稱 | | `data.actionType` | string | 事件類型:`etf_split_or_merge` ETF 分割或反分割、`par_value_change` 股票面額變更 、`capital_reduction` 減資 | | `data.effectiveDate` | string | 恢復買賣日期 (YYYY-MM-DD) | | `data.adjustmentFactor` | number | 調整係數 | | `data.haltDate` | string | 停止買賣日期 (YYYY-MM-DD) | | `data.resumeDate` | string | 恢復買賣日期 (YYYY-MM-DD) | | `data.raw` | object | 原始資料 | | `data.raw.exchangeRatio` | number | 換股比例 (面額變更、減資時才有值) | | `data.raw.parValueBefore` | number | 變更前面額 (面額變更時才有值) | | `data.raw.parValueAfter` | number | 變更後面額 (面額變更時才有值) | | `data.raw.lastClosePrice` | number | 停止買賣前收盤價 | | `data.raw.referencePrice` | number | 恢復買賣參考價 | | `data.raw.limitUpPrice` | number | 漲停價格 | | `data.raw.limitDownPrice` | number | 跌停價格 | | `data.raw.openingReferencePrice` | number | 開盤競價基準 | | `data.raw.splitType` | string | 分割類型:`分割`、`反分割` | | `data.raw.reductionReason` | string | 減資原因 (減資時才有值) | | `data.raw.refundPerShare` | number | 每股退還股款 (元) (減資時才有值) | | `data.raw.rightsOfferingRatio` | number | 減資後現金增資配股率 (減資時才有值) | | `data.raw.rightsOfferingPrice` | number | 現金增資認購價 (元) (減資時才有值) | | `data.raw.exRightsReferencePrice` | number | 除權參考價 (減資時才有值) | #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.corporate_actions.capital_changes(**{"start_date": "2025-12-06", "end_date": "2026-01-08"}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.corporateActions.capitalChanges({ start_date: '2025-12-06', end_date: '2026-01-08' }) .then(data => console.log(data)); ``` Response Body: ```json { "start_date": "2025-01-01", "end_date": "2026-01-09", "sort": "desc", "data": [ { "symbol": "4530", "name": "宏易", "actionType": "capital_reduction", "resumeDate": "2025-12-29", "haltDate": "2025-12-18", "exchange": "TPEx", "raw": { "exrightReferencePrice": 0, "limitDownPrice": 28.2, "limitUpPrice": 34.45, "openingReferencePrice": 31.3, "previousClose": 12.3, "reason": "彌補虧損", "referencePrice": 31.32, "refundPerShare": 0, "sharesPerThousand": 392.72795 } }, { "symbol": "3593", "name": "力銘", "actionType": "capital_reduction", "resumeDate": "2025-12-22", "haltDate": "2025-12-11", "exchange": "TWSE", "raw": { "limitDownPrice": 12.15, "limitUpPrice": 14.85, "openingReferencePrice": 13.5, "previousClose": 8.1, "reason": "彌補虧損", "referencePrice": 13.5, "refundPerShare": 0, "sharesPerThousand": 599.9999936 } }, { "symbol": "00715L", "name": "期街口布蘭特正2", "actionType": "etf_split_or_merge", "resumeDate": "2025-12-10", "haltDate": "2025-12-03", "exchange": "TWSE", "raw": { "limitDownPrice": 0.01, "limitUpPrice": 9999.95, "openingReferencePrice": 20.86, "previousClose": 10.43, "referencePrice": 20.86, "splitRatio": 0.5, "splitType": "反分割" } }, { "symbol": "8103", "name": "瀚荃", "actionType": "capital_reduction", "resumeDate": "2025-12-08", "haltDate": "2025-11-27", "exchange": "TWSE", "raw": { "limitDownPrice": 77.5, "limitUpPrice": 94.7, "openingReferencePrice": 86.1, "previousClose": 74.7, "reason": "退還股款", "referencePrice": 86.11, "refundPerShare": 1.5, "sharesPerThousand": 850 } }, { "symbol": "0052", "name": "富邦科技", "actionType": "etf_split_or_merge", "resumeDate": "2025-11-26", "exchange": "TWSE", "raw": { "limitDownPrice": 31.54, "limitUpPrice": 38.54, "openingReferencePrice": 35.04, "previousClose": 245.3, "referencePrice": 35.04, "splitType": "分割" } }, { "symbol": "1808", "name": "潤隆", "actionType": "capital_reduction", "resumeDate": "2025-11-24", "haltDate": "2025-11-13", "exchange": "TWSE", "raw": { "limitDownPrice": 33.45, "limitUpPrice": 40.85, "openingReferencePrice": 37.15, "previousClose": 34.45, "reason": "退還股款", "referencePrice": 37.16, "refundPerShare": 1, "sharesPerThousand": 900 } }, { "symbol": "6465", "name": "威潤", "actionType": "capital_reduction", "resumeDate": "2025-11-24", "haltDate": "2025-11-13", "exchange": "TPEx", "raw": { "exrightReferencePrice": 0, "limitDownPrice": 15.55, "limitUpPrice": 18.95, "openingReferencePrice": 17.25, "previousClose": 15.65, "reason": "彌補虧損", "referencePrice": 17.25, "refundPerShare": 0, "sharesPerThousand": 907.01186 } }, { "symbol": "9927", "name": "泰銘", "actionType": "capital_reduction", "resumeDate": "2025-11-24", "haltDate": "2025-11-13", "exchange": "TWSE", "raw": { "limitDownPrice": 62.2, "limitUpPrice": 76, "openingReferencePrice": 69.1, "previousClose": 52.4, "reason": "退還股款", "referencePrice": 69.11, "refundPerShare": 2.82805, "sharesPerThousand": 717.194904 } }, { "symbol": "8422", "name": "可寧衛", "actionType": "par_value_change", "resumeDate": "2025-11-17", "haltDate": "2025-11-06", "exchange": "TWSE", "raw": { "limitDownPrice": 22.5, "limitUpPrice": 27.5, "openingReferencePrice": 25, "previousClose": 250, "referencePrice": 25 } }, { "symbol": "5301", "name": "寶得利", "actionType": "capital_reduction", "resumeDate": "2025-11-12", "haltDate": "2025-11-05", "exchange": "TPEx", "raw": { "exrightReferencePrice": 0, "limitDownPrice": 12.55, "limitUpPrice": 15.25, "openingReferencePrice": 13.9, "previousClose": 6.41, "reason": "彌補虧損", "referencePrice": 13.89, "refundPerShare": 0, "sharesPerThousand": 461.57 } }, ... ] } ``` --- ### Corporate Actions Dividends 取得 上市櫃除權息資料(依日期查詢) ```text GET /corporate-actions/dividends/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ------------------------------------------------------------ | | `start_date` | string | 開始日期(格式:`yyyy-MM-dd`) | | `end_date` | string | 結束日期(格式:`yyyy-MM-dd`)可輸入未來日期取得未來預告資訊 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------------------- | --------- | -------------------------- | | `data`\* | object\[] | 除權息資料 | | `data.date`\* | string | 除權息日期 | | `data.exchange` | string | 交易所 | | `data.symbol` | string | 股票代號 | | `data.name` | string | 股票名稱 | | `data.previousClose` | number | 除權息前收盤價 | | `data.referencePrice` | number | 除權息參考價 | | `data.dividend` | number | 除權息總金額 (權值 + 息值) | | `data.dividendType` | string | 除權息類別 | | `data.limitUpPrice` | number | 除權後漲停價 | | `data.limitDownPrice` | number | 除權後跌停價 | | `data.openingReferencePrice` | number | 開盤競價參考價 | | `data.exdividendReferencePrice` | number | 減除股利參考價 | | `data.cashDividend` | number | 現金除息 | | `data.stockDividendShares` | number | 每千股無償配股 | #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.corporate_actions.dividends(**{"start_date": "2025-08-26", "end_date": "2026-01-08"}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.corporateActions.dividends({ start_date: '2025-08-26', end_date: '2026-01-08' }) .then(data => console.log(data)); ``` Response Body: ```json { "data": [ { // 宣告未來的除權息資料不會帶入價格 "date": "2026-01-08", "exchange": "TWSE", "symbol": "2247", "name": "汎德永業", "previousClose": null, "referencePrice": null, "dividend": 6.5, "dividendType": "息", "limitUpPrice": null, "limitDownPrice": null, "openingReferencePrice": null, "exdividendReferencePrice": null, "cashDividend": 6.5, "stockDividendShares": null }, { // 已發生的除權息資料會帶入價格 (僅有息) "date": "2026-01-06", "exchange": "TWSE", "symbol": "00946", "name": "群益科技高息成長", "previousClose": 9.6, "referencePrice": 9.54, "dividend": 0.058, "dividendType": "息", "limitUpPrice": 10.49, "limitDownPrice": 8.59, "openingReferencePrice": 9.54, "exdividendReferencePrice": 9.54, "cashDividend": 0.058, "stockDividendShares": 0 }, { // 增資 ( 前日開盤會等於減除股利參考價或 stockDividendShares = 0 ) "date": "2026-01-06", "exchange": "TWSE", "symbol": "2442", "name": "新美齊", "previousClose": 24.8, "referencePrice": 24.12, "dividend": 0.671598, "dividendType": "權", "limitUpPrice": 27.25, "limitDownPrice": 21.75, "openingReferencePrice": 24.8, "exdividendReferencePrice": 24.8, "cashDividend": 0, "stockDividendShares": 0 }, { // 已發生的除權息資料會帶入價格 (僅有權) "date": "2025-08-26", "exchange": "TPEx", "symbol": "6752", "name": "叡揚", "previousClose": 158.5, "referencePrice": 150.95, "dividend": 7.548635, "dividendType": "權", "limitUpPrice": 166, "limitDownPrice": 136, "openingReferencePrice": 151, "exdividendReferencePrice": 150.95, "cashDividend": 0, "stockDividendShares": 50.00706711 }, { // 已發生的除權息資料會帶入價格 (同時包含權息) "date": "2025-08-26", "exchange": "TPEx", "symbol": "4554", "name": "橙的", "previousClose": 36.95, "referencePrice": 32.39, "dividend": 4.560619, "dividendType": "權息", "limitUpPrice": 35.6, "limitDownPrice": 29.2, "openingReferencePrice": 32.4, "exdividendReferencePrice": 32.39, "cashDividend": 0.35, "stockDividendShares": 129.99998584 } ] } ``` --- ### Corporate Actions Listing Applicants 取得 申請上市櫃公司資料 ```text GET /corporate-actions/listing-applicants/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ------------------------------------------------------------ | | `start_date` | string | 開始日期(格式:`yyyy-MM-dd`) | | `end_date` | string | 結束日期(格式:`yyyy-MM-dd`)可輸入未來日期取得未來預告資訊 | | `sort` | string | 排序方式(`asc`、`desc`) | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------------- | ------ | ---------------------------------------- | | `symbol` | string | 公司代號 | | `name` | string | 公司簡稱 | | `exchange` | string | 申請類別:`TWSE`(上市)、`TPEx`(上櫃) | | `applicationDate` | string | 申請日期 | | `chairman` | string | 董事長 | | `capitalAtApplication` | number | 申請時股本(仟元) | | `reviewCommitteeDate` | string | 上市審議委員審議日 | | `boardApprovalDate` | string | 交易所董事會通過日 | | `contractFilingDate` | string | 主管機關核准日期 | | `listedDate` | string | 股票上市、櫃買賣日期 | | `underwriter` | string | 承銷商 | | `underwritingPrice` | number | 承銷價 | | `remarks` | string | 備註 | #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.corporate_actions.listing_applicants(**{"start_date": "2025-01-07", "end_date": "2026-01-07"}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.corporateActions.listingApplicants({ start_date: '2025-01-07', end_date: '2026-01-07' }) .then(data => console.log(data)); ``` Response Body: ```json { "start_date": "2025-01-07", "end_date": "2026-01-07", "sort": "desc", "data": [ ... { "symbol": "7762", "name": "吉晟生", "exchange": "TWSE", "applicationDate": "2025-09-24", "chairman": "楊朝堂", "capitalAtApplication": 572328, "reviewCommitteeDate": null, "boardApprovalDate": null, "contractFilingDate": null, "listedDate": null, "underwriter": "宏遠", "underwritingPrice": null, "remarks": "創新板,114-10-31撤件" }, { "symbol": "6961", "name": "旅天下", "exchange": "TPEx", "applicationDate": "2025-09-17", "chairman": "李嘉寅", "capitalAtApplication": 236340000, "reviewCommitteeDate": "2025-11-06", "boardApprovalDate": "2025-11-21", "contractApprovalDate": "2025-11-25", "listedDate": null, "underwriter": "福邦", "underwritingPrice": null, "remarks": "" }, { "symbol": "4590", "name": "富田", "exchange": "TWSE", "applicationDate": "2025-09-15", "chairman": "張金鋒", "capitalAtApplication": 511941, "reviewCommitteeDate": "2025-10-23", "boardApprovalDate": "2025-11-18", "contractFilingDate": "2025-11-26", "listedDate": null, "underwriter": "中信", "underwritingPrice": null, "remarks": "創新板" }, { "symbol": "6725", "name": "矽科宏晟", "exchange": "TPEx", "applicationDate": "2025-09-11", "chairman": "郭錦松", "capitalAtApplication": 330000000, "reviewCommitteeDate": "2025-10-20", "boardApprovalDate": "2025-10-30", "contractApprovalDate": "2025-11-04", "listedDate": "2025-12-30", "underwriter": "台新", "underwritingPrice": 188, "remarks": "" } ] } ``` --- ### 開始使用 台新行情 Web API 提供開發者友善的 API 服務。您可以查詢台股的日內行情、行情快照與歷史行情等數據。 #### 速率限制[​](#速率限制 "Direct link to 速率限制") 如果您 API 請求超過了限制,將收到帶有狀態碼 `429` 的回應。 ( 限制細節請參考 [速率限制](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/rate-limit.md) ) #### 功能列表[​](#功能列表 "Direct link to 功能列表") 功能列表依資料類型可分為 **盤中行情(intraday)**、**行情快照(snapshot)**、**歷史行情(historical)**。台新行情 Web API 提供的功能如下: * `/intraday/tickers` - [股票或指數列表(依條件查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/tickers.md) * `/intraday/ticker/{symbol}` - [股票基本資料(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/ticker.md) * `/intraday/quote/{symbol}` - [股票即時報價(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/quote.md) * `/intraday/candles/{symbol}` - [股票價格K線(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/candles.md) * `/intraday/trades/{symbol}` - [股票成交明細(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/trades.md) * `/intraday/volumes/{symbol}` - [股票分價量表(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/intraday/volumes.md) * `/snapshot/quotes/{market}` - [股票行情快照(依市場別)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/snapshot/quotes.md) * `/snapshot/movers/{market}` - [股票漲跌幅排行(依市場別)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/snapshot/movers.md) * `/snapshot/actives/{market}` - [股票成交量值排行(依市場別)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/snapshot/actives.md) * `/historical/candles/{symbol}` - [取得 1 年內歷史股價(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/historical/candles.md) * `/historical/stats/{symbol}` - [取得近 52 週股價數據(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/historical/stats.md) #### 使用 SDK[​](#使用-sdk "Direct link to 使用 SDK") 台新行情 Web API 提供 Python、Node.js SDK。您可以透過以下方式存取 API: * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient const stock = client.stock; ``` --- ### Historical Candles 取得 1 年內的上市櫃歷史股價(依代碼查詢),個股資料區間最遠可回溯至 2010 年,指數部分最遠可回溯至 2015 年! ```text historical/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from` | string | 開始日期(格式:`yyyy-MM-dd`) | | `to` | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe` | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `adjusted` | string | 還原股價啟用,可選 `true`、`false` | | `fields` | string | 欄位,可選:`open,high,low,close,volume,turnover,change` | | `sort` | string | 時間排序,預設為 `desc` 降冪;可選 `asc` 升冪 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近五日資料,並且無法選擇 turnover 與 change 的欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock print(reststock.historical.candles(**{"symbol": "0050", "from": "2023-02-06", "to": "2023-02-08"})) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.historical.candles({ symbol: '0050', from: '2023-02-06', to: '2023-02-08', fields: 'open,high,low,close,volume,change' }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "0050", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "data": [ { "date": "2023-02-08", "open": 120.1, "high": 120.95, "low": 120, "close": 120.85, "volume": 9239321, "change": 1.85 }, { "date": "2023-02-07", "open": 119.1, "high": 119.25, "low": 118.55, "close": 119, "volume": 8787291, "change": -0.25 }, { "date": "2023-02-06", "open": 120.1, "high": 120.1, "low": 119.25, "close": 119.25, "volume": 14297030, "change": -1.75 } ] } ``` #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | ------ | ----------- | | `date`\* | string | 日期 | | `type`\* | string | 證券類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `timeframe*` | string | K線週期 | | `data` | Candle | K線資料 | info '\*' 表示必揭示欄位。 --- ### Historical Stats 取得近 52 週股價數據(依代碼查詢) ```text historical/stats/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ----------- | | `symbol`\* | string | 股票代碼 | #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.historical.stats(symbol = "0050") ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.historical.stats({ symbol: '0050' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-02-09", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "0050", "name": "元大台灣50", "openPrice": 120.5, "highPrice": 121, "lowPrice": 120.3, "closePrice": 120.9, "change": 0.05, "changePercent": 0.04, "tradeVolume": 5032245, "tradeValue": 607543546, "previousClose": 120.85000000000001, "week52High": 145.05, "week52Low": 96.5 } ``` #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ------------------ | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market`\* | string | 市場別 | | `symbol`\* | string | 股票代碼 | | `name`\* | string | 股票簡稱 | | `openPrice`\* | number | 最後交易日開盤價 | | `highPrice`\* | number | 最後交易日最高價 | | `lowPrice`\* | number | 最後交易日最低價 | | `closePrice`\* | number | 最後交易日收盤價 | | `change`\* | number | 最後交易日漲跌 | | `changePercent`\* | number | 最後交易日漲跌幅 | | `tradeVolume`\* | number | 最後交易日成交量 | | `tradeValue`\* | number | 最後交易日成交金額 | | `previousClose`\* | number | 前一交易日收盤價 | | `week52High`\* | number | 近 52 週高點 | | `week52Low`\* | number | 近 52 週低點 | info '\*' 表示必揭示欄位。 --- ### Intraday Candles 股票價格K線(依代碼查詢) ```text intraday/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | --------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `type` | string | Ticker 類型,可選 `oddlot` 盤中零股 | | `timeframe` | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K | | `sort` | string | 時間排序,預設為 `asc` 升冪 ;可選 `desc` 降冪 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | --------- | -------------------------------------------------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `timeframe`\* | number | K線週期 | | `data`\* | object\[] | K線資料 | | >>`open` | number | K線開盤價 | | >>`high` | number | K線最高價 | | >>`low` | number | K線最低價 | | >>`close` | number | K線收盤價 | | >>`volume` | number | K線成交量(整股:成交張數;興櫃股票及盤中零股:成交股數;指數:成交金額) | | >>`average` | number | 成交均價 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.candles(symbol='2330') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday.candles({ symbol: '2330' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "data": [ { "date": "2023-05-29T09:00:00.000+08:00", "open": 574, "high": 574, "low": 572, "close": 572, "volume": 8450, "average": 573.82 }, { "date": "2023-05-29T09:01:00.000+08:00", "open": 572, "high": 573, "low": 571, "close": 571, "volume": 594, "average": 573.68 }, { "date": "2023-05-29T09:02:00.000+08:00", "open": 572, "high": 572, "low": 569, "close": 570, "volume": 1372, "average": 573.26 }, ...... ] } ``` --- ### Intraday Quote 股票即時報價(依代碼查詢) ```text intraday/quote/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------- | | `symbol`\* | string | 股票代碼 | | `type` | string | 類型,可選 `oddlot` 盤中零股 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | ----------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market`\* | string | 市場別 | | `symbol`\* | string | 股票代碼 | | `name`\* | string | 股票簡稱 | | `referencePrice` | number | 今日參考價 | | `previousClose` | number | 昨日收盤價 | | `openPrice` | number | 開盤價 | | `openTime` | number | 開盤價成交時間 | | `highPrice` | number | 最高價 | | `highTime` | number | 最高價成交時間 | | `lowPrice` | number | 最低價 | | `lowTime` | number | 最低價成交時間 | | `closePrice` | number | 收盤價(最後成交價) | | `closeTime` | number | 收盤價(最後成交價)成交時間 | | `lastPrice` | number | 最後一筆成交價(含試撮) | | `lastSize` | number | 最後一筆成交數量(含試撮) | | `avgPrice` | number | 當日成交均價 | | `change` | number | 最後成交價漲跌 | | `changePercent` | number | 最後成交價漲跌幅 | | `amplitude` | number | 當日振幅 | | `bids` | object\[] | 最佳五檔委買 | | >> `price` | number | 最佳五檔委買價格 | | >> `size` | number | 最佳五檔委買數量 | | `asks` | object\[] | 最佳五檔委賣 | | >> `price` | number | 最佳五檔委賣價格 | | >> `size` | number | 最佳五檔委賣數量 | | `total` | object | 統計資訊 | | >> `tradeValue` | number | 累計成交金額 | | >> `tradeVolume` | number | 累計成交量 | | >> `tradeVolumeAtBid` | number | 累計內盤成交量 | | >> `tradeVolumeAtAsk` | number | 累計外盤成交量 | | >> `transaction` | number | 累計成交筆數 | | >> `time` | number | 統計時間 | | `lastTrade` | object | 最後一筆成交資訊 | | >> `bid` | number | 最後一筆成交買價 | | >> `ask` | number | 最後一筆成交賣價 | | >> `price` | number | 最後一筆成交價格 | | >> `size` | number | 最後一筆成交數量 | | >> `time` | number | 最後一筆成交時間 | | `lastTrial` | object | 最後一筆試撮資訊 | | >> `bid` | number | 最後一筆試撮買價 | | >> `ask` | number | 最後一筆試撮賣價 | | >> `price` | number | 最後一筆試撮價格 | | >> `size` | number | 最後一筆試撮數量 | | >> `time` | number | 最後一筆試撮時間 | | `opHaltStatus` | object | 暫停交易 | | >> `isHalted` | boolean | 暫停交易:`true`;恢復交易:`false` | | >> `time` | number | 暫停交易時間/恢復交易時間 | | `isLimitDownPrice` | boolean | 最後成交價為跌停價:`true` | | `isLimitUpPrice` | boolean | 最後成交價為漲停價:`true` | | `isLimitDownBid` | boolean | 最佳一檔委買跌停價:`true` | | `isLimitUpBid` | boolean | 最佳一檔委買漲停價:`true` | | `isLimitDownAsk` | boolean | 最佳一檔委賣跌停價:`true` | | `isLimitUpAsk` | boolean | 最佳一檔委賣漲停價:`true` | | `isLimitDownHalt` | boolean | 暫緩撮合且瞬間趨跌:`true` | | `isLimitUpHalt` | boolean | 暫緩撮合且瞬間趨漲:`true` | | `isTrial` | boolean | 試撮階段:`true` | | `isDelayedOpen` | boolean | 延後開盤信號:`true` | | `isDelayedClose` | boolean | 延後收盤信號:`true` | | `isContinuous` | boolean | 最後成交為逐筆交易:`true` | | `isOpen` | boolean | 開盤信號:`true` | | `isClose` | boolean | 收盤信號:`true` | | `lastUpdated` | number | 最後更新時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.quote(symbol='2330') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday.quote({ symbol: '2330' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "name": "台積電", "referencePrice": 566, "previousClose": 566, "openPrice": 574, "openTime": 1685322000049353, "highPrice": 574, "highTime": 1685322000049353, "lowPrice": 564, "lowTime": 1685327142152580, "closePrice": 568, "closeTime": 1685338200000000, "avgPrice": 568.77, "change": 2, "changePercent": 0.35, "amplitude": 1.77, "lastPrice": 568, "lastSize": 4778, "bids": [ { "price": 567, "size": 87 }, { "price": 566, "size": 2454 }, { "price": 565, "size": 611 }, { "price": 564, "size": 609 }, { "price": 563, "size": 636 } ], "asks": [ { "price": 568, "size": 800 }, { "price": 569, "size": 806 }, { "price": 570, "size": 3643 }, { "price": 571, "size": 1041 }, { "price": 572, "size": 2052 } ], "total": { "tradeValue": 31019803000, "tradeVolume": 54538, "tradeVolumeAtBid": 19853, "tradeVolumeAtAsk": 27900, "transaction": 9530, "time": 1685338200000000 }, "lastTrade": { "bid": 567, "ask": 568, "price": 568, "size": 4778, "time": 1685338200000000, "serial": 6652422 }, "lastTrial": { "bid": 567, "ask": 568, "price": 568, "size": 4772, "time": 1685338196400347, "serial": 6651941 }, "isClose": true, "serial": 6652422, "lastUpdated": 1685338200000000 } ``` --- ### Intraday Ticker 取得股票資訊 (依股票代碼查詢) ```text intraday/ticker/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------- | | `symbol`\* | string | 股票代碼 | | `type` | string | 類型,可選 `oddlot` 盤中零股 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------------------- | ------- | ------------------------------------------------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代碼 | | `name`\* | string | 股票簡稱 | | `nameEn` | string | 股票英文簡稱 | | `industry` | string | 產業別 | | `securityType` | string | 證券別,參閱 [證券別代碼](#%E8%AD%89%E5%88%B8%E5%88%A5%E4%BB%A3%E7%A2%BC) | | `referencePrice` | number | 參考價 | | `limitUpPrice` | number | 漲停價 | | `limitDownPrice` | number | 跌停價 | | `canDayTrade` | boolean | 可買賣現沖 | | `canBuyDayTrade` | boolean | 可先買現沖 | | `canBelowFlatMarginShortSell` | boolean | 平盤下得融券賣出 | | `canBelowFlatSBLShortSell` | boolean | 平盤下得借券賣出 | | `isAttention` | boolean | 注意股 | | `isDisposition` | boolean | 處置股 | | `isUnusuallyRecommended` | boolean | 投資理財節目異常推介個股 | | `isSpecificAbnormally` | boolean | 特殊異常個股 | | `matchingInterval` | number | 撮合循環秒數 | | `securityStatus` | string | 證券狀態,分別有 `NORMAL`, `TERMINATED`, `SUSPENDED` 狀態 | | `boardLot` | number | 交易單位 | | `tradingCurrency` | string | 交易幣別 | | `exercisePrice` | number | 履約價格(限權證) | | `exercisedVolume` | number | 前一交易日履約數量(限權證) | | `cancelledVolume` | number | 前一交易日註銷數量(限權證) | | `remainingVolume` | number | 發行餘額量(限權證) | | `exerciseRatio` | number | 行使比率(限權證) | | `knockInPrice` | number | 上限價格(限權證) | | `knockOutPrice` | number | 下限價格(限權證) | | `maturityDate` | string | 到期日(限權證) | | `previousClose` | number | 前一交易日收盤價 | | `openTime` | string | 開盤時間(限指數) | | `closeTime` | string | 收盤時間(限指數) | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password") sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.ticker(symbol='2330') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday.ticker({ symbol: '2330' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "name": "台積電", "industry": "24", "securityType": "01", "previousClose": 566, "referencePrice": 566, "limitUpPrice": 622, "limitDownPrice": 510, "canDayTrade": true, "canBuyDayTrade": true, "canBelowFlatMarginShortSell": true, "canBelowFlatSBLShortSell": true, "isAttention": false, "isDisposition": false, "isUnusuallyRecommended": false, "isSpecificAbnormally": false, "matchingInterval": 0, "securityStatus": "NORMAL", "boardLot": 1000, "tradingCurrency": "TWD" } ``` #### 證券別代碼[​](#證券別代碼 "Direct link to 證券別代碼") | 代碼 | 證券別 | 代碼 | 證券別 | | ---- | ------------------------------------------ | ---- | ---------------------- | | `01` | 一般股票 | `24` | ETF | | `02` | 轉換公司債 | `25` | ETF(外幣計價) | | `03` | 交換公司債或交換金融債 | `26` | 槓桿型ETF | | `04` | 一般特別股 | `27` | 槓桿型 ETF(外幣計價) | | `05` | 可交換特別股 | `28` | 反向型 ETF | | `06` | 認股權憑證 | `29` | 反向型 ETF(外幣計價) | | `07` | 附認股權特別股 | `30` | 期信託 ETF | | `08` | 附認股權公司債 | `31` | 期信託 ETF(外幣計價) | | `09` | 附認股權公司債履約或分拆後之公司債 | `32` | 債券 ETF | | `10` | 國內標的認購權證 | `33` | 債券 ETF(外幣計價) | | `11` | 國內標的認售權證 | `34` | 金融資產證券化受益證券 | | `12` | 外國標的認購權證 | `35` | 不動產資產信託受益證券 | | `13` | 外國標的認售權證 | `36` | 不動產投資信託受益證券 | | `14` | 國內標的下限型認購權證 | `37` | ETN | | `15` | 國內標的上限型認售權證 | `38` | 槓桿型 ETN | | `16` | 國內標的可展延下限型認購權證 | `39` | 反向型 ETN | | `17` | 國內標的可展延上限型認售權證 | `40` | 債券型 ETN | | `18` | 受益憑證(封閉式基金) | `41` | 期權策略型 ETN | | `19` | 存託憑證 | `42` | 中央登錄公債 | | `20` | 存託憑證可轉換公司債 | `43` | 外國債券 | | `21` | 存託憑證附認股權公司債 | `44` | 黃金現貨 | | `22` | 存託憑證附認股權公司債履約或分拆後之公司債 | `00` | 未知或保留代碼 | | `23` | 存託憑證認股權憑證 | | | --- ### Intraday Tickers 股票或指數列表(依條件查詢) ```text intraday/tickers ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | --------------- | ------- | ------------------------------------------------------------------------------------------- | | `type`\* | string | Ticker 類型,可選 `EQUITY` 股票;`INDEX` 指數;`WARRANT` 權證;`ODDLOT` 盤中零股 | | `exchange` | string | 交易所,可選 `TWSE` 臺灣證券交易所;`TPEx` 證券櫃檯買賣中心 | | `market` | string | 市場別,可選 `TSE` 上市;`OTC` 上櫃;`ESB` 興櫃一般板;`TIB` 臺灣創新板;`PSB` 興櫃戰略新板 | | `industry` | string | 產業別,參閱 [產業別代碼](#%E7%94%A2%E6%A5%AD%E5%88%A5%E4%BB%A3%E7%A2%BC) | | `isNormal` | boolean | 查詢正常股票(非注意、處置股票):`true` | | `isAttention` | boolean | 查詢注意股票:`true` | | `isDisposition` | boolean | 查詢處置股票:`true` | | `isHalted` | boolean | 查詢暫停交易股票:`true` | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------- | --------- | -------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `industry` | string | 產業別 | | `isNormal` | boolean | 查詢正常股票(非注意、處置股票) | | `isAttention` | boolean | 查詢注意股票 | | `isDisposition` | boolean | 查詢處置股票 | | `isHalted` | boolean | 查詢暫停交易股票 | | `data` | object\[] | 股票列表 | | >> `symbol` | string | 股票代碼 | | >> `name` | string | 股票簡稱 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.tickers(type='EQUITY', exchange="TWSE", isNormal=True) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday .tickers({ type: "EQUITY", exchange: "TWSE", isNormal: true }) .then((data) => console.log(data)); ``` Response Body: ```json { "date": "2023-02-09", "type": "EQUITY", "exchange": "TWSE", "isNormal": true, "data": [ { "symbol": "0050", "name": "元大台灣50" }, { "symbol": "0051", "name": "元大中型100" }, { "symbol": "0052", "name": "富邦科技" }, ...... ] } ``` #### 產業別代碼[​](#產業別代碼 "Direct link to 產業別代碼") | 代碼 | 產業別 | 代碼 | 產業別 | 代碼 | 產業別 | | ---- | -------- | ---- | ---------------- | ---- | ------------ | | `01` | 水泥工業 | `16` | 觀光餐旅 | `29` | 電子通路業 | | `02` | 食品工業 | `17` | 金融保險 | `30` | 資訊服務業 | | `03` | 塑膠工業 | `18` | ~~貿易百貨~~ | `31` | 其他電子業 | | `04` | 紡織纖維 | `19` | 綜合 | `32` | 文化創意業 | | `05` | 電機機械 | `20` | 其他 | `33` | 農業科技業 | | `06` | 電器電纜 | `21` | 化學工業 | `34` | ~~電子商務~~ | | `08` | 玻璃陶瓷 | `22` | 生技醫療業 | `35` | 綠能環保 | | `09` | 造紙工業 | `23` | 油電燃氣業 | `36` | 數位雲端 | | `10` | 鋼鐵工業 | `24` | 半導體業 | `37` | 運動休閒 | | `11` | 橡膠工業 | `25` | 電腦及週邊設備業 | `38` | 居家生活 | | `12` | 汽車工業 | `26` | 光電業 | `80` | 管理股票 | | `14` | 建材營造 | `27` | 通信網路業 | | | | `15` | 航運業 | `28` | 電子零組件業 | | | --- ### Intraday Trades 股票成交明細(依代碼查詢) ```text intraday/trades/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ----------------------------------- | | `symbol`\* | string | 股票代碼 | | `type` | string | Ticker 類型,可選 `oddlot` 盤中零股 | | `offset` | number | 偏移量 | | `limit` | number | 限制量 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ----------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `data`\* | object\[] | 成交明細 | | >> `bid` | number | 成交買價 | | >> `ask` | number | 成交賣價 | | >> `price` | number | 成交價格 | | >> `size` | number | 成交單量 | | >> `volume` | number | 成交總量 | | >> `time` | number | 成交時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.trades(symbol='2330') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday.trades({ symbol: '2330' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "data": [ { "price": 568, "size": 32, "time": 1685341800000000, "serial": 99999999 }, { "bid": 567, "ask": 568, "price": 568, "size": 4778, "volume": 54538, "time": 1685338200000000, "serial": 6652422 }, { "bid": 565, "ask": 566, "price": 566, "size": 1, "volume": 49760, "time": 1685337899721587, "serial": 6622549 }, ...... ] } ``` --- ### Intraday Volumes 股票分價量表(依代碼查詢) ```text intraday/volumes/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------- | | `symbol`\* | string | 股票代碼 | | `type` | string | 類型,可選 `oddlot` 盤中零股 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------- | --------- | -------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `data` | object\[] | 分價量表 | | >> `price` | number | 成交價 | | >> `volume` | number | 該成交價之累計成交量 | | >> `volumeAtBid` | number | 累計內盤成交量 | | >> `volumeAtAsk` | number | 累計外盤成交量 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.intraday.volumes(symbol='2330') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.intraday.volumes({ symbol: '2330' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "data": [ { "price": 574, "volume": 7309, "volumeAtBid": 0, "volumeAtAsk": 524 }, { "price": 573, "volume": 771, "volumeAtBid": 657, "volumeAtAsk": 114 }, { "price": 572, "volume": 3364, "volumeAtBid": 843, "volumeAtAsk": 2521 }, { "price": 571, "volume": 3723, "volumeAtBid": 1026, "volumeAtAsk": 2697 }, { "price": 570, "volume": 5541, "volumeAtBid": 3019, "volumeAtAsk": 2522 }, { "price": 569, "volume": 1952, "volumeAtBid": 1318, "volumeAtAsk": 634 }, { "price": 568, "volume": 7906, "volumeAtBid": 1422, "volumeAtAsk": 6484 }, { "price": 567, "volume": 10498, "volumeAtBid": 2816, "volumeAtAsk": 7682 }, { "price": 566, "volume": 8206, "volumeAtBid": 5988, "volumeAtAsk": 2218 }, { "price": 565, "volume": 4833, "volumeAtBid": 2329, "volumeAtAsk": 2504 }, { "price": 564, "volume": 435, "volumeAtBid": 435, "volumeAtAsk": 0 } ] } ``` --- ### Snapshot Actives 股票成交量值排行(依市場別) ```text snapshot/actives/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------------------------- | | `market`\* | string | 市場別,可選 `TSE` 上市;`OTC` 上櫃;`ESB` 興櫃一般板;`TIB` 臺灣創新板;`PSB` 興櫃戰略新板 | | `trade`\* | string | 成交量/成交值,可選 `volume` 成交量;`value` 成交值 | | `type` | string | 標的類型,可選 `ALLBUT099` 包含一般股票、特別股及ETF ; `COMMONSTOCK` 為一般股票 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | -------------- | | `date`\* | string | 日期 | | `time`\* | string | 時間 | | `market`\* | string | 市場別 | | `trade`\* | string | 成交量/成交值 | | `data`\* | object\[] | 快照資料 | | >> `type` | string | Ticker 類型 | | >> `symbol` | string | 股票代碼 | | >> `name` | string | 股票簡稱 | | >> `openPrice` | number | 開盤價 | | >> `highPrice` | number | 最高價 | | >> `lowPrice` | number | 最低價 | | >> `closePrice` | number | 收盤價 | | >> `change` | number | 漲跌 | | >> `changePercent` | number | 漲跌幅 | | >> `tradeVolume` | number | 成交量 | | >> `tradeValue` | number | 成交金額 | | >> `lastUpdated` | number. | 快照時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.snapshot.actives(market='TSE', trade='value') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.snapshot.actives({ market: 'TSE', trade: 'value' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "time": "140000", "market": "TSE", "trade": "value", "data": [ { "type": "EQUITY", "symbol": "2330", "name": "台積電", "openPrice": 574, "highPrice": 574, "lowPrice": 564, "closePrice": 568, "change": 2, "changePercent": 0.35, "tradeVolume": 54538, "tradeValue": 31019803000, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "3231", "name": "緯創", "openPrice": 66, "highPrice": 69.2, "lowPrice": 65.9, "closePrice": 68, "change": 3, "changePercent": 4.62, "tradeVolume": 202089, "tradeValue": 13763365000, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "3661", "name": "世芯-KY", "openPrice": 1555, "highPrice": 1660, "lowPrice": 1550, "closePrice": 1660, "change": 150, "changePercent": 9.93, "tradeVolume": 6937, "tradeValue": 11264055000, "lastUpdated": 1685338200000000 }, ...... ] } ``` --- ### Snapshot Movers 股票漲跌幅排行(依市場別) ```text snapshot/movers/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | -------------------------------------------------------------------------------- | | `market`\* | string | 市場別 | | `direction`\* | string | 上漲/下跌,可選 `up` 上漲;`down` 下跌 | | `change`\* | string | 漲跌/漲跌幅,可選 `percent` 漲跌幅;`value` 漲跌 | | `gt` | number | 篩選大於漲跌/漲跌幅的股票 | | `type` | string | 標的類型,可選 `ALLBUT099` 包含一般股票、特別股及ETF ; `COMMONSTOCK` 為一般股票 | | `gte` | number | 篩選大於或等於漲跌/漲跌幅的股票 | | `lt` | number | 篩選小於漲跌/漲跌幅的股票 | | `lte` | number | 篩選小於或等於漲跌/漲跌幅的股票 | | `eq` | number | 篩選等於漲跌/漲跌幅的股票 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | ------------ | | `date`\* | string | 日期 | | `time`\* | string | 時間 | | `market`\* | string | 市場別 | | `change`\* | string | 漲跌/漲跌幅 | | `data`\* | object\[] | 快照資料 | | >> `type` | string | Ticker 類型 | | >> `symbol` | string | 股票代碼 | | >> `name` | string | 股票簡稱 | | >> `openPrice` | number | 開盤價 | | >> `highPrice` | number | 最高價 | | >> `lowPrice` | number | 最低價 | | >> `closePrice` | number | 收盤價 | | >> `change` | number | 漲跌 | | >> `changePercent` | number | 漲跌幅 | | >> `tradeVolume` | number | 成交量 | | >> `tradeValue` | number | 成交金額 | | >> `lastUpdated` | number | 快照時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.snapshot.movers(market='TSE', direction='up', change='percent') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.snapshot.movers({ market: 'TSE', direction: 'up', change: 'percent' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "time": "133500", "market": "TSE", "change": "percent", "data": [ { "type": "EQUITY", "symbol": "2901", "name": "欣欣", "openPrice": 27.1, "highPrice": 29.7, "lowPrice": 27.1, "closePrice": 29.7, "change": 2.7, "changePercent": 10, "tradeVolume": 640, "tradeValue": 18824300, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "2345", "name": "智邦", "openPrice": 357.5, "highPrice": 357.5, "lowPrice": 346.5, "closePrice": 357.5, "change": 32.5, "changePercent": 10, "tradeVolume": 9350, "tradeValue": 3331334500, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "3025", "name": "星通", "openPrice": 42.3, "highPrice": 44.65, "lowPrice": 41.8, "closePrice": 44.65, "change": 4.05, "changePercent": 9.98, "tradeVolume": 25625, "tradeValue": 1114127050, "lastUpdated": 1685338200000000 }, ...... ] } ``` --- ### Snapshot Quotes 股票行情快照(依市場別) ```text snapshot/quotes/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------------------------- | | `market`\* | string | 市場別,可選 `TSE` 上市;`OTC` 上櫃;`ESB` 興櫃一般板;`TIB` 臺灣創新板;`PSB` 興櫃戰略新板 | | `type` | string | 標的類型,可選 `ALLBUT099` 包含一般股票、特別股及ETF ; `COMMONSTOCK` 為一般股票 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | ------------------------ | | `date`\* | string | 日期 | | `time`\* | string | 時間 | | `market`\* | string | 市場別 | | `data`\* | object\[] | 快照資料 | | >> `type` | string | Ticker 類型 | | >> `symbol` | string | 股票代碼 | | >> `name` | string | 股票簡稱 | | >> `openPrice` | number | 開盤價 | | >> `highPrice` | number | 最高價 | | >> `lowPrice` | number | 最低價 | | >> `closePrice` | number | 收盤價 | | >> `change` | number | 漲跌 | | >> `changePercent` | number | 漲跌幅 | | >> `tradeVolume` | number | 成交量 | | >> `tradeValue` | number | 成交金額 | | >> `lastUpdated` | number | 快照時間 | | >> `lastPrice` | number | 最後一筆成交價(含試撮) | | >> `isTrial` | bool | 試撮註記 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.snapshot.quotes(market='TSE') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.snapshot.quotes({ market: 'TSE' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-05-29", "time": "133500", "market": "TSE", "data": [ { "type": "EQUITY", "symbol": "0050", "name": "元大台灣50", "openPrice": 127.45, "highPrice": 127.55, "lowPrice": 126.5, "closePrice": 126.75, "change": 0.8, "changePercent": 0.64, "tradeVolume": 14444, "tradeValue": 1832941850, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "0051", "name": "元大中型100", "openPrice": 61, "highPrice": 62.2, "lowPrice": 61, "closePrice": 62, "change": 1.3, "changePercent": 2.14, "tradeVolume": 191, "tradeValue": 11816050, "lastUpdated": 1685338200000000 }, { "type": "EQUITY", "symbol": "0052", "name": "富邦科技", "openPrice": 111.8, "highPrice": 112.1, "lowPrice": 111.1, "closePrice": 111.7, "change": 1.2, "changePercent": 1.09, "tradeVolume": 565, "tradeValue": 63088400, "lastUpdated": 1685338200000000 }, ...... ] } ``` --- ### Technical Bbands 取得特定股票在指定時間範圍內的布林通通 (Bollinger Bands) ```text technical/bb/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from`\* | string | 開始日期(格式:`yyyy-MM-dd`) | | `to`\* | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe`\* | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `period`\* | number | Bolling 週期 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近 30 日資料。 #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------- | ------ | ------------ | | `symbol`\* | string | 股票代號 | | `from`\* | string | 開始日期 | | `to`\* | string | 結束日期 | | `timeframe`\* | string | K線週期 | | `period`\* | string | RSI 週期 | | `data` | Object | RSI 資料 | | >> `data[0].date` | string | 資料日期 | | >> `data[0].upper` | number | Bolling 上軌 | | >> `data[0].middle` | number | Bolling 中軌 | | >> `data[0].lower` | number | Bolling 下軌 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.technical.bb(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 10}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.technical.bb({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', period: 10 }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "2330", "from": "2024-08-01", "to": "2024-08-10", "timeframe": "D", "period": 20, "data": [ { "date": "2024-08-01", "upper": 1089.4184184924368, "middle": 997.45, "lower": 905.4815815075632 }, { "date": "2024-08-02", "upper": 1094.230862990929, "middle": 993.65, "lower": 893.0691370090711 }, { "date": "2024-08-05", "upper": 1111.086637737101, "middle": 984.15, "lower": 857.2133622628991 }, { "date": "2024-08-06", "upper": 1112.2099400640175, "middle": 977.9, "lower": 843.5900599359824 }, { "date": "2024-08-07", "upper": 1106.0354361011682, "middle": 972.15, "lower": 838.2645638988317 }, { "date": "2024-08-08", "upper": 1098.9536939789348, "middle": 964.95, "lower": 830.9463060210653 }, { "date": "2024-08-09", "upper": 1088.7976815866498, "middle": 959.4, "lower": 830.0023184133502 } ] } ``` --- ### Technical KDJ 取得特定股票在指定時間範圍內的隨機指標 (KDJ) ```text technical/kdj/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from`\* | string | 開始日期(格式:`yyyy-MM-dd`) | | `to`\* | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe`\* | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `rPeriod`\* | number | KDJ 週期 | | `kPeriod`\* | number | %K 週期 | | `dPeriod`\* | number | %D 週期 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近 30 日資料。 #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ----------- | | `symbol`\* | string | 股票代號 | | `from`\* | string | 開始日期 | | `to`\* | string | 結束日期 | | `timeframe`\* | string | K線週期 | | `rPeriod`\* | number | KDJ 週期 | | `kPeriod`\* | number | %K 週期 | | `dPeriod`\* | number | %D 週期 | | `data`\* | Object | KDJ 資料 | | >> `data[0].date` | string | 資料日期 | | >> `data[0].k` | number | K | | >> `data[0].d` | number | D | | >> `data[0].j` | number | J | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.technical.kdj(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "rPeriod": 9, "kPeriod":3, "dPeriod":3}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.technical.kdj({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', rPeriod: 9, kPeriod: 3, dPeriod: 3 }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "2330", "from": "2024-08-01", "to": "2024-08-10", "timeframe": "D", "rPeriod": 9, "kPeriod": 3, "dPeriod": 3, "data": [ { "date": "2024-08-01", "k": 32.96296296296297, "d": 27.77777777777779, "j": 43.333333333333336 }, { "date": "2024-08-02", "k": 23.703703703703713, "d": 27.901234567901245, "j": 15.308641975308653 }, { "date": "2024-08-05", "k": 17.068273092369484, "d": 24.578313253012055, "j": 2.048192771084345 }, { "date": "2024-08-06", "k": 13.855421686746999, "d": 18.20913282760673, "j": 5.147999405027534 }, { "date": "2024-08-07", "k": 36.718669549994864, "d": 22.547454776370447, "j": 65.0610990972437 }, { "date": "2024-08-08", "k": 54.05210585933478, "d": 34.87539903202555, "j": 92.40551951395325 }, { "date": "2024-08-09", "k": 66.45299145299147, "d": 52.40792228744038, "j": 94.54312978409367 } ] } ``` --- ### Technical MACD 取得特定股票在指定時間範圍內的指數平滑異同移動平均線 (MACD) ```text technical/macd/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from`\* | string | 開始日期(格式:`yyyy-MM-dd`) | | `to`\* | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe`\* | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `fast`\* | number | 快線週期 | | `slow`\* | number | 慢線週期 | | `signal`\* | number | 信號線週期 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近 30 日資料。 #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------------- | ------ | ----------- | | `symbol`\* | string | 股票代號 | | `from`\* | string | 開始日期 | | `to`\* | string | 結束日期 | | `timeframe`\* | string | K線週期 | | `fast`\* | number | 快線週期 | | `slow`\* | number | 慢線週期 | | `signal`\* | number | 信號線週期 | | `data` | Object | RSI 資料 | | >> `data[0].date` | string | 資料日期 | | >> `data[0].macdLine` | number | MACD 線 | | >> `data[0].signalLine` | number | 信號線 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.technical.macd(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "fast": 12, "slow":26, "signal":9}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.technical.macd({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', fast: 12, slow: 26, signal: 9, dPeriod: 3 }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "2330", "from": "2024-08-01", "to": "2024-08-10", "timeframe": "D", "fast": 12, "slow": 26, "signal": 9, "data": [ { "date": "2024-08-01", "macdLine": -8.888098865883194, "signalLine": 1.1835714956164298 }, { "date": "2024-08-02", "macdLine": -13.342205320023709, "signalLine": -1.721583867511598 }, { "date": "2024-08-05", "macdLine": -23.69978495993405, "signalLine": -6.117224085996089 }, { "date": "2024-08-06", "macdLine": -26.359429578554114, "signalLine": -10.165665184507695 }, { "date": "2024-08-07", "macdLine": -24.951921179141777, "signalLine": -13.12291638343451 }, { "date": "2024-08-08", "macdLine": -25.47934996958338, "signalLine": -15.594203100664284 }, { "date": "2024-08-09", "macdLine": -22.570875660446973, "signalLine": -16.989537612620822 } ] } ``` --- ### Technical RSI 取得特定股票在指定時間範圍內的相對強弱指標 (RSI) ```text technical/rsi/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from`\* | string | 開始日期(格式:`yyyy-MM-dd`) | | `to`\* | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe`\* | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `period`\* | number | RSI 週期 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近 30 日資料。 #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ----------- | | `symbol`\* | string | 股票代號 | | `from`\* | string | 開始日期 | | `to`\* | string | 結束日期 | | `timeframe`\* | string | K線週期 | | `period`\* | string | RSI 週期 | | `data` | Object | RSI 資料 | | >> `data[0].date` | string | 資料日期 | | >> `data[0].rsi` | number | RSI | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.technical.rsi(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 6}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.technical.rsi({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', period: 6 }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "2330", "from": "2024-08-01", "to": "2024-08-10", "timeframe": "D", "period": 6, "data": [ { "date": "2024-08-01", "rsi": 41.44144144144145 }, { "date": "2024-08-02", "rsi": 25.641025641025635 }, { "date": "2024-08-05", "rsi": 15.026786880961723 }, { "date": "2024-08-06", "rsi": 37.83577095879935 }, { "date": "2024-08-07", "rsi": 48.119604933543954 }, { "date": "2024-08-08", "rsi": 42.99811400274545 }, { "date": "2024-08-09", "rsi": 52.58621466649552 } ] } ``` --- ### Technical SMA 取得特定股票在指定時間範圍內的簡單移動平均 (SMA) ```text technical/sma/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | 股票代碼 | | `from`\* | string | 開始日期(格式:`yyyy-MM-dd`) | | `to`\* | string | 結束日期(格式:`yyyy-MM-dd`) | | `timeframe`\* | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K;`D` 日K;`W` 週K;`M` 月K | | `period`\* | int | SMA 週期 | caution 目前分K無法指定開始日期(from) 與 結束日期(to),一律回傳近 30 日資料。 #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ----------- | | `symbol`\* | string | 股票代號 | | `from`\* | string | 開始日期 | | `to`\* | string | 結束日期 | | `timeframe`\* | string | K線週期 | | `period`\* | string | SMA 週期 | | `data` | Object | SMA 資料 | | >> `data[0].date` | string | 資料日期 | | >> `data[0].sma` | number | SMA | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 reststock = sdk.marketdata.rest_client.stock reststock.technical.sma(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 5}) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.technical.sma({ symbol: '2330', from: '2024-08-01', to: '2024-08-10', timeframe: 'D', period: 5 }) .then(data => console.log(data)); ``` Response Body: ```json { "symbol": "2330", "from": "2024-08-01", "to": "2024-08-10", "timeframe": "D", "period": 5, "data": [ { "date": "2024-08-01", "sma": 940.4 }, { "date": "2024-08-02", "sma": 936.2 }, { "date": "2024-08-05", "sma": 910.4 }, { "date": "2024-08-06", "sma": 898.4 }, { "date": "2024-08-07", "sma": 895.6 }, { "date": "2024-08-08", "sma": 882.8 }, { "date": "2024-08-09", "sma": 889 } ] } ``` --- ### 台新行情 API 即時行情資料來源為臺灣證券交易所、證券櫃檯買賣中心、臺灣期貨交易所。請您詳閱相關使用 [規範與聲明](#statement) 。 #### Web API[​](#web-api "Direct link to Web API") 台新行情 [Web API](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/http-api/getting-started.md) 提供開發者友善的 API 服務。您可以查詢台股的日內行情、行情快照與歷史行情等數據;數據來源為時報資訊與群馥科技。 #### WebSocket API[​](#websocket-api "Direct link to WebSocket API") 台新行情 [WebSocket API](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/getting-started.md) 提供台股即時行情服務。透過 WebSocket API 可以滿足您想要接收即時行情的需求。 #### 使用規範與聲明[​](#statement "Direct link to 使用規範與聲明") * 透過本服務取得之行情資料僅供參考,成交值及成交量不含零股及鉅額交易,使用者依本資料交易發生交易損失需自行負責。 * 時報資訊與群馥科技對資料內容錯誤、更新延誤或傳輸中斷不負任何責任。您應對您所為之任何金融或投資決策自行負責。 * 使用者應遵守 [臺灣證券交易所股份有限公司交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0100124) 、 [臺灣期貨交易所股份有限公司交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0101422) 、 [財團法人中華民國證券櫃檯買賣中心有價證券交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0100766) 、各資訊來源提供者所定之資訊使用相關規範及智慧財產權相關法令,所有資訊以各資訊來源提供者公告資料為準。如有盜接 、轉接交易資訊,或以其他方式出售、出租、轉讓、再授權交易資訊,或將交易資訊另行取樣並編製指數、其他衍生性商品或將之傳送予第三人,應負違約及侵權之相關民、刑事責任。 * 台新行情 API 是由 [Fugle](https://www.fugle.tw/) 技術團隊開發提供。 --- ### 速率限制 ##### 速率限制[​](#速率限制 "Direct link to 速率限制") 台新行情提供了Web API 與 Socket 行情,並設定了以下存取的限制 * 日內行情 : 600 / min * WebSocket : 300 訂閱數;2連線數 * 行情快照 : 600 / min * 歷史行情 : 60 / min 如果您 API 請求超過了限制,將收到帶有狀態碼 `429` 的回應。需再等候1分鐘。 ```json {"statusCode":429,"message":"Rate limit exceeded"} ``` 或是您的WebSocket 訂閱數超過上限,將收到以下訊息: ```json { "event": "error", "data": { "code": 1001, "message": "message Maximum number of connections reached" } } ``` --- ### 開始使用 台新行情 WebSocket API 提供台股即時行情服務。透過 WebSocket API 可以滿足您想要接收即時行情的需求。 #### 使用 SDK[​](#使用-sdk "Direct link to 使用 SDK") 台新行情 WebSocket API 提供 Python、Node.js,您可以透過以下方式存取 WebSocket API 行情: 訂閱 WebSocket Callback 方法獲得下方 Callback 訊息。 * Python * Node.js ```python from taishin_sdk import TaishinSDK def handle_message(message): print(message) sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const stock = sdk.marketdata.webSocketClient.stock; stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); (async () => { await stock.connect(); stock.subscribe({ 'channel': 'trades', 'symbol': '2887' }); })() ``` #### 身份驗證[​](#身份驗證 "Direct link to 身份驗證") 當驗證成功後,會收到以下訊息: ```json { "event": "authenticated", "data": { "message": "Authenticated successfully" } } ``` 若驗證失敗,則收到以下訊息: ```json { "event": "error", "data": { "message": "Invalid authentication credentials" } } ``` #### Heartbeat[​](#heartbeat "Direct link to Heartbeat") 每隔 30 秒 WebSocket server 會送出一個 heartbeat 訊息: ```json { "event": "heartbeat", "data": { "time": "" } } ``` #### Ping/Pong[​](#pingpong "Direct link to Ping/Pong") SDK 每五秒將自動發送 ping 到 server 中,也可自行發送 ping,另外額外自訂 `state`(state 為 optional 參數): * Python * Node.js ```python stock.ping({ 'state' : '' }) ``` ```js stock.ping({state:''}); ``` WebSocket Server 會回應以下訊息 (若 ping 未送 `state` 則不會有該欄位): ```json { "event": "pong", "data": { "time": "", "state": "" } } ``` #### Channels[​](#channels "Direct link to Channels") 台新行情 WebSocket API 目前提供以下可訂閱頻道: * `trades` - [接收訂閱股票最新成交資訊](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/market-data-channels/trades.md) * `books` - [接收訂閱股票最新最佳五檔委買委賣資訊](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/market-data-channels/books.md) * `indices` - [接收訂閱股票最新指數行情資料](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/market-data-channels/indices.md) * `aggregates` - [接收訂閱股票聚合數據的行情資訊](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/market-data-channels/aggregates.md) * `candles` - [接收訂閱股票最新指數行情資料](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data/websocket-api/market-data-channels/candles.md) ##### 訂閱頻道[​](#訂閱頻道 "Direct link to 訂閱頻道") 要訂閱一個頻道可用下方範例進行訂閱: * Python * Node.js ```python stock.subscribe({ "channel" : "", "symbol" : "" #"intradayOddLot": True 若要訂閱盤中零股,可再額外加入此參數 }) ``` ```js stock.subscribe({ channel: '', symbol: '', //intradayOddLot: true 若要訂閱盤中零股,可再額外加入此參數 }); ``` 訂閱成功後,會收到以下事件回應: ```json { "event": "subscribed", "data": { "id": "", "channel": "", "symbol": "" } } ``` 支援訂閱同頻道的多檔股票: * Python * Node.js ```python stock.subscribe({ "channel" : "", "symbols" : ["",""] #"intradayOddLot": True 若要訂閱盤中零股,可再額外加入此參數 }) ``` ```js stock.subscribe({ channel: '', symbols: ['',''] //intradayOddLot: true 若要訂閱盤中零股,可再額外加入此參數 }); ``` 訂閱成功後,會收到以下事件回應: ```json { "event": "subscribed", "data": [ { "id": "", "channel": "", "symbol": "" }, { "id": "", "channel": "", "symbol": "" } ] } ``` ##### 取消訂閱[​](#取消訂閱 "Direct link to 取消訂閱") 要取消頻道可用下方範例進行取消: * Python * Node.js ```python stock.unsubscribe({ 'id':'' }) ``` ```js stock.unsubscribe({ id : '' }); ``` 取消訂閱成功後,會收到以下事件回應: ```json { "event": "unsubscribed", "data": { "id": "" } } ``` 支援取消訂閱多個頻道: * Python * Node.js ```python stock.unsubscribe({ 'ids':['',''] }) ``` ```js stock.unsubscribe({ ids : ['',''] }); ``` 取消訂閱成功後,會收到以下事件回應: ```json { "event": "unsubscribed", "data": [ { "id": "" }, { "id": "" } ] } ``` #### 錯誤處理[​](#錯誤處理 "Direct link to 錯誤處理") 當您所訂閱或處理的 WebSocket Callback 有異常時,您可補充處理錯誤訊息如下: * Python * Node.js ```python def handle_connect(): print('market data connected') def handle_disconnect(code, message): print(f'market data disconnect: {code}, {message}') def handle_error(error): print(f'market data error: {error}') stock.on("connect", handle_connect) stock.on("disconnect", handle_disconnect) stock.on("error", handle_error) ``` ```js stock.on("connect", (message) => { const connect_msg = JSON.parse(message); console.log(connect_msg); }); stock.on("disconnect", (message) => { console.log(message); }); stock.on("error", (message) => { const err_msg = JSON.parse(message); console.log(err_msg); }); ``` ##### 斷線重連[​](#斷線重連 "Direct link to 斷線�重連") 以下將用簡單範例,利用上述定義之錯誤處理方法,接收到斷線事件,程式自動進行連線 * Python * Node.js ```python def handle_disconnect(code, message): print(f'market data disconnect: {code}, {message}') stock.connect() print("Reconnected Succuess") print("Resubscribe") stock.subscribe({ # 重新訂閱您已訂閱過的Channel與Symbol 'channel': '', 'symbol': '' }) ``` ```js stock.on("disconnect", (message) => { console.log(message); stock.connect() console.log("Reconnected Succuess"); stock.subscribe({ channel: '', symbol: '' }); //重新訂閱您已訂閱過的Channel與Symbol }); ``` --- ### Aggregates 接收訂閱股票聚合數據的行情資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | 股票代碼 | | `intradayOddLot` | boolean | `intradayOddLot` true: 盤中零股, false: 股票, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | ---------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代碼 | | `name`\* | string | 股票簡稱 | | `referencePrice` | number | 參考價 | | `previousClose` | number | 前一交易日收盤價 | | `openPrice` | number | 開盤價 | | `openTime` | number | 開盤價成交時間 | | `highPrice` | number | 最高價 | | `highTime` | number | 最高價成交時間 | | `lowPrice` | number | 最低價 | | `lowTime` | number | 最低價成交時間 | | `closePrice` | number | 收盤價(最後成交價) | | `closeTime` | number | 收盤價(最後成交價)成交時間 | | `avgPrice` | number | 當日成交均價 | | `change` | number | 最後成交價漲跌 | | `changePercent` | number | 最後成交價漲跌幅 | | `amplitude` | number | 當日振幅 | | `lastPrice` | number | 最後一筆成交價(含試撮) | | `lastSize` | number | 最後一筆成交數量(含試撮) | | `bids` | object\[] | 最佳五檔委買 | | >> `price` | number | 最佳五檔委買價格 | | >> `size` | number | 最佳五檔委買數量 | | `asks` | object\[] | 最佳五檔委賣 | | >> `price` | number | 最佳五檔委賣價格 | | >> `size` | number | 最佳五檔委賣數量 | | `total` | object | 統計資訊 | | >> `tradeValue` | number | 累計成交金額 | | >> `tradeVolume` | number | 累計成交量 | | >> `tradeVolumeAtBid` | number | 累計內盤成交量 | | >> `tradeVolumeAtAsk` | number | 累計外盤成交量 | | >> `transaction` | number | 累計成交筆數 | | >> `time` | number | 累計資訊時間 | | `lastTrade` | object | 最後一筆成交資訊 | | >> `bid` | number | 最後一筆成交買價 | | >> `ask` | number | 最後一筆成交賣價 | | >> `price` | number | 最後一筆成交價格 | | >> `size` | number | 最後一筆成交數量 | | >> `time` | number | 最後一筆成交時間 | | `lastTrial` | object | 最後一筆試撮資訊 | | >> `bid` | number | 最後一筆試撮買價 | | >> `ask` | number | 最後一筆試撮賣價 | | >> `price` | number | 最後一筆試撮價格 | | >> `size` | number | 最後一筆試撮數量 | | >> `time` | number | 最後一筆試撮時間 | | `isLimitDownPrice` | boolean | 最後成交價為跌停價:`true` | | `isLimitUpPrice` | boolean | 最後成交價為漲停價:`true` | | `isLimitDownBid` | boolean | 最佳一檔委買跌停價:`true` | | `isLimitUpBid` | boolean | 最佳一檔委買漲停價:`true` | | `isLimitDownAsk` | boolean | 最佳一檔委賣跌停價:`true` | | `isLimitUpAsk` | boolean | 最佳一檔委賣漲停價:`true` | | `isLimitDownHalt` | boolean | 暫緩撮合且瞬間趨跌:`true` | | `isLimitUpHalt` | boolean | 暫緩撮合且瞬間趨漲:`true` | | `isTrial` | boolean | 試撮階段:`true` | | `isDelayedOpen` | boolean | 延後開盤信號:`true` | | `isDelayedClose` | boolean | 延後收盤信號:`true` | | `isContinuous` | boolean | 最後成交為逐筆交易:`true` | | `isOpen` | boolean | 開盤信號:`true` | | `isClose` | boolean | 收盤信號:`true` | | `lastUpdated` | number | 最後更新時間 | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'aggregates', 'symbol': '2330' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); const stock = sdk.marketdata.webSocketClient.stock; stock.connect().then(() => { stock.subscribe({ channel: "aggregates", symbol: "0050" }); }); stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "date": "2023-05-29", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "symbol": "2330", "name": "台積電", "referencePrice": 566, "previousClose": 566, "openPrice": 574, "openTime": 1685322000049353, "highPrice": 574, "highTime": 1685322000049353, "lowPrice": 564, "lowTime": 1685327142152580, "closePrice": 568, "closeTime": 1685338200000000, "avgPrice": 568.77, "change": 2, "changePercent": 0.35, "amplitude": 1.77, "lastPrice": 568, "lastSize": 4778, "bids": [ { "price": 567, "size": 87 }, { "price": 566, "size": 2454 }, { "price": 565, "size": 611 }, { "price": 564, "size": 609 }, { "price": 563, "size": 636 } ], "asks": [ { "price": 568, "size": 800 }, { "price": 569, "size": 806 }, { "price": 570, "size": 3643 }, { "price": 571, "size": 1041 }, { "price": 572, "size": 2052 } ], "total": { "tradeValue": 31019803000, "tradeVolume": 54538, "tradeVolumeAtBid": 19853, "tradeVolumeAtAsk": 27900, "transaction": 9530, "time": 1685338200000000 }, "lastTrade": { "bid": 567, "ask": 568, "price": 568, "size": 4778, "time": 1685338200000000, "serial": 6652422 }, "lastTrial": { "bid": 567, "ask": 568, "price": 568, "size": 4772, "time": 1685338196400347, "serial": 6651941 }, "isClose": true, "serial": 6652422, "lastUpdated": 1685338200000000 }, "id": "", "channel": "aggregates" } ``` --- ### Books 接收訂閱股票最新最佳五檔委買委賣資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | 股票代碼 | | `intradayOddLot` | boolean | `intradayOddLot` true: 盤中零股, false: 股票, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ---------------- | | `symbol`\* | string | 股票代碼 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `time`\* | number | 時間 | | `bids` | object\[] | 最佳五檔委買 | | >> `price` | number | 最佳五檔委買價格 | | >> `size` | number | 最佳五檔委買數量 | | `asks` | object\[] | 最佳五檔委賣 | | >> `price` | number | 最佳五檔委賣價格 | | >> `size` | number | 最佳五檔委賣數量 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'books', 'symbol': '2330' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const stock = sdk.marketdata.webSocketClient.stock; stock.connect().then(() => { stock.subscribe({ channel: "books", symbol: "2330" }); }); stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "2330", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "bids": [ { "price": 567, "size": 87 }, { "price": 566, "size": 2454 }, { "price": 565, "size": 611 }, { "price": 564, "size": 609 }, { "price": 563, "size": 636 } ], "asks": [ { "price": 568, "size": 800 }, { "price": 569, "size": 806 }, { "price": 570, "size": 3643 }, { "price": 571, "size": 1041 }, { "price": 572, "size": 2052 } ], "time": 1685338200000000 }, "id": "", "channel": "books" } ``` --- ### Candles 接收訂閱股票最新分鐘K #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | 股票代碼 | | `intradayOddLot` | boolean | `intradayOddLot` true: 盤中零股, false: 股票, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | ------ | -------------------------------------------------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `timeframe`\* | number | K線週期 | | `open`\* | number | K線開盤價 | | `high`\* | number | K線最高價 | | `low`\* | number | K線最低價 | | `close`\* | number | K線收盤價 | | `volume`\* | number | K線成交量(整股:成交張數;興櫃股票及盤中零股:成交股數;指數:成交金額) | | `average`\* | number | 成交均價 | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'candles', 'symbol': '2330' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const stock = sdk.marketdata.webSocketClient.stock; stock.connect().then(() => { stock.subscribe({ channel: "candles", symbol: "0050" }); }); stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "2330", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "date": "2023-05-29T13:30:00.000+08:00", "open": 568, "high": 568, "low": 568, "close": 568, "volume": 4778, "average": 568.77 }, "id": "", "channel": "candles" } ``` --- ### Indices 接收訂閱股票最新指數行情資料 #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'indices', 'symbol': 'IR0001' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const stock = sdk.marketdata.webSocketClient.stock; stock.connect().then(() => { stock.subscribe({ channel: 'indices', symbol: 'IR0001' }); }); stock.on('message', (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "IR0001", "type": "INDEX", "exchange": "TWSE", "index": 35276.44, "time": 1686114510000000 }, "id": "", "channel": "indices" } ``` --- ### Trades 接收訂閱股票最新成交資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | 股票代碼 | | `intradayOddLot` | boolean | `intradayOddLot` true: 盤中零股, false: 股票, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | ------- | -------------------------- | | `symbol`\* | string | 股票代號 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `time`\* | number | 時間 | | `serial`\* | number | 流水號 | | `bid` | number | 成交買價 | | `ask` | number | 成交賣價 | | `price` | number | 成交價格 | | `size` | number | 成交單量 | | `volume` | number | 成交總量 | | `isLimitDownPrice` | boolean | 最後成交價為跌停價:`true` | | `isLimitUpPrice` | boolean | 最後成交價為漲停價:`true` | | `isLimitDownBid` | boolean | 最佳一檔委買跌停價:`true` | | `isLimitUpBid` | boolean | 最佳一檔委買漲停價:`true` | | `isLimitDownAsk` | boolean | 最佳一檔委賣跌停價:`true` | | `isLimitUpAsk` | boolean | 最佳一檔委賣漲停價:`true` | | `isLimitDownHalt` | boolean | 暫緩撮合且瞬間趨跌:`true` | | `isLimitUpHalt` | boolean | 暫緩撮合且瞬間趨漲:`true` | | `isTrial` | boolean | 試撮階段:`true` | | `isDelayedOpen` | boolean | 延後開盤信號:`true` | | `isDelayedClose` | boolean | 延後收盤信號:`true` | | `isContinuous` | boolean | 最後成交為逐筆交易:`true` | | `isOpen` | boolean | 開盤信號:`true` | | `isClose` | boolean | 收盤信號:`true` | | `time` | number | 成交時間 | info '\*' 表示必揭示欄位 、 上方Boolean型態皆為發生時才會顯示 #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK def handle_message(message): print(message) sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'trades', 'symbol': '2330' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const stock = sdk.marketdata.webSocketClient.stock; stock.connect().then(() => { stock.subscribe({ channel: "trades", symbol: "0050" }); }); stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "2330", "type": "EQUITY", "exchange": "TWSE", "market": "TSE", "bid": 567, "ask": 568, "price": 568, "size": 4778, "volume": 54538, "isClose": true, "time": 1685338200000000, "serial": 6652422 }, "id": "", "channel": "trades" } ``` --- ### 開始使用 台新行情 Web API 提供開發者友善的 API 服務。您可以查詢日內行情、行情快照與歷史行情等數據。 #### 速率限制[​](#速率限制 "Direct link to 速率限制") 如果您 API 請求超過了限制,將收到帶有狀態碼 `429` 的回應。 #### 功能列表[​](#功能列表 "Direct link to 功能列表") 功能列表依資料類型可分為 **盤中行情(intraday)**、**行情快照(snapshot)**、**歷史行情(historical)**。台新行情 Web API 提供的功能如下: * `/intraday/products` - [期權契約列表(依條件查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/products.md) * `/intraday/tickers` - [期權商品列表(依條件查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/tickers.md) * `/intraday/quote/{symbol}` - [期貨即時報價(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/quote.md) * `/intraday/candles/{symbol}` - [期貨價格K線(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/candles.md) * `/intraday/trades/{symbol}` - [期貨成交明細(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/trades.md) * `/intraday/volumes/{symbol}` - [期貨分價量表(依代碼查詢)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/intraday/volumes.md) #### 使用 SDK[​](#使用-sdk "Direct link to 使用 SDK") 台新行情 Web API 提供 Python 、 Node.js SDK 。您可以透過以下方式存取 API: * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfutopt = sdk.marketdata.rest_client.futopt ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient const futopt = client.futopt; ``` --- ### Intraday Candles 期權價格K線(依商品查詢) ```text intraday/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | --------------------------------------------------------------------------------------- | | `symbol`\* | string | 期權代碼 | | `session` | string | session 類型,可選 `afterhours` 夜盤 | | `timeframe` | string | K線週期,可選 `1` 1分K;`5` 5分K;`10` 10分K;`15` 15分K;`30` 30分K;`60` 60分K | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | --------- | ----------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 期權代碼 | | `timeframe`\* | number | K線週期 | | `data`\* | object\[] | K線資料 | | >> `time` | number | K線時間 | | >> `open`\* | number | K線開盤價 | | >> `high`\* | number | K線最高價 | | >> `low`\* | number | K線最低價 | | >> `close`\* | number | K線收盤價 | | >> `volume` | number | K線成交量 | | >> `average` | number | 成交均價 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDKlinkSDKlinkSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfutopt = sdk.marketdata.rest_client.futopt restfutopt.intraday.candles(symbol='TXFA4') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.candles({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-12-15", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFA4", "timeframe": "1", "data": [ { "date": "2023-12-15T08:45:00.000+08:00", "open": 17744, "high": 17756, "low": 17744, "close": 17756, "volume": 98, "average": 17749.97 }, { "date": "2023-12-15T08:46:00.000+08:00", "open": 17755, "high": 17756, "low": 17742, "close": 17747, "volume": 48, "average": 17749.1 }, { "date": "2023-12-15T08:47:00.000+08:00", "open": 17746, "high": 17746, "low": 17731, "close": 17731, "volume": 26, "average": 17747.8 }, ... ] } ``` --- ### Products List 期權契約清單(依條件查詢) ```text intraday/products ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------------------------------- | | `type`\* | string | 類型,可選 `FUTURE` 期貨 ; `OPTION` 選擇權 | | `exchange` | string | 交易所,可選 `TAIFEX` 臺灣期貨交易所 | | `session` | string | 交易時段,可選 `REGULAR` 一般交易 或 `AFTERHOURS` 盤後交易 | | `contractType` | string | 契約類別,可選 `I` 指數類;`R` 利率類;`B` 債券類;`C` 商品類;`S` 股票類;`E` 匯率類 | | `status` | string | 契約狀態,可選 `N` 正常;`P` 暫停交易;`U` 即將上市 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | -------------------------------------------- | | `type`\* | string | 期權類型 | | `exchange` | string | 交易所 | | `session` | string | 交易時段 | | `contractType` | string | 契約類別 | | `status` | string | 契約狀態 | | `data` | object\[] | 契約列表 | | >> `symbol` | string | 契約代號 | | >> `type` | string | 期權類型 | | >> `name` | string | 契約名稱 | | >> `underlyingSymbol` | string | 股票現貨代號 | | >> `contractType` | string | 契約類別 | | >> `contractSize` | string | 契約乘數 | | >> `statusCode` | string | 狀態碼 | | >> `tradingCurrency` | string | 交易幣別 | | >> `quoteAcceptable` | boolean | 是否可報價 | | >> `startDate` | string | 上市日期 | | >> `canBlockTrade` | boolean | 是否可鉅額交易 | | >> `expiryType` | string | 到期別,`S` 標準;`W` 週 | | >> `underlyingType` | string | 股票現貨類別,`E` ETF;`S` 個股 | | >> `marketCloseGroup` | string | 商品收盤時間群組 | | >> `endSession` | string | 交易時段,`0` 一般交易時段;`1` 盤後交易時段 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfutopt = sdk.marketdata.rest_client.futopt restfutopt.intraday.products(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.products({ type: 'FUTURE', exchange:'TAIFEX', session:'REGULAR', contractType:'E'}) .then(data => console.log(data)); ``` Response Body: ```json { "type": "FUTURE", "exchange": "TAIFEX", "session": "AFTERHOURS", "contractType": "E", "data": [ { "symbol": "RHF", "type": "FUTURE_AH", "canBlockTrade": true, "contractSize": 100000, "contractType": "E", "endSession": "0", "expiryType": "S", "marketCloseGroup": 10, "name": "美元兌人民幣期貨", "quoteAcceptable": true, "startDate": "", "statusCode": "N", "tradingCurrency": "CNY", "underlyingSymbol": "", "underlyingType": "" }, { "symbol": "RTF", "type": "FUTURE_AH", "canBlockTrade": true, "contractSize": 20000, "contractType": "E", "endSession": "0", "expiryType": "S", "marketCloseGroup": 10, "name": "小型美元兌人民幣期貨", "quoteAcceptable": true, "startDate": "", "statusCode": "N", "tradingCurrency": "CNY", "underlyingSymbol": "", "underlyingType": "" }, { "symbol": "XAF", "type": "FUTURE_AH", "canBlockTrade": true, "contractSize": 25000, "contractType": "E", "endSession": "0", "expiryType": "S", "marketCloseGroup": 10, "name": "澳幣兌美元期貨", "quoteAcceptable": true, "startDate": "", "statusCode": "N", "tradingCurrency": "USD", "underlyingSymbol": "", "underlyingType": "" } ] } ``` --- ### Intraday Quote 期權即時報價(依商品代碼查詢) ```text intraday/quote/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------ | | `symbol`\* | string | 期權代碼 | | `session` | string | 交易時段,可選 `afterhours` 盤後交易 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | ------ | ---------------------------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange` | string | 交易所 | | `symbol` | string | 商品代號 | | `name` | string | 商品名稱 | | `previousClose` | number | 昨日收盤價 | | `openPrice` | number | 開盤價 | | `openTime` | number | 開盤價成交時間 | | `highPrice` | number | 最高價 | | `highTime` | number | 最高價成交時間 | | `lowPrice` | number | 最低價 | | `lowTime` | number | 最低價成交時間 | | `closePrice` | number | 收盤價(最後成交價) | | `closeTime` | number | 收盤價(最後成交價)成交時間 | | `avgPrice` | number | 當日成交均價 | | `change` | number | 最後成交價漲跌 | | `changePercnet` | number | 最後成交價漲跌幅 | | `amplitude` | number | 當日振幅 | | `lastPrice` | number | 最後一筆成交價(含試撮) | | `lastSize` | number | 最後一筆成交數量(含試撮) | | `total` | object | 統計時間 | | >> `tradeVolume` | number | 累計成交量 | | >> `tradeVolumeAtBid` | number | 累計內盤成交量 | | >> `tradeVolumeAtAsk` | number | 累計外盤成交量 | | `lastTrade` | object | 最後一筆成交資訊 | | >> `price` | number | 最後一筆成交價格 | | >> `size` | number | 最後一筆成交數量 | | >> `time` | number | 最後一筆成交時間 | | >> `serial` | number | 最後一筆成交流水號 | | `serial` | number | 流水號 | | `lastUpdated` | number | 最後異動時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfut = sdk.marketdata.rest_client.futopt restfut.intraday.quote(symbol='TXFA4') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.quote({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-12-12", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFA4", "name": "臺股期貨014", "previousClose": 17416, "openPrice": 17514, "openTime": 1702341900070000, "highPrice": 17540, "highTime": 1702342491330000, "lowPrice": 17427, "lowTime": 1702355400574000, "closePrice": 17460, "closeTime": 1702359886936000, "avgPrice": 17478.89, "change": 44, "changePercent": 0.25, "amplitude": 0.65, "lastPrice": 17460, "lastSize": 1, "total": { "tradeVolume": 1626, "totalBidMatch": 0, "totalAskMatch": 0 }, "lastTrade": { "price": 17460, "size": 1, "time": 1702359886936000, "serial": "00165753" }, "serial": 165753, "lastUpdated": 1702359886936000 } ``` --- ### Intraday Ticker 期權基本資料(依條件查詢) ```text intraday/ticker/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------------------------------------- | | `symbol`\* | string | 商品代碼 | | `session` | string | 交易時段,可選 `REGULAR` 一般交易 或 `AFTERHOURS` 盤後交易 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------- | ------ | ----------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange`\* | string | 交易所 | | `symbol`\* | string | 商品代號 | | `name`\* | string | 商品名稱 | | `referencePrice` | string | 參考價 | | `settlementDate` | string | 最後結算日 | | >> `startDate` | string | 上市日期 | | >> `endDate` | string | 下市日期 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfut = sdk.marketdata.rest_client.futopt restfut.intraday.ticker(symbol='TXFI4') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.ticker({ symbol: 'TXFI4'}) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2024-09-18", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFI4", "name": "臺股期貨094", "referencePrice": 21703, "settlementDate": "2024-09-18", "startDate": "2023-09-21", "endDate": "2024-09-18" } ``` --- ### Intraday Tickers 期權商品列表(依條件查詢) ```text intraday/tickers/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------------------------------- | | `type`\* | string | 類型,可選 `FUTURE` 期貨 ; `OPTION` 選擇權 | | `exchange` | string | 交易所,可選 `TAIFEX` 臺灣期貨交易所 | | `session` | string | 交易時段,可選 `REGULAR` 一般交易 或 `AFTERHOURS` 盤後交易 | | `product` | string | 期權商品代碼 | | `contractType` | string | 契約類別,可選 `I` 指數類;`R` 利率類;`B` 債券類;`C` 商品類;`S` 股票類;`E` 匯率類 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | -------------------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange` | string | 交易所 | | `session` | string | 交易時段 | | `contractType` | string | 契約類別 | | `data` | object\[] | 契約列表 | | >> `type` | string | 期權類型 | | >> `symbol` | string | 商品代號 | | >> `name` | string | 商品名稱 | | >> `referencePrice` | string | 參考價 | | >> `contractType` | string | 契約類別 | | >> `startDate` | string | 上市日期 | | >> `endDate` | string | 下市日期 | | >> `flowGroup` | string | 流程群組 | | >> `settlementDate` | string | 最後結算日 | | >> `isDynamicBanding` | boolean | 是否適用動態價格穩定 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfut = sdk.marketdata.rest_client.futopt restfut.intraday.tickers(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.tickers({ type: 'FUTURE', exchange:'TAIFEX', session:'REGULAR', contractType:'E'}) .then(data => console.log(data)); ``` Response Body: ```json { "type": "FUTURE", "exchange": "TAIFEX", "session": "REGULAR", "contractType": "E", "data": [ { "symbol": "RHFA4", "type": "FUTURE", "contractType": "E", "endDate": "2024-01-17", "flowGroup": 5, "isDynamicBanding": true, "name": "美元兌人民幣期貨014", "referencePrice": 7.1387, "settlementDate": "2024-01-17", "startDate": "2023-11-16" }, { "symbol": "RHFC4", "type": "FUTURE", "contractType": "E", "endDate": "2024-03-20", "flowGroup": 5, "isDynamicBanding": true, "name": "美元兌人民幣期貨034", "referencePrice": 7.108, "settlementDate": "2024-03-20", "startDate": "2023-01-31" }, { "symbol": "RHFF4", "type": "FUTURE", "contractType": "E", "endDate": "2024-06-19", "flowGroup": 5, "isDynamicBanding": true, "name": "美元兌人民幣期貨064", "referencePrice": 7.0619, "settlementDate": "2024-06-19", "startDate": "2023-04-20" }, { "symbol": "RHFI4", "type": "FUTURE", "contractType": "E", "endDate": "2024-09-19", "flowGroup": 5, "isDynamicBanding": true, "name": "美元兌人民幣期貨094", "referencePrice": 7.0189, "settlementDate": "2024-09-19", "startDate": "2023-07-20" }, { "symbol": "RHFL3", "type": "FUTURE", "contractType": "E", "endDate": "2023-12-20", "flowGroup": 5, "isDynamicBanding": true, "name": "美元兌人民幣期貨123", "referencePrice": 7.1531, "settlementDate": "2023-12-20", "startDate": "2022-10-20" }, ...... ] } ``` --- ### Intraday Trades 期權成交明細(依代碼查詢) ```text intraday/trades/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | -------------------------------- | | `symbol`\* | string | 期權代碼 | | `session` | string | 交易時段,可選 `afterhours` 夜盤 | | `offset` | number | 偏移量 | | `limit` | number | 限制量 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ----------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 商品代號 | | `data`\* | object\[] | 成交明細 | | >> `bid` | number | 成交買價 | | >> `ask` | number | 成交賣價 | | >> `price` | number | 成交價格 | | >> `size` | number | 成交單量 | | >> `time` | number | 成交時間 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfutopt = sdk.marketdata.rest_client.futopt restfutopt.intraday.trades(symbol='TXFA4') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.trades({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-12-20", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFA4", "data": [ { "price": 17660, "size": 3, "time": 1703051099834000, "serial": 218307 }, { "price": 17661, "size": 2, "time": 1703051099779000, "serial": 218304 }, { "price": 17661, "size": 1, "time": 1703051099778000, "serial": 218303 }, { "price": 17661, "size": 1, "time": 1703051099778000, "serial": 218301 }, .... ] } ``` --- ### Intraday Volumes 期權分價量表(依代碼查詢) ```text intraday/volumes/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | -------------------------------- | | `symbol`\* | string | 期權代碼 | | `session` | string | 交易時段,可選 `afterhours` 夜盤 | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | -------------------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 商品代號 | | `data` | object\[] | 分價量表 | | >> `price` | number | 成交價 | | >> `volume` | number | 該成交價之累計成交量 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 restfutopt = sdk.marketdata.rest_client.futopt restfutopt.intraday.volumes(symbol='TXFA4') ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const client = sdk.marketdata.restClient client.futopt.intraday.volumes({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` Response Body: ```json { "date": "2023-12-20", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFA4", "data": [ { "price": 17676, "volume": 68 }, { "price": 17675, "volume": 392 }, { "price": 17674, "volume": 265 }, { "price": 17673, "volume": 396 }, { "price": 17672, "volume": 430 }, { "price": 17671, "volume": 518 }, { "price": 17670, "volume": 681 }, { "price": 17669, "volume": 338 }, { "price": 17668, "volume": 395 }, { "price": 17667, "volume": 568 }, { "price": 17666, "volume": 670 }, { "price": 17665, "volume": 641 }, { "price": 17664, "volume": 542 }, { "price": 17663, "volume": 898 }, { "price": 17662, "volume": 870 }, { "price": 17661, "volume": 656 }, { "price": 17660, "volume": 876 }, { "price": 17659, "volume": 402 }, { "price": 17658, "volume": 352 }, { "price": 17657, "volume": 190 }, { "price": 17656, "volume": 470 }, .... ] } ``` --- ### 台新行情 API 即時行情資料來源為臺灣證券交易所、證券櫃檯買賣中心、臺灣期貨交易所。請您詳閱相關使用 [規範與聲明](#statement) 。 #### Web API[​](#web-api "Direct link to Web API") 台新行情 [Web API](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/http-api/getting-started.md) 提供開發者友善的 Web API 服務。您可以查詢期貨的日內行情數據。 #### WebSocket API[​](#websocket-api "Direct link to WebSocket API") 台新行情 [WebSocket API](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/websocket-api/getting-started.md) 提供台股即時行情服務。透過 WebSocket API 可以滿足您想要接收即時行情的需求。 #### 使用規範與聲明[​](#statement "Direct link to 使用規範與聲明") * 透過本服務取得之行情資料僅供參考,成交值及成交量不含零股及鉅額交易,使用者依本資料交易發生交易損失需自行負責。 * 時報資訊與群馥科技對資料內容錯誤、更新延誤或傳輸中斷不負任何責任。您應對您所為之任何金融或投資決策自行負責。 * 使用者應遵守 [臺灣證券交易所股份有限公司交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0100124) 、 [臺灣期貨交易所股份有限公司交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0101422) 、 [財團法人中華民國證券櫃檯買賣中心有價證券交易資訊使用管理辦法](http://www.selaw.com.tw/LawArticle.aspx?LawID=G0100766) 、各資訊來源提供者所定之資訊使用相關規範及智慧財產權相關法令,如有盜接、轉接交易資訊,或以其他方式出售、出租、轉讓、再授權交易資訊,或將交易資訊另行取樣並編製指數、其他衍生性商品或將之傳送予第三人,應負違約及侵權之相關民、刑事責任。 * 使用者須遵守臺灣證券交易所「 [交易資訊使用管理辦法](https://www.twse.com.tw/downloads/zh/products/regulation_use.pdf) 」等交易資訊管理相關規定,所有資訊以臺灣證券交易所公告資料為準。 * 台新行情 API 是由 [Fugle](https://www.fugle.tw/) 技術團隊開發提供。 --- ### 期貨選擇權月份代碼對照表 #### 期貨月份代碼對照表[​](#期貨月份代碼對照表 "Direct link to 期貨月份代碼對照表") | 1月 | 2月 | 3月 | 4月 | 5月 | 6月 | | --- | --- | --- | ---- | ---- | ---- | | A | B | C | D | E | F | | 7月 | 8月 | 9月 | 10月 | 11月 | 12月 | | G | H | I | J | K | L | 說明:對照表適用於期貨商品的月份代碼。例如:若要查詢大台2025年3月的期貨商品,其月份代碼為 `TXFC5`。 #### 選擇權月份代碼對照表[​](#選擇權月份��代碼對照表 "Direct link to 選擇權月份代碼對照表") Call | 1月 | 2月 | 3月 | 4月 | 5月 | 6月 | | --- | --- | --- | ---- | ---- | ---- | | A | B | C | D | E | F | | 7月 | 8月 | 9月 | 10月 | 11月 | 12月 | | G | H | I | J | K | L | Put | 1月 | 2月 | 3月 | 4月 | 5月 | 6月 | | --- | --- | --- | ---- | ---- | ---- | | M | N | O | P | Q | R | | 7月 | 8月 | 9月 | 10月 | 11月 | 12月 | | S | T | U | V | W | X | --- ### 速率限制 ##### 速率限制[​](#速率限制 "Direct link to 速率限制") 台新行情提供了Web API 與 Socket 行情,並設定了以下存取的限制 * 日內行情 : 600 / min * WebSocket : 300 訂閱數;2連線數 * 行情快照 : 600 / min * 歷史行情 : 60 / min 如果您 API 請求超過了限制,將收到帶有狀態碼 `429` 的回應。需再等候1分鐘。 ```json {"statusCode":429,"message":"Rate limit exceeded"} ``` 或是您的WebSocket 訂閱數超過上限,將收到以下訊息: ```json { "event": "error", "data": { "code": 1001, "message": "message Maximum number of connections reached" } } ``` --- ### 開始使用 台新行情 WebSocket API 提供台股即時行情服務。透過 WebSocket API 可以滿足您想要接收即時行情的需求。 #### 使用 SDK[​](#使用-sdk "Direct link to 使用 SDK") 台新行情 WebSocket API 提供 Python、Node.js,您可以透過以下方式存取 WebSocket API: 訂閱 WebSocket Callback 方法獲得下方 Callback 訊息。 * Python * Node.js ```python from taishin_sdk import TaishinSDK def handle_message(message): print(message) sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect() futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` #### 身份驗證[​](#身份驗證 "Direct link to 身份驗證") 當驗證成功後,會收到以下訊息: ```json { "event": "authenticated", "data": { "message": "Authenticated successfully" } } ``` 若驗證失敗,則收到以下訊息: ```json { "event": "error", "data": { "message": "Invalid authentication credentials" } } ``` #### Heartbeat[​](#heartbeat "Direct link to Heartbeat") 每隔 30 秒 WebSocket server 會送出一個 heartbeat 訊息: ```json { "event": "heartbeat", "data": { "time": "" } } ``` #### Ping/Pong[​](#pingpong "Direct link to Ping/Pong") SDK 每五秒將自動發送 ping 到 server 中,也可自行發送 ping,另外額外自訂 `state`(state 為 optional 參數): * Python * Node.js ```python futopt.ping({ 'state' : '' }) ``` ```js futopt.ping({state:''}); ``` WebSocket Server 會回應以下訊息 (若 ping 未送 `state` 則不會有該欄位): ```json { "event": "pong", "data": { "time": "", "state": "" } } ``` #### Channels[​](#channels "Direct link to Channels") 台新行情 WebSocket API 目前提供以下可訂閱頻道: * `trades` - [接收訂閱期權商品最新成交資訊](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/websocket-api/market-data-channels/trades.md) * `books` - [接收訂閱期權商品最新最佳五檔委買委賣資訊](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/market-data-future/websocket-api/market-data-channels/books.md) ##### 訂閱頻道[​](#訂閱頻道 "Direct link to 訂閱頻道") 要訂閱一個頻道可用下方範例進行訂閱: * Python * Node.js ```python futopt.subscribe({ "channel" : "", "symbol" : "" #"afterHours" : True 若要訂閱夜盤行情,可再額外加入此參數 }) ``` ```js futopt.subscribe({ channel: '', symbol: '', //afterHours : true 若要訂閱夜盤行情,可再額外加入此參數 }); ``` 訂閱成功後,會收到以下事件回應: ```json { "event": "subscribed", "data": { "id": "", "channel": "", "symbol": "" } } ``` 支援訂閱同頻道的多檔股票: * Python * Node.js ```python futopt.subscribe({ "channel" : "", "symbols" : ["",""] #"afterHours" : True 若要訂閱夜盤行情,可再額外加入此參數 }) ``` ```js futopt.subscribe({ channel: '', symbols: ['',''] //afterHours : true 若要訂閱夜盤行情,可再額外加入此參數 }); ``` 訂閱成功後,會收到以下事件回應: ```json { "event": "subscribed", "data": [ { "id": "", "channel": "", "symbol": "" }, { "id": "", "channel": "", "symbol": "" } ] } ``` ##### 取消訂閱[​](#取消訂閱 "Direct link to 取消訂閱") 要取消頻道可用下方範例進行取消: * Python * Node.js ```python futopt.unsubscribe({ 'id':'' }) ``` ```js futopt.unsubscribe({ id : '' }); ``` 取消訂閱成功後,會收到以下事件回應: ```json { "event": "unsubscribed", "data": { "id": "" } } ``` 支援取消訂閱多個頻道: * Python * Node.js ```python futopt.unsubscribe({ 'ids':['',''] }) ``` ```js futopt.unsubscribe({ ids : ['',''] }); ``` 取消訂閱成功後,會收到以下事件回應: ```json { "event": "unsubscribed", "data": [ { "id": "" }, { "id": "" } ] } ``` #### 錯誤處理[​](#錯誤處理 "Direct link to 錯誤處理") 當您所訂閱或處理的 WebSocket Callback 有異常時,您可補充處理錯誤訊息如下: * Python * Node.js ```python def handle_connect(): print('market data connected') def handle_disconnect(code, message): print(f'market data disconnect: {code}, {message}') def handle_error(error): print(f'market data error: {error}') futopt.on("connect", handle_connect) futopt.on("disconnect", handle_disconnect) futopt.on("error", handle_error) ``` ```js futopt.on("connect", (message) => { const connect_msg = JSON.parse(message); console.log(connect_msg); }); futopt.on("disconnect", (message) => { console.log(message); }); futopt.on("error", (message) => { const err_msg = JSON.parse(message); console.log(err_msg); }); ``` ##### 斷線重連[​](#斷線重連 "Direct link to 斷線重連") 以下將用簡單範例,利用上述定義之錯誤處理方法,接收到斷線事件,程式自動進行連線 * Python * Node.js ```python def handle_disconnect(code, message): print(f'market data disconnect: {code}, {message}') futopt.connect() print("Reconnected Succuess") print("Resubscribe") futopt.subscribe({ # 重新訂閱您已訂閱過的Channel與Symbol 'channel': '', 'symbol': '' }) ``` ```js futopt.on("disconnect", (message) => { console.log(message); futopt.connect() console.log("Reconnected Succuess"); futopt.subscribe({ channel: '', symbol: '' }); //重新訂閱您已訂閱過的Channel與Symbol }); ``` --- ### Aggregates 接收訂閱期權聚合數據的行情資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `books`, `aggregates`, `candles` | | `symbol`\* | string | 期權代碼 | | `afterHours`\* | bool | 訂閱夜盤行情 true : 夜盤行情 false : 日盤行情 default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | ------ | ---------------------------- | | `date`\* | string | 日期 | | `type`\* | string | 期權類型 | | `exchange` | string | 交易所 | | `symbol` | string | 商品代號 | | `name` | string | 商品名稱 | | `previousClose` | number | 昨日收盤價 | | `openPrice` | number | 開盤價 | | `openTime` | number | 開盤價成交時間 | | `highPrice` | number | 最高價 | | `highTime` | number | 最高價成交時間 | | `lowPrice` | number | 最低價 | | `lowTime` | number | 最低價成交時間 | | `closePrice` | number | 收盤價(最後成交價) | | `closeTime` | number | 收盤價(最後成交價)成交時間 | | `avgPrice` | number | 當日成交均價 | | `change` | number | 最後成交價漲跌 | | `changePercnet` | number | 最後成交價漲跌幅 | | `amplitude` | number | 當日振幅 | | `lastPrice` | number | 最後一筆成交價(含試撮) | | `lastSize` | number | 最後一筆成交數量(含試撮) | | `total` | object | 統計時間 | | >> `tradeVolume` | number | 累計成交量 | | >> `tradeVolumeAtBid` | number | 累計內盤成交量 | | >> `tradeVolumeAtAsk` | number | 累計外盤成交量 | | `lastTrade` | object | 最後一筆成交資訊 | | >> `price` | number | 最後一筆成交價格 | | >> `size` | number | 最後一筆成交數量 | | >> `time` | number | 最後一筆成交時間 | | >> `serial` | number | 最後一筆成交流水號 | | `serial` | number | 流水號 | | `lastUpdated` | number | 最後異動時間 | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'aggregates', 'symbol': 'TXFA4' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect().then(() => { futopt.subscribe({ channel: "aggregates", symbol: "TXFA4" }); }); futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "date": "2023-12-26", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFA4", "name": "臺股期貨014", "previousClose": 17622, "openPrice": 17651, "openTime": 1703551500020000, "highPrice": 17740, "highTime": 1703560921393000, "lowPrice": 17634, "lowTime": 1703552892448000, "closePrice": 17735, "closeTime": 1703569500075000, "avgPrice": 17700.51, "change": 113, "changePercent": 0.64, "amplitude": 0.6, "lastPrice": 17735, "lastSize": 7, "total": { "tradeVolume": 52553, "totalBidMatch": 26280, "totalAskMatch": 26273 }, "lastTrade": { "price": 17735, "size": 7, "time": 1703569500075000, "serial": "00136127" }, "serial": 136127, "lastUpdated": 1703569500075000 }, "id": "", "channel": "aggregates" } ``` --- ### Books 接收訂閱期權商品最新最佳五檔委買委賣資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `books`, `aggregates`, `candles` | | `symbol`\* | string | 契約代碼 | | `afterHours`\* | bool | 訂閱夜盤行情 true : 夜盤行情 false : 日盤行情 default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ---------------- | | `symbol`\* | string | 期權代碼 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `time`\* | number | 時間 | | `bids` | object\[] | 最佳五檔委買 | | >> `price` | number | 最佳五檔委買價格 | | >> `size` | number | 最佳五檔委買數量 | | `asks` | object\[] | 最佳五檔委賣 | | >> `price` | number | 最佳五檔委賣價格 | | >> `size` | number | 最佳五檔委賣數量 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'books', 'symbol': 'TXFA4' #'afterHours' : True # 夜盤行情 }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect().then(() => { futopt.subscribe({ channel: "books", symbol: "TXFA4" // afterHours: true //夜盤行情 }); }); futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "TXFA4", "type": "FUTURE", "exchange": "TAIFEX", "bids": [ { "price": 17539, "size": 2 }, { "price": 17538, "size": 4 }, { "price": 17537, "size": 3 }, { "price": 17536, "size": 10 }, { "price": 17535, "size": 10 } ], "asks": [ { "price": 17541, "size": 2 }, { "price": 17542, "size": 15 }, { "price": 17543, "size": 3 }, { "price": 17544, "size": 5 }, { "price": 17545, "size": 4 } ], "time": 1702956500113000 }, "id": "", "channel": "books" } ``` --- ### Candles 接收訂閱期權商品最新分鐘K #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `books`, `aggregates`, `candles` | | `symbol`\* | string | 契約代碼 | | `afterHours`\* | bool | 訂閱夜盤行情 true : 夜盤行情 false : 日盤行情 default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | ------ | -------------------------------------------------------------------------- | | `date`\* | string | 日期 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `symbol`\* | string | 股票代號 | | `timeframe`\* | number | K線週期 | | `open`\* | number | K線開盤價 | | `high`\* | number | K線最高價 | | `low`\* | number | K線最低價 | | `close`\* | number | K線收盤價 | | `volume`\* | number | K線成交量(整股:成交張數;興櫃股票及盤中零股:成交股數;指數:成交金額) | | `average`\* | number | 成交均價 | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'candles', 'symbol': 'TXFA4' }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect().then(() => { futopt.subscribe({ channel: "candles", symbol: "TXFA4" }); }); futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "TXFA4", "type": "FUTURE", "exchange": "TAIFEX", "date": "2023-12-28T12:01:00.000+08:00", "open": 17861, "high": 17862, "low": 17859, "close": 17862, "volume": 22, "average": 17820.19 }, "id": "", "channel": "candles" } ``` --- ### Trades 接收訂閱期權商品最新成交資訊 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | ------------------------------------------------------------- | | `channel`\* | string | 訂閱頻道:`trades`, `books`, `aggregates`, `candles` | | `symbol`\* | string | 期貨商品代碼 | | `afterHours`\* | bool | 訂閱夜盤行情 true : 夜盤行情 false : 日盤行情 default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | ------ | -------------- | | `symbol`\* | string | 商品代號 | | `type`\* | string | Ticker 類型 | | `exchange`\* | string | 交易所 | | `market` | string | 市場別 | | `trades` | object | 成交報價 | | >> `price` | number | 成交價格 | | >> `size` | number | 成交單量 | | >> `bid` | number | 成交買價 | | >> `ask` | number | 成交賣價 | | `total` | object | 成交量 | | >> `tradeVolume` | number | 成交總量 | | >> `totalBidMatch` | number | 累積內盤成交量 | | >> `totalAskMatch` | number | 累積外盤成交量 | | `time`\* | number | 時間 | | `serial`\* | number | 流水號 | info '\*' 表示必揭示欄位。 #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = TaishinSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime(accounts[0]) # 建立行情連線 futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'trades', 'symbol': 'TXFA4' #'afterHours' : True # 夜盤行情 }) ``` ```js const { TaishinSDK } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(accounts[0]); // 建立行情連線 const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect().then(() => { futopt.subscribe({ channel: "trades", symbol: "TXFA4" // afterHours: true //夜盤行情 }); }); futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ##### Receive data[​](#receive-data "Direct link to Receive data") ```json { "event": "data", "data": { "symbol": "TXFA4", "type": "FUTURE", "exchange": "TAIFEX", "trades": [ { "price": 17540, "size": 1, "bid": 17539, "ask": 17540 } ], "total": { "tradeVolume": 12174, "totalBidMatch": 8760, "totalAskMatch": 7907 }, "time": 1702956487023000, "serial": 159250 }, "id": "", "channel": "trades" } ``` --- ### 以 LLM 輔助 SDK 串接開發 你可以使用大型語言模型(LLMs)來協助建置 Nova 的整合。
我們提供了以下應用,協助你在開發過程中使用 LLM。 #### 純文字文件(Plain text docs)[​](#純文字文件plain-text-docs "Direct link to 純文字文件(Plain text docs)") 你可以在任何網址後方加上 `.md`,即可取得該頁面的純文字 Markdown 版本。
例如,本頁的純文字版本可於 [build-with-llm.md](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/build-with-llm) 取得。
我們提供 [llms.txt](https://ml-fugle-api.masterlink.com.tw/FugleSDK/llms.txt) 檔案,用於指引 AI 工具與代理如何取得我們頁面的純文字版本。 `/llms.txt` 是一項新興標準,旨在讓網站與內容更容易被 LLM 存取與使用。 * [llms.txt](https://ml-fugle-api.masterlink.com.tw/FugleSDK/llms.txt) * [llms-full.txt](https://ml-fugle-api.masterlink.com.tw/FugleSDK/llms-full.txt) #### Model Context Protocol(MCP)[​](#model-context-protocolmcp "Direct link to Model Context Protocol(MCP)") Nova 的 `Model Context Protocol(MCP)`定義許多應用,讓 AI Agent 能夠與 Nova 互動,並搜尋我們的 Library。
在你與 Agent 協作的過程中,它可以使用這些工具來回答問題或完成任務。 如果你正在使用 AI Agent 來協助建置 Nova 整合,請將該 Agent 連接至 MCP 伺服器。 [Nova MCP](https://github.com/fugle-dev/fugle-mcp-server) --- ### 主動回報 *** #### 訂閱委託回報[​](#訂閱委託回報 "Direct link to 訂閱委託回報") * Python * Node.js ```py # A callback to receive order data def on_order(content): print("==Order==") print(content) # print(content.seq_no) # 印出委託單流水號 print("========") sdk.set_on_order(on_order) ``` info 詳細回傳內容,可參照 [Ack Object](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#ack-object) ```js //Callback to receive order data sdk.setOnOrder(function(content) { console.log("====order===\n", content)}); ``` info 詳細回傳內容,可參照 [Ack Object](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ack-object) #### 訂閱成交回報[​](#訂閱成交回報 "Direct link to 訂閱成交回報") * Python * Node.js ```py def on_filled(content): print("==Filled==") print(content) # print(content.filled_no) # 印出成交流水號 print("========") sdk.set_on_filled(on_filled) ``` info 詳細回傳內容,可參照 [Mat Object](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/csharp/EnumMatrix#mat-object) ```js sdk.setOnFilled(function(content) { console.log("===Filled===\n",content)}) ``` info 詳細回傳內容,可參照 [Mat Object](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/csharp/EnumMatrix#mat-object) #### 訂閱範例[​](#訂閱範例 "Direct link to 訂閱範例") * Python * Node.js ```py # A callback to receive order data def on_order(content): print("==Order==") print(content) # print(content.seq_no) # 印出委託單流水號 print("========") sdk.set_on_order(on_order) def on_filled(content): print("==Filled==") print(content) # print(content.filled_no) # 印出成交流水號 print("========") sdk.set_on_filled(on_filled) sdk.connect_websocket() # 啟動訂閱 ``` ```js //Callback to receive order data sdk.setOnOrder(function(content) { console.log("====order===\n", content)}); sdk.setOnFilled(function(content) { console.log("===Filled===\n",content)}) sdk.connectWebsocket(); // 啟動訂閱 ``` --- ### 交易 *** 此篇教學將示範如何進行一個完整的買賣流程 #### 買入股票[​](#買入股票 "Direct link to 買入股票") 假設今天開盤後,我們想以 11.50 元買進 2 張台新金,我們可以這樣撰寫程式並執行: * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order, BSAction, TimeInForce, OrderType, PriceType, MarketType sdk = TaishinSDK() #若有開多帳號,則會回傳資訊 accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") #建立委託單內容 order = Order( buy_sell = BSAction.Buy, symbol = "2887", price = "11.5", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force= TimeInForce.ROD, order_type = OrderType.Stock ) sdk.stock.place_order(accounts[0], order) #下單委託 ``` info 整股與零股之委託,請參考各語言 Library [Python Libary](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#markettype) ```js const { TaishinSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證路徑", "您的憑證密碼"); const order = { buySell: BSAction.Buy, symbol: "2887", price: "11.5", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock }; sdk.stock.placeOrder(accounts[0],order); ``` info 整股與零股之委託,請參考各語言 Library [Node.Js Libary](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) #### 確認委託與成交回報[​](#確認委託與成交回報 "Direct link to 確認委託與成交回報") 若要確定該筆的狀態,可以依照下方範例查詢指定的委託單: * Python * Node.js ```python orderResults = sdk.stock.get_order_results(accounts[0]) print(orderResults) ``` ```js const orderResults = sdk.stock.getOrderResults(accounts[0]) console.log(orderResults) ``` 根據回報的結果,我們可以判斷此筆委託是否成交,成交了多少數量: * Python * Node.js ```py OrderRecord { ... org_qty: 2000, # 原始下單股數 (Int) filled_qty: 0, # 已成交數量 (Int) cel_qty: 0, # 已取消數量 (Int) can_cancel: false, # 是否可取消 (Boolean) err_code: "000000", # 錯誤代碼 (String) err_msg: "", # 錯誤訊息 (String) seq_no: "10000043", # 流水號 (String) is_pre_order: false, # 是否預約單 (Boolean) pre_order_no: "", # 預約單號碼 (String) avg_price: , # 平均成交價格 (Double) ... } ``` ```js { ... orgQty: 2000, // 原始下單股數 (Int) filledQty: 0, // 已成交數量 (Int) celQty: 0, // 已取消數量 (Int) canCancel: false, // 是否可取消 (Boolean) errCode: "000000", // 錯誤代碼 (String) errMsg: "", // 錯誤訊息 (String) seqNo: "10000043", // 流水號 (String) isPreOrder: false, // 是否預約單 (Boolean) preOrderNo: "", // 預約單號碼 (String) avgPrice: , // 平均成交價格 (Double) ... } ``` #### 修改委託價格[​](#修改委託價格 "Direct link to 修改委託價格") 由於原先的價格一直無法成交,我們調整原先的委託價格,改用12.00元的價格買入: * Python * Node.js ```python orderResults = sdk.stock.get_order_results(accounts[0]) sdk.stock.modify_price(accounts[0], orderResults[0],"12", PriceType.Limit) ``` ```js orderResults = sdk.stock.getOrderResults(accounts[0]) sdk.stock.modifyPrice(accounts[0],orderResults[0],"12", PriceType.Limit) ``` 幾分鐘後,我們再查詢一次委託狀態,發現成交了: * Python * Node.js ```python orderResults = sdk.stock.get_order_results(accounts[0]) print(orderResults[0]) ``` ```py [ OrderRecord { ... org_qty: 2000, # 原始下單股數 (Int) filled_qty: 2000, # 已成交數量 (Int) cel_qty: 0, # 已取消數量 (Int) can_cancel: false, # 是否可取消 (Boolean) err_code: "000000", # 錯誤代碼 (String) err_msg: "", # 錯誤訊息 (String) seq_no: "10000043", # 流水號 (String) is_pre_order: false, # 是否預約單 (Boolean) pre_order_no: "", # 預約單號碼 (String) avg_price: 12.00 , # 平均成交價格 (Double) ... } ] ``` ```js orderResults = sdk.stock.getOrderResults(accounts[0]) console.log(orderResults[0]) ``` ```js { ... orgQty: 2000, // 原始下單股數 (Int) filledQty: 2000, // 已成交數量 (Int) celQty: 0, // 已取消數量 (Int) canCancel: false, // 是否可取消 (Boolean) errCode: "000000", // 錯誤代碼 (String) errMsg: "", // 錯誤訊息 (String) seqNo: "10000043", // 流水號 (String) isPreOrder: false, // 是否預約單 (Boolean) preOrderNo: "", // 預約單號碼 (String) avgPrice: 12.00, // 平均成交價格 (Double) ... } ``` #### 賣出股票[​](#賣出股票 "Direct link to 賣出股票") info 請先確認是否有當沖權限,在 `Account` 物件中當沖權限欄位可得知 最後決定在收盤前,賣出一張台新金: * Python * Node.js ```python #建立委託單內容 order = Order( buy_sell = BSAction.Sell, symbol = "2887", price = "12.5", quantity = 1000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force= TimeInForce.ROD, order_type = OrderType.Stock ) sdk.stock.place_order(accounts[0], order) #下單委託 ``` ```js order = { buySell: BSAction.Sell, symbol: "2887", price: "12.5", quantity: 1000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock }; sdk.stock.placeOrder(accounts[0],order) ``` --- ### Nova API *** Nova API 是專為程式交易與量化交易設計的台股 API 解決方案,由 Fugle 技術團隊攜手台新證券共同打造。提供跨平台 SDK (Windows / Mac / Linux),支援台灣股票市場的自動交易,讓您的股票交易策略快速上線。適用於台股交易 API 串接、演算法交易、高頻交易等多種應用場景。 --- ### 錯誤代碼 > 錯誤訊息範例 ```json { "code": "5001", "message": "查無資料" } ``` #### 錯誤代碼表[​](#錯誤代碼表 "Direct link to 錯誤代碼表") info 以下為可能遇到之錯誤代碼提供參考 ##### 權限檢核錯誤代碼[​](#權限檢核錯誤代碼 "Direct link to 權限檢核錯誤代碼") | 代碼 | 說明 | | ------ | ----------------------- | | A00007 | 尚未完成 API 簽署與認證 | ##### 登入錯誤代碼[​](#登入錯誤代碼 "Direct link to 登入錯誤代碼") | 代碼 | 說明 | 意義 | | ------ | --------------------------- | ------------------------------------------------------------------ | | CO-001 | 系統啟動時,初始化失敗. | 發生非預期錯誤,請嘗試重新登入,或洽富果客服。 | | CO-002 | 系統執行時發生內部錯誤. | 發生非預期錯誤,請嘗試重新登入,或洽富果客服。 | | 01-000 | 查無帳號. | 帳號或密碼錯誤,請確認後重新輸入。 | | 01-001 | 帳號無登入權限. | 帳號或密碼錯誤,請確認後重新輸入。 | | 01-002 | 帳號權限錯誤, 請洽客服人員. | 帳號或密碼錯誤,請確認後重新輸入。 | | 01-010 | 密碼錯誤1次. | 帳號或密碼錯誤,請確認後重新輸入。 | | 01-011 | 密碼錯誤2次. | 帳號或密碼錯誤,請確認後重新輸入。 | | 01-012 | 密碼錯誤3次, 帳號鎖定. | 密碼錯誤次數已達上限,請至密碼專區「解鎖」或「補發」後再重新登入。 | | 01-020 | 帳號鎖定. | 密碼錯誤次數已達上限,請至密碼專區「解鎖」或「補發」後再重新登入。 | | AO-101 | 建立帳號失敗. | 發生非預期錯誤,請嘗試重新登入,或洽富果客服。 | | AO-102 | 帳號不存在. | 帳號或密碼錯誤,請確認後重新輸入。 | | AO-108 | 使用者不存在. | 帳號或密碼錯誤,請確認後重新輸入。 | ##### 交易錯誤代碼[​](#交易錯誤代碼 "Direct link to 交易錯誤代碼") | 代碼 | 說明 | | ------ | --------------------------- | | 000008 | 後台系統或交易所回應Timeout | | 000013 | 後台錯誤 ( 包含錯誤原因 ) | | 000017 | 非交易接單時段 | ##### 帳務錯誤代碼[​](#帳務錯誤代碼 "Direct link to 帳務錯誤代碼") | 代碼 | 說明 | | ---- | -------------------------------------------------------------------------------------------------------- | | 0001 | 資料庫錯誤 | | 0006 | 查詢參數錯誤 | | 0007 | 伺服器錯誤 | | 1000 | 查無帳號 | | 1001 | 帳號無登入權限 | | 1003 | 多帳號查詢驗證失敗 | | 5000 | 錯誤不在定義的代號中 | | 5001 | 查無資料 | | 5003 | 系統資料查詢錯誤 | | 6035 | 格式資料查詢錯誤 | | 6045 | 今日已結帳完成,「當日已實現損益」、「現股當沖損益」、「信用當沖損益」等資料請改至歷史已實現損益功能查詢 | | 8002 | 非預期的例外錯誤 | | 9906 | 當日結帳轉檔中,請您稍後查詢 | --- ### 對帳單查詢 accountStatement #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | String | 查詢起始日期 ( YYYYMMDD ) | | end\_date | String | 查尋迄日 ( YYYYMMDD ) | | symbol | String ( Optional ) | 股票代號 | #### 未實現 StatementResponse 欄位[​](#未實現-statementresponse--欄位 "Direct link to 未實現 StatementResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------------------------------- | ------ | -------------- | | income | String | 賣出 | | cost | String | 買入 | | netAmount | String | 收付淨額 | | fee | String | 手續費 | | tax | String | 交易稅 | | marginShortDayTradingProfitLoss | String | 融券當沖損益 | | commonStockDayTradingProfitLoss | None | 普通股當沖損益 | | securitiesIncomeTax | String | 證券所得稅 | | healthInsuranceFee | String | 健保費 | | filledQuantity | String | 成交股數 | | interest | String | 利息 | | shortSellingFee | String | 融券費 | | filledAmount | String | 成交金額 | | paymentGrossTotal | String | 付款總額 | | profitLoss | String | 損益 | | creditDebitNetAmount | String | 信用貸款淨額 | | securitiesLendingDifferentialFee | String | 證券借貸價差費 | | accountSummary | Object | 帳戶摘要 | | └─ marginPositionMarketValueSum | String | 融資市值總計 | | └─ shortPositionMarketValueSum | String | 融券市值總計 | | └─ shortCollateralSum | String | 融券擔保品總計 | | └─ marginLimit | String | 融資限額 | | └─ shortLimit | String | 融券限額 | | └─ guaranteeAmountSum | String | 保證金總計 | | └─ marginAmountSum | String | 融資金額總計 | | └─ shortAmountSum | String | 融券金額總計 | | └─ accountMaintenanceRate | String | 帳戶維持率 | | └─ settlementToday | String | 今日結算金額 | | └─ settlementYesterday | String | 昨日結算金額 | | └─ settlementNet | String | 結算淨額 | | billSummary | Object | 帳單摘要 | | └─ commonStockBuyAmount | String | 普通股買入金額 | | └─ commonStockSellAmount | String | 普通股賣出金額 | | └─ commonStockFee | String | 普通股手續費 | | └─ commonStockTax | String | 普通股稅金 | | └─ commonStockStInTax | String | 普通股證交稅 | | └─ commonStockNetAmount | String | 普通股淨額 | | └─ ownFundsAmount | String | 自有資金金額 | | └─ marginAmount | String | 融資金額 | | └─ marginFee | String | 融資手續費 | | └─ marginInterest | String | 融資利息 | | └─ marginTax | String | 融資稅金 | | └─ marginSecuritiesIncomeTax | String | 融資證券所得稅 | | └─ marginNetAmount | String | 融資淨額 | | └─ guaranteeAmount | String | 保證金金額 | | └─ shortCollateral | String | 融券擔保品 | | └─ shortFee | String | 融券手續費 | | └─ shortInterest | String | 融券利息 | | └─ shortHealthInsuranceFee | String | 融券健保費 | | └─ shortNetAmount | String | 融券淨額 | | └─ profitLoss | String | 損益 | | └─ buyQuantity | String | 買進股數 | | └─ sellQuantity | String | 賣出股數 | | └─ netAmount | String | 淨額 | | └─ securitiesLendingDifferentialFee | String | 證券借貸價差費 | | filledRecords | list | 成交資訊 | | └─ branchId | String | 分公司代號 | | └─ custId | String | 帳號 | | └─ name | String | 姓名 | | └─ symbol | String | 股票代號 | | └─ symbolName | String | 股票名 | | └─ filledDate | String | 成交日期 | | └─ orderNo | String | 委託書號 | | └─ filledNo | String | 成交序號 | | └─ orderType | String | 委託別 | | └─ orderTypeName | String | 委託別名稱 | | └─ buySell | String | 買賣別 | | └─ buySellName | String | 買賣別名稱 | | └─ marketType | String | 盤別 | | └─ filledPrice | String | 成交價 | | └─ filledQty | String | 成交股數 | | └─ filledAmount | String | 成交值 | | └─ tax | String | 交易稅 | | └─ fee | String | 手續費 | | └─ interest | String | 利息 | | └─ reverseInterest | String | 融券利息 | | └─ marginAmount | String | 信用金額 | | └─ shortAmount | String | 借貸金額 | | └─ shortCollateral | String | 擔保品 | | └─ guaranteeAmount | String | 融券保證金 | | └─ shortSellingFee | String | 融券手續費 | | └─ income | String | 淨收金額 | | └─ cost | String | 淨付金額 | | └─ securitiesLendingFee | String | 標借費 | | └─ netAmount | String | 預估淨額 | | └─ ownFundsAmount | String | 自備款 | | └─ profitLoss | String | 損益 | | └─ securitiesTransactionIncomeTax | String | 證所稅 | | └─ healthInsuranceFee | String | 健保補充費 | | └─ isDayTrade | String | 是否為當沖 | | └─ securitiesLendingDifferentialFee | String | 證券借貸價差費 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.accountStatement(account,"20241101","20241201") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { income: "0", // 賣出 (String) cost: "0", // 買入 (String) netAmount: "0", // 收付淨額 (String) fee: "0", // 手續費 (String) tax: "0", // 交易稅 (String) marginShortDayTradingProfitLoss: "0", // 融券當沖損益 (String) commonStockDayTradingProfitLoss: null, // 普通股當沖損益 (String) securitiesIncomeTax: "0", // 證券所得稅 (String) healthInsuranceFee: "0", // 健保費 (String) filledQuantity: "0", // 成交股數 (String) interest: "0", // 利息 (String) shortSellingFee: "0", // 融券費 (String) filledAmount: "0", // 成交金額 (String) paymentGrossTotal: "0", // 付款總額 (String) profitLoss: "0", // 損益 (String) creditDebitNetAmount: "0", // 信用貸款淨額 (String) securitiesLendingDifferentialFee: "0", // 證券借貸價差費 (String) accountSummary: { marginPositionMarketValueSum: "0", // 融資持倉市值總計 (String) shortPositionMarketValueSum: "0", // 融券持倉市值總計 (String) shortCollateralSum: "0", // 融券擔保品總計 (String) marginLimit: "0", // 融資限額 (String) shortLimit: "0", // 融券限額 (String) guaranteeAmountSum: "0", // 保證金總計 (String) marginAmountSum: "0", // 融資金額總計 (String) shortAmountSum: "0", // 融券金額總計 (String) accountMaintenanceRate: "", // 帳戶維持率 (String) settlementToday: "0", // 今日結算金額 (String) settlementYesterday: "0", // 昨日結算金額 (String) settlementNet: "0", // 結算淨額 (String) }, billSummary: { commonStockBuyAmount: "0", // 普通股買入金額 (String) commonStockSellAmount: "0", // 普通股賣出金額 (String) commonStockFee: "0", // 普通股手續費 (String) commonStockTax: "0", // 普通股稅金 (String) commonStockStInTax: "0", // 普通股證交稅 (String) commonStockNetAmount: "0", // 普通股淨額 (String) ownFundsAmount: "0", // 自有資金金額 (String) marginAmount: "0", // 融資金額 (String) marginFee: "0", // 融資手續費 (String) marginInterest: "0", // 融資利息 (String) marginTax: "0", // 融資稅金 (String) marginSecuritiesIncomeTax: "0", // 融資證券所得稅 (String) marginNetAmount: "0", // 融資淨額 (String) guaranteeAmount: "0", // 保證金金額 (String) shortCollateral: "0", // 融券擔保品 (String) shortFee: "0", // 融券手續費 (String) shortInterest: "0", // 融券利息 (String) shortHealthInsuranceFee: "0", // 融券健保費 (String) shortNetAmount: "0", // 融券淨額 (String) profitLoss: "0", // 損益 (String) buyQuantity: "0", // 買進股數 (String) sellQuantity: "0", // 賣出股數 (String) netAmount: "0", // 淨額 (String) securitiesLendingDifferentialFee: "0", // 證券借貸價差費 (String) }, filledRecords: [ { branchId: "592a", // 分公司代號 (String) custId: "0456125", // 帳號 (String) name: "xxx", // 姓名 (String) symbol: "3231", // 股票代號 (String) symbolName: "緯創", // 股票名 (String) filledDate: "20241119", // 成交日期 (String) orderNo: "i9294", // 委託書號 (String) filledNo: "0000004", // 成交序號 (String) orderType: "0", // 委託別 (String) orderTypeName: "現買", // 委託別名稱 (String) buySell: "B", // 買賣別 (String) buySellName: "買", // 買賣別名稱 (String) marketType: "0", // 盤別 (String) filledPrice: "113.5000", // 成交價 (String) filledQty: "1000", // 成交股數 (String) filledAmount: "113500", // 成交值 (String) tax: "0", // 交易稅 (String) fee: "161", // 手續費 (String) interest: "0", // 利息 (String) reverseInterest: "0", // 融券利息 (String) marginAmount: "0", // 信用金額 (String) shortAmount: "0", // 借貸金額 (String) shortCollateral: "0", // 擔保品 (String) guaranteeAmount: "0", // 融券保證金 (String) shortSellingFee: "0", // 融券手續費 (String) income: "0", // 淨收金額 (String) cost: "0", // 淨付金額 (String) securitiesLendingFee: "0", // 標借費 (String) netAmount: "-113661", // 預估淨額 (String) ownFundsAmount: "0", // 自備款 (String) profitLoss: "0", // 損益 (String) securitiesTransactionIncomeTax: "0", // 證所稅 (String) healthInsuranceFee: "0", // 健保補充費 (String) isDayTrade: "N", // 是否為當沖 (String) securitiesLendingDifferentialFee: "0", // 證券借貸價差費 (String) }, ... ] } ``` --- ### 帳戶損益速查 accountTotalPnl #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | #### 帳戶損益速查 AccountQuickInquiryResponse 欄位[​](#帳戶損益速查-accountquickinquiryresponse--欄位 "Direct link to 帳戶損益速查 AccountQuickInquiryResponse 欄位") | 參數 | 類別 | 說明 | | -------------------------------- | ------ | ------------------ | | unrealizedProfitLossCash | String | 未實現損益(現股) | | unrealizedProfitLossMargin | String | 未實現損益(融資) | | unrealizedProfitLossShortSelling | String | 未實現損益(融券) | | unrealizedProfitLossTotal | String | 未實現損益總計 | | realizedProfitLossCash | String | 已實現損益(現股) | | realizedProfitLossMargin | String | 已實現損益(融資) | | realizedProfitLossShortSelling | String | 已實現損益(融券) | | realizedProfitLossTotal | String | 已實現損益總計 | | dayTradingProfitLossCredit | String | 當沖損益(信用) | | dayTradingProfitLossCash | String | 當沖損益(現股) | | netAmount | String | 淨收付金額 | | accountMaintenanceRate | string | 整戶維持率 | | totalProfitLossCash | String | 總損益(現股) | | totalProfitLossMargin | String | 總損益(融資) | | totalProfitLossShortSelling | String | 總損益(融券) | | totalProfitLoss | String | 總損益 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.accountTotalPnl(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { unrealizedProfitLossCash: "85293", // 未實現損益(現股) (string) unrealizedProfitLossMargin: "0", // 未實現損益(融資) (string) unrealizedProfitLossShortSelling: "0", // 未實現損益(融券) (string) unrealizedProfitLossTotal: "85293", // 未實現損益總計 (string) realizedProfitLossCash: "0", // 已實現損益(現股) (string) realizedProfitLossMargin: "0", // 已實現損益(融資) (string) realizedProfitLossShortSelling: "0", // 已實現損益(融券) (string) realizedProfitLossTotal: "0", // 已實現損益總計 (string) dayTradingProfitLossCredit: "0", // 當沖損益(信用) (string) dayTradingProfitLossCash: "0", // 當沖損益(現股) (string) netAmount: "-2904132", // 淨收付金額 (string) accountMaintenanceRate: null, // 整戶維持率 (string) totalProfitLossCash: "85293", // 總損益(現股) (string) totalProfitLossMargin: "0", // 總損益(融資) (string) totalProfitLossShortSelling: "0", // 總損益(融券) (string) totalProfitLoss: "85293", // 總損益 (string) } ``` --- ### 分戶帳銀行餘額查詢 info 如是約定新光銀交割,請用 [新光銀餘額查詢](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/accountManagement/SkBankBalance) bankBalance #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 餘額 Bankbalace 欄位[​](#餘額-bankbalace-欄位 "Direct link to 餘額 Bankbalace 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------------------- | ------ | ------------ | | availableBalance | number | 可用餘額 | | reservedAmount | number | 圈存金額 | | dedicatedAccountBalance | number | 專戶餘額 | | withdrawalBankCode | string | 出金銀行代號 | | withdrawalBank | string | 出金銀行名稱 | | withdrawalAccount | string | 出金銀行帳號 | | depositBankCode | string | 入金銀行代號 | | depositAccount | string | 入金銀行帳號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.bankBalance(accounts[0]) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { availableBalance: 7015.00, // 可用餘額 (number) reservedAmount: 2041.00, // 圈存金額 (number) dedicatedAccountBalance: 9056.00, // 專戶餘額 (number) withdrawalBankCode: "803", // 出金銀行代號 (string) withdrawalBank: "聯邦", // 出金銀行名稱 (string) withdrawalAccount: "046508006075", // 出金銀行帳號 (string) depositBankCode: "1030851", // 入金銀行代號 (string) depositAccount: "89600221676687" // 入金銀行帳號 (string) } ``` --- ### 庫存與未實現損益查詢 inventories #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | #### PositionResponse 欄位[​](#positionresponse--欄位 "Direct link to PositionResponse 欄位") | 參數 | 類別 | 說明 | | ------------------------------- | ------ | --------------------------------------------------------------- | | no | string | 序號 | | prevDayQuantity | string | 昨日庫存股數 | | currentQuantity | string | 即時庫存股數 | | todayQuantity | string | 今日增減成交股數 | | todayBuyQuantity | string | 今日買進成交數量 | | todaySellQuantity | string | 今日賣出成交數量 | | cost | string | 付出成本 | | marketValue | string | 現值 | | unrealizedProfitLoss | string | 未實現損益 | | unrealizedProfitLossRate | string | 未實現損益率 | | securitiesTransactionIncomeTax | string | 證券交易所得稅 | | healthInsuranceFee | string | 健保補充費 | | fee | string | 手續費 | | tax | string | 交易稅 | | openMarginAmount | string | 未償還融資/券金額 | | openGuaranteeAmount | string | 未償還融券保證金 | | openShortCollateral | string | 未償還擔保品 | | shortSellingFee | string | 融券手續費 | | ownFundsAmount | string | 自備款 | | otherCost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | interest | string | 利息 | | unrealizedNetAmount | string | 預估淨收付 | | totalProfitLoss | string | 總損益 | | realizedProfitLoss | string | 當日已實現損益 | | dividendAmount | string | 除息金額 | | **accountSummary** | object | 帳戶摘要 | | └─ marginPositionMarketValueSum | string | 融資市值加總 | | └─ shortPositionMarketValueSum | string | 融券市值加總 | | └─ shortCollateralSum | string | 融券擔保品加總 | | └─ marginLimit | string | 融資限額 | | └─ shortLimit | string | 融券限額 | | └─ guaranteeAmountSum | string | 擔保金總和 | | └─ marginAmountSum | string | 融資金額總和 | | └─ shortAmountSum | string | 融券金額總和 | | └─ accountMaintenanceRate | string | 帳戶維持率 | | └─ settlementToday | string | 今日交割 | | └─ settlementYesterday | string | 昨日交割 | | └─ settlementNet | string | 淨交割金額 | | **positionSummaries** | array | 持倉摘要清單 | | └─ branchId | string | 分公司代號 | | └─ custId | string | 帳號 | | └─ no | string | 序號 | | └─ symbol | string | 股票代碼 | | └─ name | string | 用戶名 | | └─ symbolName | string | 股票名稱 | | └─ stockEvaluation | string | 股票評價 | | └─ orderType | string | 交易類型 | | └─ orderTypeName | string | 交易類型名稱 | | └─ buySell | string | 買賣別 : `Buy`、`Sell` | | └─ prevDayQuantity | string | 昨日庫存股數 | | └─ currentQuantity | string | 即時庫存股數 | | └─ totalQuantity | string | 今日交易增減成交股數 | | └─ totalBuyQuantity | string | 今日買進成交股數 | | └─ totalSellQuantity | string | 今日賣出成交股數 | | └─ cost | string | 成本 | | └─ costBeforeDividend | string | 成本 (不扣除息金額) | | └─ averagePrice | string | 成交均價 | | └─ openMarginAmount | string | 未償還融資金額 | | └─ guaranteeAmount | string | 保證金 | | └─ openGuaranteeAmount | string | 未償還融券保證金 | | └─ shortCollateral | string | 擔保品 | | └─ openShortCollateral | string | 未償還擔保品 | | └─ shortSellingFee | string | 融券手續費 | | └─ ownFundsAmount | string | 自備款 | | └─ guaranteeDefaultAmount | string | 擔保金缺額 | | └─ currentPrice | string | 現價 | | └─ marketValue | string | 市值 | | └─ unrealizedProfitLoss | string | 未實現損益 | | └─ unrealizedProfitLossRate | string | 未實現損益率 | | └─ fee | string | 手續費 | | └─ tax | string | 稅金 | | └─ interest | string | 利息 | | └─ otherCost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | └─ unrealizedNetAmount | string | 預估淨收付金額 | | └─ targetPrice | string | 標的股票現價 | | └─ portfolioType | string | 權證種類 :`1` 認購權證 | | └─ holdingPercent | string | 持有比率 | | └─ securitiesIncomeTax | string | 證券所得稅 | | └─ healthInsuranceFee | string | 健保補充費 | | └─ referencePrice | string | 參考價格 | | └─ totalProfit | string | 總損益 | | └─ realizedProfit | string | 當日已實現損益 | | └─ pledgeQuantity | string | 質押數量 | | └─ amount | string | 會總成交價金 | | └─ averageFilledPrice | string | 平均成交價格 | | └─ breakEvenPrice | string | 損益兩平價格 | | └─ dividendAmount | string | 股利金額 | | └─ **positionDetails** | array | 持倉明細 | |   └─ no | string | 序號 | |   └─ tDate | string | 成交日期 | |   └─ orderType | string | 交易類型 | |   └─ orderTypeName | string | 訂單類型名稱 | |   └─ buySell | string | 買賣別 : `Buy`、`Sell` | |   └─ orderNo | string | 委託書號 | |   └─ filledNo | string | 成交序號 | |   └─ filledQuantity | string | 成交數量 | |   └─ prevDayQuantity | string | 昨日庫存股數 | |   └─ filledPrice | string | 成交價格 | |   └─ filledAmount | string | 成交金額 | |   └─ currentPrice | string | 現價 | |   └─ marketValue | string | 市值 | |   └─ marginAmount | string | 融資金額 | |   └─ openMarginAmount | string | 未償還融資/券金額 | |   └─ shortCollateral | string | 融券抵押品 | |   └─ openShortCollateral | string | 未償還擔保品 | |   └─ guaranteeAmount | string | 保證金 | |   └─ openGuaranteeAmount | string | 未償還融券保證金 | |   └─ securitiesLendingFee | string | 標借費 | |   └─ shortSellingFee | string | 融券費手續費 | |   └─ fee | string | 手續費 | |   └─ tax | string | 交易稅 | |   └─ interest | string | 利息 | |   └─ cost | string | 收付金額 | |   └─ costBeforeDividend | string | 收付金額(不扣除息金額) | |   └─ changeType | string | 異動別 | |   └─ ownFundsAmount | string | 自備款 | |   └─ portfolioType | string | 權證種類 | |   └─ custId | string | 帳號 | |   └─ name | string | 名稱 | |   └─ branchId | string | 分行 ID | |   └─ otherCost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ isAdjustable | string | 是否可調整成本:`Y`開放、`N`不開放 | |   └─ securitiesIncomeTax | string | 證券所得稅 | |   └─ healthInsuranceFee | string | 健康保險費 | |   └─ unrealizedProfitLoss | string | 未實現損益 | |   └─ referencePrice | string | 參考價格 | |   └─ ioFlag | string | 異動代碼 | |   └─ ioName | string | 異動名稱 | |   └─ breakEvenPrice | string | 損益兩平價格 | |   └─ dividendAmount | string | 股利金額 | |   └─ guaranteeDefaultAmount | string | 擔保金缺額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.inventories(accounts) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { no: "合計", // 序號 (string) prevDayQuantity: "26796", // 昨日庫存股數 (string) currentQuantity: "26796", // 即時庫存股數 (string) todayQuantity: "0", // 今日增減成交股數 (string) todayBuyQuantity: "0", // 今日買進成交數量 (string) todaySellQuantity: "0", // 今日賣出成交數量 (string) cost: "348817", // 付出成本 (string) marketValue: "549957", // 現值 (string) unrealizedProfitLoss: "198916", // 未實現損益 (string) unrealizedProfitLossRate: "57.03%", // 未實現損益率 (string) securitiesTransactionIncomeTax: "0", // 證券交易所得稅 (string) healthInsuranceFee: "0", // 健保補充費 (string) fee: "489", // 手續費 (string) tax: "0", // 交易稅 (string) openMarginAmount: "0", // 未償還融資/券金額 (string) openGuaranteeAmount: "0", // 未償還融券保證金 (string) openShortCollateral: "0", // 未償還擔保品 (string) shortSellingFee: "0", // 融券手續費 (string) ownFundsAmount: "0", // 自備款 (string) otherCost: "0", // 其他費用 (string) interest: "0", // 利息 (string) unrealizedNetAmount: "547733", // 預估淨收付 (string) totalProfitLoss: "198916.00", // 總損益 (string) realizedProfitLoss: "0", // 當日已實現損益 (string) dividendAmount: "360.00", // 除息金額 (string) AccountSummary { marginPositionMarketValueSum: "0", // 融資市值加總 (string) shortPositionMarketValueSum: "0", // 融券市值加總 (string) shortCollateralSum: "0", // 融券擔保品加總 (string) marginLimit: "0", // 融資限額 (string) shortLimit: "0", // 融券限額 (string) guaranteeAmountSum: "0", // 擔保金總和 (string) marginAmountSum: "0", // 融資金額總和 (string) shortAmountSum: "0", // 融券金額總和 (string) accountMaintenanceRate: "0%", // 帳戶維持率 (string) settlementToday: "0", // 今日交割 (string) settlementYesterday: "0", // 昨日交割 (string) settlementNet: "0", // 淨交割金額 (string) }, positionSummaries: [ { branchId: "5920", // 分公司代號 (string) custId: "1234567", // 帳號 (string) no: "1", // 序號 (string) symbol: "00885", // 股票代碼 (string) name: "許OO", // 用戶名 (string) symbolName: "富邦越南", // 股票名稱 (string) stockEvaluation: "", // 股票評價 (string) orderType: "0", // 交易類型 (string) orderTypeName: "現買", // 交易類型名稱 (string) buySell: "B", // 買賣別 (string) prevDayQuantity: "1000", // 昨日庫存股數 (string) currentQuantity: "1000", // 即時庫存股數 (string) totalQuantity: "0", // 今日交易增減成交股數 (string) totalBuyQuantity: "0", // 今日買進成交股數 (string) totalSellQuantity: "0", // 今日賣出成交股數 (string) cost: "16173", // 成本 (string) costBeforeDividend: "16173.00", // 成本 (不扣除息金額) (string) averagePrice: "16.17", // 成交均價 (string) openMarginAmount: "0", // 未償還融資金額 (string) guaranteeAmount: "0", // 保證金 (string) openGuaranteeAmount: "0", // 未償還融券保證金 (string) shortCollateral: "0", // 擔保品 (string) openShortCollateral: "0", // 未償還擔保品 (string) shortSellingFee: "0", // 融券手續費 (string) ownFundsAmount: "0", // 自備款 (string) guaranteeDefaultAmount: "0", // 擔保金缺額 (string) currentPrice: "11.7", // 現價 (string) marketValue: "11700", // 市值 (string) unrealizedProfit: null, // 未實現損益 (null) unrealizedProfitLossRate: "-27.85%", // 未實現損益率 (string) fee: "23", // 手續費 (string) tax: "0", // 稅金 (string) interest: "0", // 利息 (string) otherCost: "0", // 其他成本 (string) unrealizedNetAmount: "11669", // 預估淨收付金額 (string) targetPrice: "0", // 標的股票現價 (string) portfolioType: "", // 權證種類 (string) holdingPercent: "2.13%", // 持有比率 (string) securitiesIncomeTax: "0", // 證券所得稅 (string) healthInsuranceFee: "0", // 健保補充費 (string) referencePrice: "0", // 參考價格 (string) totalProfit: "-4504.00", // 總損益 (string) realizedProfit: "0", // 當日已實現損益 (string) pledgeQuantity: "1000", // 質押數量 (string) amount: "16150.00", // 會總成交價金 (string) averageFilledPrice: "16.15", // 平均成交價格 (string) breakEvenPrice: "16.22", // 損益兩平價格 (string) dividendAmount: "0", // 股利金額 (string) positionDetails: [ { no: "1", // 序號 (string) tDate: "20210419", // 成交日期 (string) orderType: "0", // 交易類型 (string) orderTypeName: "現買", // 訂單類型名稱 (string) buySell: "B", // 買賣別 (string) orderNo: "i0317", // 委託書號 (string) filledNo: "0000001", // 成交序號 (string) filledQuantity: "1000", // 成交數量 (string) prevDayQuantity: "1000", // 昨日庫存股數 (string) filledPrice: "16.15", // 成交價格 (string) filledAmount: "16150.00", // 成交金額 (string) currentPrice: "11.7", // 現價 (string) marketValue: "11700", // 市值 (string) marginAmount: "0", // 融資金額 (string) openMarginAmount: "0", // 未償還融資/券金額 (string) shortCollateral: "0", // 融券抵押品 (string) openShortCollateral: "0", // 未償還擔保品 (string) guaranteeAmount: "0", // 保證金 (string) openGuaranteeAmount: "0", // 未償還融券保證金 (string) securitiesLendingFee: "0", // 標借費 (string) shortSellingFee: "0", // 融券費手續費 (string) fee: "23", // 手續費 (string) tax: "0", // 交易稅 (string) interest: "0", // 利息 (string) cost: "16173", // 收付金額 (string) costBeforeDividend: "16173",// 收付金額(不扣除息金額) (string) changeType: "0", // 異動別 (string) ownFundsAmount: "0", // 自備款 (string) portfolioType: "", // 權證種類 (string) custId: "1234567", // 帳號 (string) name: "許OO", // 名稱 (string) branchId: "5920", // 分行 ID (string) otherCost: "0", // 其他成本 (string) isAdjusted: null, // 是否可調整 (null) securitiesIncomeTax: "0", // 證券所得稅 (string) healthInsuranceFee: "0", // 健康保險費 (string) unrealizedProfitLoss: "-4504", // 未實現損益 (string) unrealizedProfitLossRate: null, // 未實現損益率 (null) referencePrice: "0", // 參考價格 (string) ioFlag: "", // 異動代碼 (string) ioName: "", // 異動名稱 (string) breakEvenPrice: "16.22", // 損益兩平價格 (string) dividendAmount: "0", // 股利金額 (string) guaranteeDefaultAmount: "0" // 擔保金缺額 (string) }, ], }, ... ] } ``` --- ### 歷史交割款查詢 historySettlement #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | --------- | ------------------------------------------------------------------------------------------------------------ | ------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | startDate | string | 查詢起始日期 ( YYYYMMDD ) | | endDate | string | 查詢結束日期 ( YYYYMMDD ) | #### 交割款 SettlementResponse 欄位[​](#交割款-settlementresponse--欄位 "Direct link to 交割款 SettlementResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------------------- | ------ | -------------- | | accountSummary | Object | 帳戶摘要 | | └─ marginPositionMarketValueSum | String | 融資市值加總 | | └─ shortPositionMarketValueSum | String | 融券市值加總 | | └─ shortCollateralSum | String | 融券擔保品加總 | | └─ marginLimit | String | 融資限額 | | └─ shortLimit | String | 融券限額 | | └─ guaranteeAmountSum | String | 融券保證金加總 | | └─ marginAmountSum | String | 融資金額加總 | | └─ shortAmountSum | String | 融券金額加總 | | └─ settlementToday | String | 今日結算金額 | | └─ settlementYesterday | String | 昨日結算金額 | | └─ settlementNet | String | 結算淨額 | | settlements | Array | 結算記錄 | | └─ branchId | String | 分公司代號 | | └─ custId | String | 帳號 | | └─ sDate | String | 交割日期 | | └─ tDate | String | 交易日期 | | └─ netAmount | String | 淨收付金額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.historySettlement(account,"20241001","20241014") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { accountSummary: { // 帳戶摘要 (AccountSummary object) marginPositionMarketValueSum: "0", // 融資市值加總 (string) shortPositionMarketValueSum: "0", // 融券市值加總 (string) shortCollateralSum: "0", // 融券擔保品加總 (string) marginLimit: "0", // 融資限額 (string) shortLimit: "0", // 融券限額 (string) guaranteeAmountSum: "0", // 融券保證金加總 (string) marginAmountSum: "0", // 融資金額加總 (string) shortAmountSum: "0", // 融券金額加總 (string) settlementToday: "0", // 今日交割金額 (string) settlementYesterday: "0", // 昨日交割金額 (string) settlementNet: "0", // 交割金額 (string) }, settlements: [ { branchId: "592a", // 分公司代號 (string) custId: "123456", // 帳號 (string) sDate: "20241014", // 交割日期 (string) tDate: "20241009", // 交易日期 (string) netAmount: "-1640300.00" // 淨收付金額 (string) } ] } ``` --- ### 今日交割款查詢 todaySettlement #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | #### 交割款 PaymentResponse 欄位[​](#交割款-paymentresponse-欄位 "Direct link to 交割款 PaymentResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------------------- | ------ | ------------------ | | sDate | String | 交割日期 | | tDate | String | 交易日期 | | netAmount | String | 總淨收付金額 | | settleSum | Object | 現金結算彙總 | | └─ buyAmount | String | 今日現股買金額 | | └─ sellAmount | String | 今日現股賣金額 | | └─ fee | String | 手續費 | | └─ tax | String | 交易稅 | | └─ netAmount | String | 淨收付金額 | | settleCreditSum | Object | 融資結算摘要 | | └─ marginQuantity | String | 當日融資額度 | | └─ marginQuantityLeft | String | 當日可用融資餘額 | | └─ marginCollateral | String | 融資自備款 | | └─ marginCollateralBuy | String | 融資自備款買入 | | └─ marginCollateralSell | String | 融資自備款賣出 | | └─ marginAmount | String | 融資金額 | | └─ marginAmountBuy | String | 融資買入金額 | | └─ marginAmountSell | String | 融資賣出金額 | | └─ marginNetAmountBuy | String | 融資買入應收付金額 | | └─ marginNetAmountSell | String | 融資賣出應收付金額 | | └─ interest | String | 融資利息 | | └─ fee | String | 手續費 | | └─ tax | String | 交易稅 | | └─ netAmount | String | 淨收付金額 | | settleDebitSum | Object | 融券結算摘要 | | └─ shortQuantity | String | 當日融券額度 | | └─ shortQuantityLeft | String | 當日可用融資餘額 | | └─ guaranteeAmount | String | 融券保證金 | | └─ guaranteeAmountBuy | String | 融券保證金券買 | | └─ guaranteeAmountSell | String | 融券保證金券賣 | | └─ shortCollateral | String | 融券擔保品 | | └─ shortCollateralBuy | String | 融券擔保品券買 | | └─ shortCollateralSell | String | 融券擔保品券賣 | | └─ shortNetAmountBuy | String | 融券券買應收付金額 | | └─ shortNetAmountSell | String | 融券券賣應收付金額 | | └─ shortSellingFee | String | 融券手續費 | | └─ interest | String | 融券利息 | | └─ netAmount | String | 融券淨收付金額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.todaySettlement(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { sDate: "20241209", // 交割日期 (string) tDate: "20241205", // 交易日期 (string) netAmount: "-150213", // 總淨收付金額 (string) settleSum: { // 現金結算摘要 buyAmount: "150000", // 今日現股買金額 (string) sellAmount: "0", // 今日現股賣金額 (string) fee: "213", // 手續費 (string) tax: "0", // 交易稅 (string) netAmount: "0", // 淨金額 (string) }, settleCreditSum: { // 融資結算摘要 marginQuantity: "0", // 當日融資額度 (string) marginQuantityLeft: "0", // 剩餘融資數量 (string) openShortCollateral: "0", // 融資自備款 (string) openShortCollateralBuy: "0", // 融資自備款買入 (string) openShortCollateralSell: "0", // 融資自備款賣出 (string) marginAmount: "0", // 融資金額 (string) marginAmountBuy: "0", // 融資買入金額 (string) marginAmountSell: "0", // 融資賣出金額 (string) marginNetAmountBuy: "0", // 融資淨買入金額 (string) marginNetAmountSell: "0", // 融資淨賣出金額 (string) interest: "0", // 融資利息 (string) fee: "0", // 費用 (string) tax: "0", // 交易稅 (string) netAmount: "0", // 融資淨額 (string) }, settleDebitSum: { // 融券結算摘要 (SettlementShortSummary object) shortQuantity: "0", // 融券數量 (string) shortQuantityLeft: "0", // 當日可用融資餘額 (string) guaranteeAmount: "0", // 保證金金額 (string) guaranteeAmountBuy: "0", // 融券保證金券買 (string) guaranteeAmountSell: "0", // 融券保證金券賣 (string) shortCollateral: "0", // 融券擔保品 (string) shortCollateralBuy: "0", // 融券擔保品券買 (string) shortCollateralSell: "0", // 融券擔保品券賣 (string) shortNetAmountBuy: "0", // 融券券買應收付金額 (string) shortNetAmountSell: "0", // 融券券賣應收付金額 (string) shortSellingFee: "0", // 融券手續費 (string) interest: "0", // 融券利息 (string) netAmount: "0", // 融券淨收付金額 (string) } } ``` --- ### 已實現損益查詢 realizedProfitAndLoses #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢起始日 ( YYYYMMDD ) | | end\_date | string | 查詢結束日 ( YYYYMMDD ) | #### Realized 欄位[​](#realized-欄位 "Direct link to Realized 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------------------------- | ------ | ------------------------------------------------------------------------------------------- | | no | String | 編號 | | cost | String | 買入成本 | | income | String | 賣出成本 | | profitLoss | String | 損益 | | profitLossRate | String | 損益率 | | accumulatedCost | String | 累計成本 | | accumulatedProfitLoss | String | 累計損益 | | accumulatedProfitLossRate | String | 累計損益率 | | shortSellingFee | String | 融券手續費 | | interest | String | 利息 | | closedMarginAmount | String | 償還融資金額 | | dividendAmount | String | 股利金額 | | securitiesLendingDifferentialFee | String | 券差借券費 | | **profitLossSummary** | Array | 損益摘要 | | └─ branchId | String | 分公司代號 | | └─ custId | String | 帳號 | | └─ name | String | 客戶姓名 | | └─ orderType | String | 委託別 : `0` 整股、`1、3`融資、`2、4`融券、 `9`現賣(擔保品) | | └─ orderTypeName | String | 委託類型名稱 | | └─ buySell | String | 買賣別 : `Buy`、`Sell` : `Buy`、`Sell` | | └─ symbol | String | 股票代號 | | └─ symbolName | String | 股票名稱 | | └─ targetPrice | String | 標的現價 | | └─ portfolioType | String | 權證種類 - | | └─ no | String | 編號 | | └─ tDate | String | 交易日期 | | └─ orderNo | String | 委託序號 | | └─ filledNo | String | 成交序號 | | └─ closedQuantity | String | 沖銷股數 | | └─ filledPrice | String | 成交價格 | | └─ closedMarginAmount | String | 償還融資金額 | | └─ closedShortCollateral | String | 償還擔保品 | | └─ closedGuaranteeAmount | String | 償還融券保證金 | | └─ interest | String | 利息 | | └─ shortSellingFee | String | 借券費 | | └─ cost | String | 成本 | | └─ costBeforeDividend | String | 成本 (不扣除息金額) | | └─ income | String | 賣出收入 | | └─ profitLoss | String | 損益 | | └─ profitLossRate | String | 損益率 | | └─ otherCost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | └─ closeType | String | 沖銷類別 : `0`現股、`1`融資、`2`融券、`3`信用當沖、`4`現股當沖、`5`現賣(未買回)/券差(買進) | | └─ securitiesTransactionTax | String | 證所稅 | | └─ healthInsurancePremium | String | 健保補充費 | | └─ orderTypeName2 | String | 委託類別名稱 | | └─ dividendAmount | String | 除息金額 | | └─ securitiesLendingDifferentialFee | String | 券差借券費 | | └─ **buyDetail** | Object | 買入詳情 | |   └─ filledQuantity | String | 成交數量 | |   └─ filledAmount | String | 成交金額 | |   └─ netAmount | String | 淨收付 | |   └─ marginAmount | String | 融資金額 | |   └─ guaranteeAmount | String | 保證金金額 | |   └─ shortCollateral | String | 融券擔保品 | |   └─ securitiesLendingFee | String | 標借費 | |   └─ adjustmentDate | String | 調整日期 | |   └─ orderType | String | 委託別 : `0` 整股、`1、3`融資、`2、4`融券、 `9`現賣(擔保品) | |   └─ orderTypeName | String | 委託類型名稱 | |   └─ buySell | String | 買賣方向 | |   └─ changeType | String | 變更類型 | |   └─ isAdjusted | String | 是否開放調整成本 | |   └─ ioFlag | String | 異動代碼 | |   └─ ioName | String | 異動名稱 | |   └─ no | String | 編號 | |   └─ tDate | String | 交易日期 | |   └─ orderNo | String | 委託序號 | |   └─ filledNo | String | 成交序號 | |   └─ closedQuantity | String | 沖銷股數 | |   └─ filledPrice | String | 成交價格 | |   └─ closedMarginAmount | String | 償還融資金額 | |   └─ closedShortCollateral | String | 償還擔保品 | |   └─ closedGuaranteeAmount | String | 償還融券保證金 | |   └─ fee | String | 手續費 | |   └─ interest | String | 利息 | |   └─ tax | String | 稅金 | |   └─ shortSellingFee | String | 借券費 | |   └─ cost | String | 成本 | |   └─ costBeforeDividend | String | 成本 (不扣除息金額) | |   └─ income | String | 賣出收入 | |   └─ profitLoss | String | 損益 | |   └─ profitLossRate | String | 損益率 | |   └─ otherCost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ closeType | String | 沖銷類別 : `0`現股、`1`融資、`2`融券、`3`信用當沖、`4`現股當沖、`5`現賣(未買回)/券差(買進) | |   └─ securitiesTransactionTax | String | 證所稅 | |   └─ healthInsurancePremium | String | 健保補充費 | |   └─ orderTypeName2 | String | 委託類別 | |   └─ dividendAmount | String | 除息金額 | |   └─ securitiesLendingDifferentialFee | String | 券差借券費 | | └─ **SellDetail** | Object | 賣出詳情 | |   └─ filledQuantity | String | 成交數量 | |   └─ filledAmount | String | 成交金額 | |   └─ netAmount | String | 淨收付 | |   └─ marginAmount | String | 融資金額 | |   └─ guaranteeAmount | String | 保證金金額 | |   └─ shortCollateral | String | 融券擔保品 | |   └─ securitiesLendingFee | String | 標借費 | |   └─ adjustmentDate | String | 調整日期 | |   └─ orderType | String | 委託別 : `0` 整股、`1、3`融資、`2、4`融券、 `9`現賣(擔保品) | |   └─ orderTypeName | String | 委託類型名稱 | |   └─ buySell | String | 買賣方向 | |   └─ changeType | String | 變更類型 | |   └─ isAdjusted | String | 是否開放調整成本 | |   └─ ioFlag | String | 異動代碼 | |   └─ ioName | String | 異動名稱 | |   └─ no | String | 編號 | |   └─ tDate | String | 交易日期 | |   └─ orderNo | String | 委託序號 | |   └─ filledNo | String | 成交序號 | |   └─ closedQuantity | String | 沖銷股數 | |   └─ filledPrice | String | 成交價格 | |   └─ closedMarginAmount | String | 償還融資金額 | |   └─ closedShortCollateral | String | 償還擔保品 | |   └─ closedGuaranteeAmount | String | 償還融券保證金 | |   └─ fee | String | 手續費 | |   └─ interest | String | 利息 | |   └─ tax | String | 稅金 | |   └─ shortSellingFee | String | 借券費 | |   └─ cost | String | 成本 | |   └─ costBeforeDividend | String | 成本 (不扣除息金額) | |   └─ income | String | 賣出收入 | |   └─ profitLoss | String | 損益 | |   └─ profitLossRate | String | 損益率 | |   └─ otherCost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ closeType | String | 沖銷類別 : `0`現股、`1`融資、`2`融券、`3`信用當沖、`4`現股當沖、`5`現賣(未買回)/券差(買進) | |   └─ securitiesTransactionTax | String | 證所稅 | |   └─ healthInsurancePremium | String | 健保補充費 | |   └─ orderTypeName2 | String | 委託類別 | |   └─ dividendAmount | String | 除息金額 | |   └─ securitiesLendingDifferentialFee | String | 券差借券費 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.realizedProfitAndLoses(account,"20241101","20241201"); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { no: "合計", // 編號 (String) cost: "83618", // 買入總成本 (String) income: "81462", // 賣出總收入 (String) profitLoss: "-2156", // 總損益 (String) profitLossRate: "-2.58%", // 總損益率 (String) accumulatedCost: "0", // 累計成本 (String) accumulatedProfitLoss: "-2156", // 累計損益 (String) accumulatedProfitLossRate: "-2.58%", // 累計損益率 (String) shortSellingFee: "0", // 融券手續費 (String) interest: "0", // 利息 (String) closedMarginAmount: "0", // 償還融資金額 (String) dividendAmount: "0", // 股利金額 (String) securitiesLendingDifferentialFee: "0", // 券差借券費 (String) profitLossSummary: [ { no: "1", // 編號 (String) transactionDate: "20240808", // 交易日期 (String) filledNo: "0000001", // 成交編號 (String) closedQuantity: "1000", // 平倉數量 (String) filledPrice: "81.70", // 成交價格 (String) closedMarginAmount: "0", // 償還融資金額 (String) closedShortCollateral: "0", // 償還擔保品 (String) closedGuaranteeAmount: "0", // 償還保證金 (String) interest: "0", // 利息 (String) shortSellingFee: "0", // 融券費用 (String) cost: "83618", // 買入成本 (String) costBeforeDividend: "83618", // 買入成本 (未扣除股息) (String) income: "81462", // 賣出收入 (String) profitLoss: "-2156", // 損益 (String) profitLossRate: "-2.58%", // 損益率 (String) otherCost: "0", // 其他成本 (String) closedType: "4", // 平倉類型 (String) orderTypeName2: "現沖", // 委託類型名稱2 (String) dividendAmount: "0", // 股息金額 (String) securitiesLendingDifferentialFee: "0", // 券差借券費 (String) branchId: "5920", // 分公司代號 (String) customerId: "9816000", // 客戶帳號 (String) customerName: "陳XXX", // 客戶姓名 (String) orderType: "0", // 委託類型 (String) orderTypeName: "現股", // 委託類型名稱 (String) buySell: "Sell", // 買賣方向 (String) symbol: "3663", // 股票代號 (String) symbolName: "鑫科", // 股票名稱 (String) targetPrice: "0", // 標的價格 (String) portfolioType: "", // 投資組合類型 (String) buyDetail: { no: "1", // 編號 (String) transactionDate: "20240808", // 交易日期 (String) orderNo: "o0179", // 委託序號 (String) filledNo: "0000002", // 成交編號 (String) closedQuantity: "1000", // 平倉股數 (String) filledPrice: "83.50", // 成交價格 (String) closedMarginAmount: "0", // 償還融資金額 (String) closedShortCollateral: "0", // 償還擔保品 (String) closedGuaranteeAmount: "0", // 償還保證金 (String) fee: "118", // 手續費 (String) interest: "0", // 利息 (String) tax: "0", // 稅金 (String) shortSellingFee: "0", // 融券費用 (String) cost: "83618", // 買入成本 (String) costBeforeDividend: "83618", // 買入成本 (未扣除股息) (String) income: "81462", // 賣出收入 (String) profitLoss: "-2156", // 損益 (String) profitLossRate: "-2.58%", // 損益率 (String) otherCost: "0", // 其他成本 (String) closedType: "4", // 平倉類型 (String) securitiesTransactionTax: "0", // 證券交易稅 (String) healthInsurancePremium: "0", // 健保費用 (String) orderTypeName2: "買沖", // 委託類型名稱2 (String) dividendAmount: "0", // 股息金額 (String) securitiesLendingDifferentialFee: "0", // 券差借券費 (String) filledQuantity: "1000", // 成交數量 (String) filledAmount: "83500", // 成交金額 (String) netAmount: "-83618", // 淨支付金額 (String) marginAmount: "0", // 融資金額 (String) guaranteeAmount: "0", // 保證金金額 (String) shortCollateral: "0", // 融券擔保品 (String) securitiesLendingFee: "0", // 證券借貸費用 (String) adjustmentDate: "", // 調整日期 (String) orderType: "0", // 委託類型 (String) orderTypeName: "現股", // 委託類型名稱 (String) buySell: "B", // 買賣方向 (String) changeType: "0", // 變更類型 (String) isAdjusted: "N", // 是否已調整 (String) ioFlag: "", // 異動代碼 (String) ioName: "" // 異動名稱 (String) }, sellDetail: { no: "1", // 編號 (String) transactionDate: "20240808", // 交易日期 (String) orderNo: "g0050", // 委託序號 (String) filledNo: "0000001", // 成交編號 (String) closedQuantity: "1000", // 平倉股數 (String) filledPrice: "81.70", // 成交價格 (String) closedMarginAmount: "0", // 償還融資金額 (String) closedShortCollateral: "0", // 償還擔保品 (String) closedGuaranteeAmount: "0", // 償還保證金 (String) fee: "116", // 手續費 (String) interest: "0", // 利息 (String) tax: "122", // 稅金 (String) shortSellingFee: "0", // 融券費用 (String) cost: "0", // 成本 (String) costBeforeDividend: "0", // 成本 (未扣除股息) (String) income: "81462", // 賣出收入 (String) profitLoss: "0", // 損益 (String) profitLossRate: "100.00%", // 損益率 (String) otherCost: "0", // 其他成本 (String) closedType: "4", // 平倉類型 (String) securitiesTransactionTax: "0", // 證券交易稅 (String) healthInsurancePremium: "0", // 健保費用 (String) orderTypeName2: "賣沖", // 委託類型名稱2 (String) dividendAmount: "0", // 股息金額 (String) securitiesLendingDifferentialFee: "0", // 券差借券費 (String) filledQuantity: "1000", // 成交數量 (String) filledAmount: "81700", // 成交金額 (String) netAmount: "81462", // 淨收入金額 (String) marginAmount: "0", // 融資金額 (String) guaranteeAmount: "0", // 保證金金額 (String) shortCollateral: "0", // 融券擔保品 (String) securitiesLendingFee: "0", // 證券借貸費用 (String) adjustmentDate: "", // 調整日期 (String) orderType: "0", // 委託類型 (String) orderTypeName: "現股", // 委託類型名稱 (String) buySell: "S", // 買賣方向 (String) changeType: "", // 變更類型 (String) isAdjusted: null, // 是否已調整 (null 或 String) ioFlag: "", // 異動代碼 (String) ioName: "" // 異動名稱 (String) } } ] } ``` --- ### 新光銀行餘額查詢 info 如是約定分戶帳交割,請用 [分戶帳餘額查詢](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/accountManagement/Balance.md) skbankBalance #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 餘額 SKBankbalace 欄位[​](#餘額-skbankbalace-欄位 "Direct link to 餘額 SKBankbalace 欄位") Return type : Object | 參數 | 類別 | 說明 | | ---------------- | ------ | -------- | | balance | number | 帳戶餘額 | | availableBalance | number | 可用餘額 | | currency | string | 幣別 | | branchId | string | 分公司 | | custId | string | 帳號 | | bankAccount | string | 銀行帳號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.skbankBalance(accounts[0]) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { balance: 7015.00, // 帳戶餘額 (double) available: 7015.00, // 可用餘額 (double) currency: "TWD", // 幣別 (string) branch_id: "592W", // 分公司代號 (string) cust_id: "1222344", // 證券帳號 (string) bank_account: "046508006075" // 銀行帳號 (string) } ``` --- ### 今日買賣日報與即時庫存 todayTradeSummary #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | symbol | String ( Optional ) | 股票代號 | #### RealtimePositionQuantityOutput 欄位[​](#realtimepositionquantityoutput-欄位 "Direct link to RealtimePositionQuantityOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------------------------- | ------ | ---------------------------------------- | | symbol | String | 股票代號 | | marketType | String | 市場別 : `T` 上市 、 `O` 上櫃、 `R` 興櫃 | | commonStockQuantity | String | 昨日餘額普通股股數 | | marginStockQuantity | String | 昨日餘額融資股數 | | shortStockQuantity | String | 昨日餘額融券股數 | | oddLotQuantity | String | 昨日餘額零股股數 | | realTimeDepositoryQuantity | String | 即時普通股股數 | | realTimeMarginQuantity | String | 即時融資股數 | | realTimeShortSellingQuantity | String | 即時融券股數 | | realTimeOddLotQuantity | String | 即時零股股數 | | todayDepositoryBuyOrderQuantity | String | 今日普通股委託買進股數 | | todayMarginBuyOrderQuantity | String | 今日融資委託買進股數 | | todayShortSellingBuyOrderQuantity | String | 今日融券委託買進股數 | | todayOddLotBuyOrderQuantity | String | 今日零股委託買進股數 | | todayDepositorySellOrderQuantity | String | 今日普通股委託賣出股數 | | todayMarginSellOrderQuantity | String | 今日融資委託賣出股數 | | todayShortSellingSellOrderQuantity | String | 今日融券委託賣出股數 | | todayOddLotSellOrderQuantity | String | 今日零股委託賣出股數 | | todayDepositoryBuyExecutedQuantity | String | 今日普通股買進成交股數 | | todayMarginBuyExecutedQuantity | String | 今日融資買進成交股數 | | todayShortSellingBuyExecutedQuantity | String | 今日融券買進成交股數 | | todayOddLotBuyExecutedQuantity | String | 今日零股買進成交股數 | | todayDepositorySellExecutedQuantity | String | 今日普通股賣出成交股數 | | todayMarginSellExecutedQuantity | String | 今日融資賣出成交股數 | | todayShortSellingSellExecutedQuantity | String | 今日融券賣出成交股數 | | todayOddLotSellExecutedQuantity | String | 今日零股賣出成交股數 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.accounting.todayTradeSummary(account); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { symbol: "1108", // 商品代碼 (String) marketType: "T", // 市場別 (String) : T 上市 、 O 上櫃、 R 興櫃 commonStockQuantity: "0", // 昨日餘額普通股股數 (String) marginStockQuantity: "0", // 昨日餘額融資股數 (String) shortSellingQuantity: "0", // 昨日餘額融券股數 (String) oddLotQuantity: "0", // 昨日餘額零股股數 (String) realTimeDepositoryQuantity: "1000", // 即時普通股股數 (String) realTimeMarginQuantity: "0", // 即時融資股數 (String) realTimeShortSellingQuantity: "0", // 即時融券股數 (String) realTimeOddLotQuantity: "0", // 即時零股股數 (String) todayDepositoryBuyOrderQuantity: "1000", // 今日普通股委託買進股數 (String) todayMarginBuyOrderQuantity: "0", // 今日融資委託買進股數 (String) todayShortSellingBuyOrderQuantity: "0", // 今日融券委託買進股數 (String) todayOddLotBuyOrderQuantity: "0", // 今日零股委託買進股數 (String) todayDepositorySellOrderQuantity: "0", // 今日普通股委託賣出股數 (String) todayMarginSellOrderQuantity: "0", // 今日融資委託賣出股數 (String) todayShortSellingSellOrderQuantity: "0", // 今日融券委託賣出股數 (String) todayOddLotSellOrderQuantity: "0", // 今日零股委託賣出股數 (String) todayDepositoryBuyExecutedQuantity: "1000", // 今日普通股買進成交股數 (String) todayMarginBuyExecutedQuantity: "0", // 今日融資買進成交股數 (String) todayShortSellingBuyExecutedQuantity: "0", // 今日融券買進成交股數 (String) todayOddLotBuyExecutedQuantity: "0", // 今日零股買進成交股數 (String) todayDepositorySellExecutedQuantity: "0", // 今日普通股賣出成交股數 (String) todayMarginSellExecutedQuantity: "0", // 今日融資賣出成交股數 (String) todayShortSellingSellExecutedQuantity: "0", // 今日融券賣出成交股數 (String) todayOddLotSellExecutedQuantity: "0", // 今日零股賣出成交股數 (String) } ``` --- ### 參數對照表 #### 類別[​](#類別 "Direct link to 類別") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | ----------- | --------------------------- | -------------------------------------------------------------------------------------------------------- | | buySell | [BSAction](#bsaction) | 買賣別 : `Buy`、`Sell` | | symbol | string | 股票代號 | | price | string | 委託價格 | | quantity | int | 委託數量 | | marketType | [MarketType](#markettype) | 盤別 : 可選用參數`Common` 整股、`Fixing`定盤、`IntradayOdd` 盤中零股、`Odd` 盤後零股、`Emg` 興櫃 | | priceType | [PriceType](#pricetype) | 價格旗標 : 可選用參數為 `Limit`限價、`LimitUp`漲停、`LimitDown`跌停、`Market`市價、`Reference`參考價 | | timeInForce | [timeInForce](#timeinforce) | 委託條件 : 可選用參數為 `ROD`、`FOK`、`IOC` | | orderType | [OrderType](#ordertype) | 委託類別 : 可選用參數為 `Stock`現股、`Margin`融資、`Short`融券、`DayTradeShort` 現股當沖(for 現沖先賣) | caution 不同 MarketType 對應的 quantity 之單位及範圍不同,請參考 [盤別](#markettype) 說明。 caution 當 MarketType 爲 MarketType.Common, MarketType.Odd, MarketType.IntradayOdd 其中之一,且 priceType 爲 PriceType.Limit 時,需填入 price 欄位,其餘時候 price 欄位為空值或為null。 caution 現沖先賣時 , orderType = DayTrade , buySell 需為 Sell , marketType 需為 Common ##### OrderRecord[​](#orderrecord "Direct link to OrderRecord") 委託列表,透過 [GetOrderResult(accounts)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/trade/GetOrderResults.md) 取得。 | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | workDate | String | 有效交易日期 | | orderDate | String | 委託日期 | | orderTime | String | 委託時間 | | sysCode | String | 來源別 | | orderNo | String | 委託書號 | | symbol | String | 股票代號 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 :`T`上市、`O`上櫃、`R`興櫃 | | marketType | [marketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg` 興櫃、`IntradayOdd` 盤中零股 | | priceType | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | | timeInForce | [TimeInForce](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現沖賣 | | orderPrice | Number | 委託價格 | | orgQty | Number | 原始下單股數 | | filledQty | Number | 已成交股數 | | celQty | Number | 已取消股數 | | canCancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | errCode | String | 錯誤代碼 | | errMsg | String | 錯誤訊息 | | seqNo | String | 流水號 | | isPreOrder | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 : `true` 是預約單、`false`不是預約單 : `true` 是預約單、`false`不是預約單 : `true` 是預約單、`false`不是預約單 : `true` 是預約單、`false`不是預約單 | | preOrderNo | String | 預約單號碼 | | avgPrice | Number | 成交均價 | | chgTime | String | 變動時間 | | chgDate | String | 變動日期 | ##### Ack Object[​](#ack-object "Direct link to Ack Object") 委託回報物件 | 参数 | 类别 | 说明 | | ------------- | --------------------------- | -------------------------------------------------------------------------------------------------- | | workDate | String | 有效交易日期 | | orderDateTime | String | 原始委託日期 | | orgRequestNo | String | 原始委託 Request 序號 | | sysCode | String | 來源別 | | orgSysCode | String | 原始委託來源 | | requestNo | String | 刪改委託 Request 序號 | | orderNo | String | 委託書號 | | symbol | String | 股票代號 | | buySell | [BSAction](#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | marketType | [MarketType](#markettype) | 市場類型 : `Common` 整股、`AfterMarket` 盤後、`Odd` 盤後零股、`Emg` 興櫃、`IntradayOdd` 盤中零股 | | priceType | [PriceType](#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | | timeInForce | [TimeInForce](#timeinforce) | 委託條件別 : `ROD`、`IOC`、`FOK` | | orderType | [OrderType](#ordertype) | 委託單類型 : `Stock` 股票、`Margin` 融資、`Short` 融券、`ShortSale` 借券 | | orderPrice | Double | 委託價格 | | orgQty | Int | 原始下單股數 | | filledQty | Int | 已成交股數 | | celQty | Int | 已取消股數 | | canCancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | errCode | String | 錯誤代碼 | | errMsg | String | 錯誤訊息 | | act | String | 新單 / 刪改 : `0` 新單、`M` 改量、`C` 刪單、`R` 改價 | | kind | String | 種類 : `ACK` 委託、`MAT` 成交 | | account | String | 帳號 | | beforeQty | Int | 變更前股數 | | afterQty | Int | 變更後股數 | | lineNo | String | 行號 | | orderSeqNo | String | 流水號 | | isPreOrder | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 | | orgPreOrderNo | String | 原始預約單委託書編號 | | preOrderNo | String | 預約單號碼 | ##### Mat Object[​](#mat-object "Direct link to Mat Object") 成交回報物件 | 参数 | 类别 | 说明 | | ----------- | ------------------------- | ------------------------------------------------------------------------------------------------ | | orderNo | String | 委託書號 | | orgSysCode | String | 原始委託來源別 | | symbol | String | 股票代號 | | orderSeqNo | String | 網單序號 | | mktSeqNo | String | 成交序號 | | marketType | [MarketType](#markettype) | 市場類型 : `Common` 整股、`AfterMarket` 盤後、`Odd` 盤後零股、`Emg` 興櫃、`IntradayOdd` 盤中零股 | | buySell | [BsAction](#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | orderType | [OrderType](#ordertype) | 委託單類型 : `Stock` 股票、`Margin` 融資、`Short` 融券 | | payPrice | Int | 價金 | | lineNo | String | 行號 | | kind | String | 種類 : `MAT` 成交、`ACK` 委託 | | account | String | 帳號 | | filledTime | String | 成交時間 | | filledQty | Int | 成交股數 | | filledPrice | Double | 成交價格 | ##### Account[​](#account "Direct link to Account") 帳號資訊 | Parameter | Type | Meaning | | ----------- | ------ | --------------------------------------------------------------------------------- | | account | string | 分公司+帳號 | | accountType | string | 帳號類型 | | sMark | string | 現股當沖狀態 : `B` 可先賣後買與先買後賣、 `Y`、`A` 可先買後賣、其餘回傳未符合資格 | | name | string | 姓名 | #### Constants ( 欄位對應數值 )[​](#constants--欄位對應數值- "Direct link to Constants ( 欄位對應數值 )") ##### BSAction[​](#bsaction "Direct link to BSAction") 買賣別 (buySell) | Name | Meaning | | ---- | ------- | | Buy | 買 | | Sell | 賣 | ##### MarketType[​](#markettype "Direct link to MarketType") 盤別 | Name | Meaning | | ----------- | -------- | | Common | 整股 | | Fixing | 定盤 | | IntradayOdd | 盤中零股 | | Odd | 盤後零股 | | Emg | 興櫃 | | EmgOdd | 興櫃零股 | 使用不同MarketType時,相對應的Quantity所代表的單位及範圍也會不同,詳如下表: | Name | Quantity Unit | Quantity Ranges | | ----------- | ------------- | --------------- | | Common | 千股 | 1000 ~ 499000 | | Fixing | 千股 | 1000 ~ 499000 | | IntradayOdd | 股 | 1 ~ 999 | | Odd | 股 | 1 ~ 999 | | Emg | 千股 | 1000 ~ 499000 | | EmgOdd | 股 | 1 ~ 999 | 使用不同 MarketType 時,可使用的 PriceType , TimeInForce 會不同,詳如下表: | MarketType | Available PriceType | Available TimeInForce | | ----------- | ---------------------------------------------------- | --------------------- | | Common | Limit 、 LimitUp 、 LimitDown 、 Market 、 Reference | ROD 、 IOC 、 FOK | | Fixing | Reference | ROD | | IntradayOdd | Limit 、 LimitUp 、 LimitDown 、 Reference | ROD | | Odd | Limit 、 LimitUp 、 LimitDown 、 Reference | ROD | | Emg | Limit | ROD | | EmgOdd | Limit | ROD | ##### PriceType[​](#pricetype "Direct link to PriceType") 價格類型 (priceType) | Name | Meaning | | --------- | ----------------------- | | Limit | 限價 | | LimitUp | 漲停 | | LimitDown | 跌停 | | Market | 市價 | | Reference | 參考價 (定盤時為定盤價) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") 委託條件 (TimeInForce) | Name | Meaning | | ---- | ------------------------------------- | | ROD | 當日有效(Rest of Day) | | FOK | 全部成交否則取消(Fill-or-Kill) | | IOC | 立即成交否則取消(Immediate-or-Cancel) | ##### OrderType[​](#ordertype "Direct link to OrderType") 委託類別 (orderType) | Name | Meaning | | ------------- | -------- | | Stock | 現股 | | Margin | 融資 | | Short | 融券 | | DayTradeShort | 現股當沖 | ##### market[​](#market "Direct link to market") 市場 | Name | Value | | -------- | ----- | | 上市股票 | T | | 上櫃股票 | O | | 興櫃股票 | R | ##### QueryType[​](#querytype "Direct link to QueryType") 查詢類別 (QueryType) | Name | Meaning | | -------------- | ---------- | | All | 全部 | | Reservation | 預約單 | | RegularSession | 盤中 | | Cancelable | 可取消委託 | | Failed | 失敗單 | --- ### 取得交易日 getMarketTime #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ---- | ------ | -------- | | date | String | 查詢日期 | #### TradingSchedule 回傳[​](#tradingschedule-回傳 "Direct link to TradingSchedule 回傳") | 參數 | 類別 | 說明 | | ---------------------- | ------- | -------------------------------- | | **regular** | Object | 正常交易時段 | | └─ openTime | String | 正常交易開始時間("0930") | | └─ closeTime | String | 正常交易結束時間("1800") | | **after\_market** | Object | 盤後交易時段 | | └─ openTime | String | 盤後交易開始時間("1400") | | └─ closeTime | String | 盤後交易結束時間("1600") | | **odd\_lot** | Object | 零股交易時段 | | └─ openTime | String | 零股交易開始時間("1400") | | └─ closeTime | String | 零股交易結束時間("1600") | | **intraday\_odd\_lot** | Object | 零股當日盤交易時段 | | └─ openTime | String | 零股當日盤交易開始時間("0930") | | └─ closeTime | String | 零股當日盤交易結束時間("1800") | | **emg** | Object | 興櫃交易時段 | | └─ openTime | String | 興櫃交易開始時間("1100") | | └─ closeTime | String | 興櫃交易結束時間("1900") | | isTradingDay | Boolean | 是否為交易日(true/false) | | lastTradingDay | String | 上一個交易日("20240916") | | nextTradingDay | String | 下一個交易日("20240919") | | nextTradingDay2 | String | 下下個交易日("20240920") | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.getMarketTime("20241008") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { Regular: { openTime: "0930", // 正常交易開始時間 (String) closeTime: "1800", // 正常交易結束時間 (String) }, afterMarket: { openTime: "1400", // 盤後交易開始時間 (String) closeTime: "1600", // 盤後交易結束時間 (String) }, oddLot: { openTime: "1400", // 零股交易開始時間 (String) closeTime: "1600", // 零股交易結束時間 (String) }, intradayOddLot: { openTime: "0930", // 零股當日盤交易開始時間 (String) closeTime: "1800", // 零股當日盤交易結束時間 (String) }, emg: { openTime: "1100", // 興櫃交易開始時間 (String) closeTime: "1900", // 興櫃交易結束時間 (String) }, isTradingDay: true, // 是否為交易日 (Boolean) lastTradingDay: "20241007", // 上一個交易日 (String) nextTradingDay: "20241009", // 下一個交易日 (String) nextTradingDay2: "20241011", // 下下個交易日 (String) } ``` --- ### 登入 login #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ---------- | ------ | ---------- | | personalID | String | 登入的ID | | password | String | 登入的密碼 | | certPath | String | 憑證路徑 | | certPass | String | 憑證密碼 | #### 帳號資訊 Account 欄位[​](#帳號資訊-account-欄位 "Direct link to 帳號資訊 Account 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------- | ------ | --------------------------------------------------------------------------------- | | branchName | String | 分公司名 | | name | String | 客戶姓名 | | account | String | 客戶帳號 | | accountType | string | 帳號類型 回傳 `stk` 證券 | | sMark | String | 現股當沖狀態 : `B` 可先賣後買與先買後賣、 `Y`、`A` 可先買後賣、其餘回傳未符合資格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const { TaishinSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("Your ID", "Your Password","Your Cert Path","Your Cert Password"); console.log(accounts); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js [{ branchName :"桃園", account: "592v980000", accountType: "stk", sMark: "N", name: "許", }, { branchName :"營業部", account: "5920981100", accountType: "stk", sMark: "N", name: "許", }, { branchName :"松德", account: "592a980222", accountType: "stk", sMark: "N", name: "許" }] ``` --- ### API 資格開通 registerApiAuth #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 回傳[​](#回傳 "Direct link to 回傳") Return type: bool #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const { TaishinSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼"); console.log(accounts) //若有多帳號,則回傳多個 const register = sdk.registerApiAuth(accounts[0]) // 放入已簽屬完成的帳號 ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js true ``` --- ### 查詢歷史成交明細 filledHistoryDetail #### 輸入參數[​](#輸入參數 "Direct link to 輸入參�數") | 參數 | 類別 | 說明 | | --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | startDate | string | 查詢開始日 ( YYYYMMDD ) | | endDate | string | 查詢終止日 ( YYYYMMDD ) | #### 成交資訊 FilledRecordOutput 欄位[​](#成交資訊-filledrecordoutput-欄位 "Direct link to 成交資訊 FilledRecordOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | orderNo | String | 委託書號 | | sysCode | String | 來源別 | | symbol | String | 股票代號 | | mktSeqNo | String | 成交序號 | | marketType | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 : `T` 上市、`O`上櫃、`R`興櫃 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現股當沖賣 | | payment | Double | 應收付總金額 | | filledDate | String | 成交日期 | | filledTime | String | 成交時間 | | filledQty | Int | 成交股數 | | filledPrice | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const filled_history_detail = sdk.stock.filledHistoryDetail(account,"20230921","20230922"); console.log(filled_history_detail) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderNo: "g0002", // 委託書號 (String) sysCode: "4U", // 來源別 (String) symbol: "2889", // 股票代號 (String) mktSeqNo: "00000009", // 成交序號 (String) marketType: 1, // 盤別 (Int) market: "T", // 市場 (String) buySell: "Buy", // 買賣方向 (BsAction) orderType: "Common", // 委託單類型 (OrderType) payment: 15000.0, // 應收付總金額 (Double) filledDate: "20241004", // 成交日期 (String) filledTime: "152549030", // 成交時間 (String) filledQty: 1000, // 成交股數 (Int) filledPrice: 15.0, // 成交價格 (Double) } ``` --- ### 查詢歷史成交 filledHistory #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | startDate | string | 查詢開始日 ( YYYYMMDD ) | | endDate | string | 查詢終止日 ( YYYYMMDD ) | #### 成交資訊 FilledRecordOutput 欄位[​](#成交資訊-filledrecordoutput-欄位 "Direct link to 成交資訊 FilledRecordOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | orderNo | String | 委託書號 | | sysCode | String | 來源別 | | symbol | String | 股票代號 | | mktSeqNo | String | 成交序號 | | marketType | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 : `T` 上市、`O`上櫃、`R`興櫃 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現股當沖賣 | | payment | Double | 應收付總金額 | | filledDate | String | 成交日期 | | filledTime | String | 成交時間 | | filledQty | Int | 成交股數 | | filledPrice | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const filled_history = sdk.stock.filledHistory(account,"20230921","20230922"); console.log(filled_history) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderNo: "g0002", // 委託書號 (String) sysCode: "4U", // 來源別 (String) symbol: "2889", // 股票代號 (String) mktSeqNo: "00000009", // 成交序號 (String) marketType: 1, // 盤別 (Int) market: "T", // 市場 (String) buySell: "Buy", // 買賣方向 (BsAction) orderType: "Common", // 委託單類型 (OrderType) payment: 15000.0, // 應收付總金額 (Double) filledDate: "20241004", // 成交日期 (String) filledTime: "152549030", // 成交時間 (String) filledQty: 1000, // 成交股數 (Int) filledPrice: 15.0, // 成交價格 (Double) } ``` --- ### 查詢今日成交彙總 getFilled #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | symbol | string ( Optional ) | 股票代號 | #### 成交資訊 FilledRecordOutput 欄位[​](#成交資訊-filledrecordoutput-欄位 "Direct link to 成交資訊 FilledRecordOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | orderNo | String | 委託書號 | | sysCode | String | 來源別 | | symbol | String | 股票代號 | | mktSeqNo | String | 成交序號 | | marketType | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 : `T` 上市、`O`上櫃、`R`興櫃 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現股當沖賣 | | payment | Double | 應收付總金額 | | filledDate | String | 成交日期 | | filledTime | String | 成交時間 | | filledQty | Int | 成交股數 | | filledPrice | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const getfilled = sdk.stock.getFilled(account); console.log(getfilled) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderNo: "g0002", // 委託書號 (String) sysCode: "4U", // 來源別 (String) symbol: "2889", // 股票代號 (String) mktSeqNo: "00000009", // 成交序號 (String) marketType: 1, // 盤別 (Int) market: "T", // 市場 (String) buySell: "Buy", // 買賣方向 (BsAction) orderType: "Common", // 委託單類型 (OrderType) payment: 15000.0, // 應收付總金額 (Double) filledDate: "20241004", // 成交日期 (String) filledTime: "152549030", // 成交時間 (String) filledQty: 1000, // 成交股數 (Int) filledPrice: 15.0, // 成交價格 (Double) } ``` --- ### 查詢今日成交明細 getFilledDetail #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | symbol | string ( Optional ) | 股票代號 | #### 成交資訊 FilledDetailOutput 欄位[​](#成交資訊-filleddetailoutput--欄位 "Direct link to 成交資訊 FilledDetailOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | orderNo | String | 委託書號 | | sysCode | String | 來源別 | | symbol | String | 股票代號 | | marketType | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 : `T` 上市、`O`上櫃、`R`興櫃 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現股當沖賣 | | payment | Double | 應收付總金額 | | filledDate | String | 成交日期 | | filledQty | Int | 成交股數 | | filledPrice | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const getfilled = sdk.stock.getFilled(account); console.log(getfilled) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderNo: "g0002", // 委託書號 (String) sysCode: "4U", // 來源別 (String) symbol: "2889", // 股票代號 (String) mktSeqNo: "00000009", // 成交序號 (String) marketType: 1, // 盤別 (Int) market: "T", // 市場 (String) buySell: "Buy", // 買賣方向 (BsAction) orderType: "Common", // 委託單類型 (OrderType) payment: 15000.0, // 應收付總金額 (Double) filledDate: "20241004", // 成交日期 (String) filledTime: "152549030", // 成交時間 (String) filledQty: 1000, // 成交股數 (Int) filledPrice: 15.0, // 成交價格 (Double) } ``` --- ### 取得委託單結果 getOrderResults #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | --------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | queryType | [QueryType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#querytype) | 盤別 : `All` 全部、`Reservation` 預約單 、`RegularSession` 盤中、`Cancelable` 可取消委託、`Failed` 失敗單 | #### 委託資訊 OrderRecord 欄位[​](#委託資訊-orderrecord-欄位 "Direct link to 委託資訊 OrderRecord 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | workDate | String | 有效交易日期 | | orderDate | String | 委託日期 | | orderTime | String | 委託時間 | | sysCode | String | 來源別 | | orderNo | String | 委託書號 | | symbol | String | 股票代號 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 :`T`上市、`O`上櫃、`R`興櫃 | | marketType | [marketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg` 興櫃、`IntradayOdd` 盤中零股 | | priceType | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | | timeInForce | [TimeInForce](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現沖賣 | | orderPrice | Number | 委託價格 | | orgQty | Number | 原始下單股數 | | filledQty | Number | 已成交股數 | | celQty | Number | 已取消股數 | | canCancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | errCode | String | 錯誤代碼 | | errMsg | String | 錯誤訊息 | | seqNo | String | 流水號 | | isPreOrder | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 | | preOrderNo | String | 預約單號碼 | | avgPrice | Number | 成交均價 | | chgTime | String | 變動時間 | | chgDate | String | 變動日期 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const orders = sdk.stock.getOrderResults(accounts); console.log(orders); // 帶入查詢參數 // sdk.stock.getOrderResults(accounts[0], QueryType.All) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { workDate: "20241007", // 有效交易日期 (String) orderDate: "20241007", // 委託日期 (String) orderTime: "153823610", // 委託時間 (String) sysCode: "4U", // 來源別 (String) orderNo: "f0002", // 委託書號 (String) symbol: "2889", // 股票代號 (String) buySell: "Buy", // 買賣方向 (BSAction) market: "T", // 市場 (String) marketType: "Common", // 盤別 (MarketType) priceType: "Limit", // 價格類型 (Enum) timeInForce: "ROD", // 委託條件 (Enum) orderType: "0", // 委託類型 (String) orderPrice: 15.0, // 委託價格 (Double) orgQty: 300000, // 原始下單股數 (Int) filledQty: 300000, // 已成交數量 (Int) celQty: 0, // 已取消數量 (Int) canCancel: false, // 是否可取消 (Boolean) errCode: "000000", // 錯誤代碼 (String) errMsg: "", // 錯誤訊息 (String) seqNo: "10000043", // 流水號 (String) isPreOrder: false, // 是否預約單 (Boolean) preOrderNo: "", // 預約單號碼 (String) avgPrice: 15.0, // 平均成交價格 (Double) chgTime: "153823610", // 異動時間 (String) chgDate: "20241007", // 異動日期 (String) } ``` --- ### 資券配額查詢 marginQuota #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | --------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | stock\_no | String | 股票代碼 | | query\_type | String | 查詢類別 : `1`融資、`2`融券 | #### 配額資訊 MarginShortQuota欄位[​](#配額資訊-marginshortquota欄位 "Direct link to 配額資訊 MarginShortQuota欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------ | ------ | ---------------------------------------------------- | | symbol | String | 股票代號 | | kind | String | 類別 (1: 融資, 2: 融券) | | tqty | String | 資券限額 : `數量` 、`停資`、`停券`、`不限資` | | stop | String | 是否停止融資/融券交易 (Y: 是, N: 否) | | crPercentage | String | 融資成數 (如 :0600 表0.6) | | dbPercentage | String | 融券成數 (如 :0900 表0.9) | | blMark | String | 融券核准記號 | | crStatus | String | 融資狀態 (查詢融資時才有) (如: 資0900 代表資成數) | | dbStatus | String | 融券狀態 (查詢融券時才有) (如: 券0900 代表券成數) | | crFlag | String | 信用交易資格: `Y` 無信用交易資格、`N` 有信用交易資格 | | luMsg | String | 平盤下是否可券賣 | | dteMsg | String | 是否可當沖、禁98戶 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.stock.marginQuota(account, "2330") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { symbol: "2330", // 股票代號 (String) kind: "1", // 類別 (String) tqty: "不限資", // 資券限額 (String) stop: "N", // 是否停止融資/融券交易 (String) crPercentage: "0600", // 融資成數 (String) dbPercentage: "0900", // 融券成數 (String) blMark: "1", // 融券核准記號 (String) crStatus: null, // 融資狀態 (String) dbStatus: "券0900", // 融券狀態 (String) crFlag: "N", // 信用交易資格 (String) luMsg: "平盤下可券", // 平盤下可券賣 (String) dteMsg: "可當沖", // 可當沖 (String) } ``` --- ### 修改委託價格 modifyPrice #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | account | \[Account] | 帳號 | | OrderRecord | [OrderRecord](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#orderrecord) | 預計修改的委託單 | | price | string | 修改後的價格 | | priceType | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | 修改後的價格旗標 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | caution 僅盤前可以修改 PriceType,盤中時段不支援改 PriceType caution 當 price 欄位有填入值時,priceType 欄位 Limit ; 當 priceType 不為 Limit 時,price 為 `0` #### 修改資訊 ModifiedResponse 欄位[​](#修改資訊-modifiedresponse-欄位 "Direct link to 修改資訊 ModifiedResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------- | ------ | -------- | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js // 單筆阻塞改價 sdk.stock.modifyPrice(accounts, orderRecord, "13.5", PriceType.Limit) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderDate: "20241007", // 委託日期 (String) orderTime: "153823610" // 委託時間 (String) } ``` --- ### 刪、改委託單數量 modifyVolume #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | orderRecord | [orderRecord](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#orderrecord) | 預計修改的委託單 | | volume | number | 刪減的股數 (設為 `0` 表刪單) | #### 修改資訊 OrderRecord 欄位[​](#修改資訊-orderrecord-欄位 "Direct link to 修改資訊 OrderRecord 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------- | ------ | -------- | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js sdk.stock.modifyVolume(accounts, orderRes, 200000) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderDate: "20241007", // 委託日期 (String) orderTime: "153823610" // 委託時間 (String) } ``` --- ### 查詢歷史委託 orderHistory #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | startDate | string | 查詢開始日 ( YYYYMMDD ) | | endDate | string | 查詢終止日 ( YYYYMMDD ) | #### OrderRecord 回傳[​](#orderrecord-回傳 "Direct link to OrderRecord 回傳") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | workDate | String | 有效交易日期 | | orderDate | String | 委託日期 | | orderTime | String | 委託時間 | | sysCode | String | 來源別 | | orderNo | String | 委託書號 | | symbol | String | 股票代號 | | buySell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 :`T`上市、`O`上櫃、`R`興櫃 | | marketType | [marketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg` 興櫃、`IntradayOdd` 盤中零股 | | priceType | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | | timeInForce | [TimeInForce](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | orderType | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`DayTradeShort` 現沖賣 | | orderPrice | Number | 委託價格 | | orgQty | Number | 原始下單股數 | | filledQty | Number | 已成交股數 | | celQty | Number | 已取消股數 | | canCancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | errCode | String | 錯誤代碼 | | errMsg | String | 錯誤訊息 | | seqNo | String (optional) | 流水號 | | isPreOrder | Boolean (optional) | 是否預約單 : `true` 是預約單、`false`不是預約單 | | preOrderNo | String (optional) | 預約單號碼 | | avgPrice | Number (optional) | 成交均價 | | chgTime | String (optional) | 變動時間 | | chgDate | String (optional) | 變動日期 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const orderHistory = sdk.stock.orderHistory(account,"20230921","20231020"); console.log(orderHistory); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js [ { workDate: "20241007", // 有效交易日期 (String) orderDate: "20241007", // 委託日期 (String) orderTime: "153718236", // 委託時間 (String) sysCode: "4U", // 來源別 (String) orderNo: "", // 委託書號 (String) symbol: "2889", // 股票代號 (String) buySell: "Buy", // 買賣方向: `Buy` 買 (String) market: "T", // 市場代號("T":台股)(String) marketType: "Common", // 盤別 (String) priceType: "Limit", // 價格類型 (String) timeInForce: "ROD", // 委託條件 (String) orderType: "0", // 委託類型 (String) orderPrice: 15.0, // 委託價格 (Double) orgQty: 150000, // 委託數量 (Int) filledQty: 0, // 已成交數量 (Int) celQty: 0, // 已取消數量 (Int) canCancel: false, // 是否可取消 (Boolean) errCode: "889", // 錯誤代號 (String) errMsg: "委託額度逾電交投資能力, 請洽營業員!", // 錯誤訊息 (String) seqNo: null, // 流水號 (String) isPreOrder: null, // 是否為預訂單 (Boolean) preOrderNo: null, // 預訂單號碼 (String) avgPrice: null, // 平均成交價格 (Double) chgTime: null, // 異動時間 (String) chgDate: null // 異動日期 (String) }, { workDate: "20241007", // 有效交易日期 (String) orderDate: "20241007", // 委託日期 (String) orderTime: "153617390", // 委託時間 (String) sysCode: "4U", // 來源別 (String) orderNo: "h0001", // 委託書號 (String) symbol: "2889", // 股票代號 (String) buySell: "Buy", // 買賣方向 (String) market: "T", // 市場代號 (String) marketType: "Common", // 盤別 (String) priceType: "Limit", // 價格類型 (String) timeInForce: "ROD", // 委託條件 (String) orderType: "0", // 委託類型 (String) orderPrice: 15.0, // 委託價格 (Double) orgQty: 15000, // 委託數量 (Int) filledQty: 15000, // 已成交數量 (Int) celQty: 0, // 已取消數量 (Int) canCancel: false, // 是否可取消 (Boolean) errCode: "000000", // 錯誤代號 (String) errMsg: "", // 錯誤訊息 (String) seqNo: null, // 流水號 (String) isPreOrder: null, // 是否為預訂單 (Boolean) preOrderNo: null, // 預訂單號碼 (String) avgPrice: null, // 平均成交價格 (Double) chgTime: null, // 異動時間 (String) chgDate: null // 異動日期 (String) } ] ``` --- ### 建立委託單 placeOrder #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | OrderObject | [OrderObject](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#orderobject) | 委託內容 | #### 委託資訊 PlaceOrderResponse 欄位[​](#委託資訊-placeorderresponse-欄位 "Direct link to 委託資訊 PlaceOrderResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ---------- | ------ | ------------ | | orderDate | String | 委託日期 | | orderTime | String | 委託時間 | | workDate | String | 有效交易日期 | | isPreOrder | Bool | 預約單註記 | | orderNo | String | 委託書號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```js const order = { buySell: BSAction.Buy, symbol: "2888", price: "8.90", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock }; sdk.stock.placeOrder(accounts.data[0],order,false); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { orderDate: "20241004", // 委託日期 (String) orderTime: "152549030", // 委託時間 (String) workDate: "20241004", // 有效交易日期 (String) isPreOrder: false, // 委託單狀態 (Bool) orderNo: "g0002" // 委託書編號 (String) } ``` --- ### 警示股票查詢 queryAttentionStock #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | symbol | String ( Optional ) | 股票代號 | #### AlertStockOutput 欄位[​](#alertstockoutput---欄位 "Direct link to AlertStockOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | ---------------------------- | ------ | ----------------------------------------------------------------- | | marketType | Int | 市場別 : `0` 上市、`1`上櫃、`3`興櫃 | | symbol | String | 股票代號 | | lowerLimitPrice | Double | 跌停價 | | closingPrice | Double | 收盤價 | | upperLimitPrice | Double | 漲停價 | | alertStartDate | String | 警示開始日期 | | alertEndDate | String | 警示結束日期 | | alertHandlingMode | Int | 警示處理模式 : `1` 受處置、`2`再處置 、 非`1`、`2` 為正常 | | stockName | String | 股票名稱 | | messageDescription | String | 訊息說明(風控股票提示) | | shortSellingAtFlatMark | String | 平盤下可否券賣(`1` 表示可平盤下券賣、不為 `1` 則不可平盤下券賣) | | shortSellingAtFlatAllowed | String | 平盤下可券賣狀態 ( 當股查詢時才有值 ) | | dayTradingAndAccount98Status | String | 是否可當沖及禁98戶 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py # 查詢全部 sdk.stock.queryAttentionStock(account) # 查詢單檔 sdk.stock.queryAttentionStock(account,"9945") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { marketType: 0, // 市場別 (Int) symbol: "9945", // 股票代號 (String) lowerLimitPrice: 43.65, // 當日跌停價 (Double) closingPrice: 48.45, // 當日收盤價 (Double) upperLimitPrice: 53.20, // 當日漲停價 (Double) alertStartDate: "20241008", // 警示開始日期 (String) alertEndDate: "20241011", // 警示結束日期 (String) alertHandlingMode: 0, // 警示處理模式 (Int) stockName: "潤泰新", // 股票名稱 (String) messageDescription: "風控股票,請務必查詢是否委託成功,或洽營業員辦理!", // 訊息說明 (String) shortSellingAtParMark: "1", // 平盤下可否券賣 (String) shortSellingAtParAllowed: "平盤下可券", // 平盤下可券賣狀態 (String) dayTradingAndAccount98Status: "禁當沖", // 當沖及帳戶98狀態 (String) } ``` --- ### 處置股票查詢 queryDispositionStock #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/nodejs/EnumMatrix.md#account) | 帳號 | | symbol | String | 股票代號 | #### StockStatusOutput 欄位[​](#stockstatusoutput--欄位 "Direct link to StockStatusOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | -------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | 股票代號 | | abnormalRecommendationMark | string | 異常推介註記 : `0` 表示正常、`1`投資理財節目異常推介 | | abnormalDescription | string | 異常說明 | | specialAbnormalMark | string | 特殊異常註記 : `0` 表示正常、`1`特殊異常有價證券 | | specialAbnormalDescription | string | 特殊異常說明 | | dispositionStockMark | string | 處置股票註記 : `0` 表示正常、`1` 處置股票、`2` 再次處置、`3` 彈性處置 | | dispositionDescription | string | 處置說明 | | internalControlCategory | string | 內控類別 : `0` 表示正常、`AA`委託超過 30 萬需預收、`A` 委託超過 50 萬需預收、`B` 委託超過 300 萬需預收、`C` 委託超過 500 萬需預收 | | internalControlDescription | string | 內控類別說明 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.queryDispositionStock(account,"4956") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { symbol: "4956", // 股票代號 (String) abnormalRecommendationMark: "0", // 異常推介註記 (String) : `0` 表示正常、`1`投資理財節目異常推介 abnormalDescription: "", // 異常說明 (String) specialAbnormalMark: "0", // 特殊異常註記 (String) : `0` 表示正常、`1`特殊異常有價證券 specialAbnormalDescription: "", // 特殊異常說明 (String) dispositionStockMark: "1", // 處置股票註記 (String) : `0` 表示正常、`1` 處置股票、`2` 再次處置、`3`彈性處置 dispositionDescription: "處置有價證券,請注意交易風險!", // 處置股票說明 (String) internalControlCategory: "0", // 內控類別 (String) : `0` 表示正常、`AA`委託超過 30 萬需預收、`A` 委託超過 50 萬需預收、`B` 委託超過 300 萬需預收、`C` 委託超過 500 萬需預收 internalControlDescription: "", // 內控類別說明 (String) } ``` --- ### 現沖券餘額查詢 shortDaytradeQuota #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | #### ShortResource 欄位[​](#shortresource--欄位 "Direct link to ShortResource 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----- | ------ | -------------- | | quota | String | 現沖券剩餘張數 | | total | String | 現冲券原始額度 | | used | String | 現冲券使用額度 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.shortDaytradeQuota(account, "2330") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { quota: "00000740", // 現沖券剩餘張數 (String) total: "00000740", // 現冲券原始額度 (String) used: "00000000", // 現冲券使用額度 (String) } ``` --- ### 對帳單查詢 account\_statment #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ------------ | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | String | 查詢起始日期 | | end\_date | String | 查尋迄日 | | symbol | String ( Optional ) | 股票代號 | #### 未實現 StatementResponse 欄位[​](#未實現-statementresponse--欄位 "Direct link to 未實現 StatementResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------------------------------------- | ------ | ------------------------------------------------------------------ | | income | String | 賣出 | | cost | String | 買入 | | net\_amount | String | 收付淨額 | | fee | String | 手續費 | | tax | String | 交易稅 | | margin\_short\_day\_trading\_profit\_loss | String | 融券當沖損益 | | common\_stock\_day\_trading\_profit\_loss | None | 普通股當沖損益 | | securities\_income\_tax | String | 證券所得稅 | | health\_insurance\_fee | String | 健保費 | | filled\_quantity | String | 成交股數 | | interest | String | 利息 | | short\_selling\_fee | String | 融券費 | | filled\_amount | String | 成交金額 | | payment\_gross\_total | String | 付款總額 | | profit\_loss | String | 損益 | | credit\_debit\_net\_amount | String | 信用貸款淨額 | | securities\_lending\_differential\_fee | String | 證券借貸價差費 | | account\_summary | Object | 帳戶摘要 | | └─ margin\_position\_market\_value\_sum | String | 融資市值總計 | | └─ short\_position\_market\_value\_sum | String | 融券市值總計 | | └─ short\_collateral\_sum | String | 融券擔保品總計 | | └─ margin\_limit | String | 融資限額 | | └─ short\_limit | String | 融券限額 | | └─ guarantee\_amount\_sum | String | 保證金總計 | | └─ margin\_amount\_sum | String | 融資金額總計 | | └─ short\_amount\_sum | String | 融券金額總計 | | └─ account\_maintenance\_rate | String | 帳戶維持率 | | └─ settlement\_today | String | 今日結算金額 | | └─ settlement\_yesterday | String | 昨日結算金額 | | └─ settlement\_net | String | 結算淨額 | | bill\_summary | Object | 帳單摘要 | | └─ common\_stock\_buy\_amount | String | 普通股買入金額 | | └─ common\_stock\_sell\_amount | String | 普通股賣出金額 | | └─ common\_stock\_fee | String | 普通股手續費 | | └─ common\_stock\_tax | String | 普通股稅金 | | └─ common\_stock\_st\_in\_tax | String | 普通股證交稅 | | └─ common\_stock\_net\_amount | String | 普通股淨額 | | └─ own\_funds\_amount | String | 自有資金金額 | | └─ margin\_amount | String | 融資金額 | | └─ margin\_fee | String | 融資手續費 | | └─ margin\_interest | String | 融資利息 | | └─ margin\_tax | String | 融資稅金 | | └─ margin\_securities\_income\_tax | String | 融資證券所得稅 | | └─ margin\_net\_amount | String | 融資淨額 | | └─ guarantee\_amount | String | 保證金金額 | | └─ short\_collateral | String | 融券擔保品 | | └─ short\_fee | String | 融券手續費 | | └─ short\_interest | String | 融券利息 | | └─ short\_health\_insurance\_fee | String | 融券健保費 | | └─ short\_net\_amount | String | 融券淨額 | | └─ profit\_loss | String | 損益 | | └─ buy\_quantity | String | 買進股數 | | └─ sell\_quantity | String | 賣出股數 | | └─ net\_amount | String | 淨額 | | └─ securities\_lending\_differential\_fee | String | 證券借貸價差費 | | filled\_records | list | 成交資訊 | | └─ branch\_id | String | 分公司代號 | | └─ cust\_id | String | 帳號 | | └─ name | String | 姓名 | | └─ symbol | String | 股票代號 | | └─ symbol\_name | String | 股票名 | | └─ filled\_date | String | 成交日期 | | └─ order\_no | String | 委託書號 | | └─ filled\_no | String | 成交序號 | | └─ order\_type | String | 委託別 : `0` 整股、`1 , 3` 融資、`2 , 4` 融券、`9` 現賣 ( 擔保品 ) | | └─ order\_type\_name | String | 委託別名稱 | | └─ buy\_sell | String | 買賣別 | | └─ buy\_sell\_name | String | 買賣別名稱 | | └─ market\_type | String | 盤別 | | └─ filled\_price | String | 成交價 | | └─ filled\_qty | String | 成交股數 | | └─ filled\_amount | String | 成交值 | | └─ tax | String | 交易稅 | | └─ fee | String | 手續費 | | └─ interest | String | 利息 | | └─ reverse\_interest | String | 融券利息 | | └─ margin\_amount | String | 信用金額 | | └─ short\_amount | String | 借貸金額 | | └─ short\_collateral | String | 擔保品 | | └─ guarantee\_amount | String | 融券保證金 | | └─ short\_selling\_fee | String | 融券手續費 | | └─ income | String | 淨收金額 | | └─ cost | String | 淨付金額 | | └─ securities\_lending\_fee | String | 標借費 | | └─ net\_amount | String | 預估淨額 | | └─ own\_funds\_amount | String | 自備款 | | └─ profit\_loss | String | 損益 | | └─ securities\_transaction\_income\_tax | String | 證所稅 | | └─ health\_insurance\_fee | String | 健保補充費 | | └─ is\_day\_trade | String | 是否為當沖 | | └─ securities\_lending\_differential\_fee | String | 證券借貸價差費 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.account_statment(account,"20241101","20241201") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py StatementResponse { income: "0", # 賣出 (String) cost: "0", # 買入 (String) net_amount: "0", # 收付淨額 (String) fee: "0", # 手續費 (String) tax: "0", # 交易稅 (String) margin_short_day_trading_profit_loss: "0", # 融券當沖損益 (String) common_stock_day_trading_profit_loss: None, # 普通股當沖損益 (String) securities_income_tax: "0", # 證券所得稅 (String) health_insurance_fee: "0", # 健保費 (String) filled_quantity: "0", # 成交股數 (String) interest: "0", # 利息 (String) short_selling_fee: "0", # 融券費 (String) filled_amount: "0", # 成交金額 (String) payment_gross_total: "0", # 付款總額 (String) profit_loss: "0", # 損益 (String) credit_debit_net_amount: "0", # 信用貸款淨額 (String) securities_lending_differential_fee: "0", # 證券借貸價差費 (String) account_summary: AccountSummary { margin_position_market_value_sum: "0", # 融資持倉市值總計 (String) short_position_market_value_sum: "0", # 融券持倉市值總計 (String) short_collateral_sum: "0", # 融券擔保品總計 (String) margin_limit: "0", # 融資限額 (String) short_limit: "0", # 融券限額 (String) guarantee_amount_sum: "0", # 保證金總計 (String) margin_amount_sum: "0", # 融資金額總計 (String) short_amount_sum: "0", # 融券金額總計 (String) account_maintenance_rate: "", # 帳戶維持率 (String) settlement_today: "0", # 今日結算金額 (String) settlement_yesterday: "0", # 昨日結算金額 (String) settlement_net: "0", # 結算淨額 (String) }, bill_summary: BillSummary { common_stock_buy_amount: "0", # 普通股買入金額 (String) common_stock_sell_amount: "0", # 普通股賣出金額 (String) common_stock_fee: "0", # 普通股手續費 (String) common_stock_tax: "0", # 普通股稅金 (String) common_stock_st_in_tax: "0", # 普通股證交稅 (String) common_stock_net_amount: "0", # 普通股淨額 (String) own_funds_amount: "0", # 自有資金金額 (String) margin_amount: "0", # 融資金額 (String) margin_fee: "0", # 融資手續費 (String) margin_interest: "0", # 融資利息 (String) margin_tax: "0", # 融資稅金 (String) margin_securities_income_tax: "0", # 融資證券所得稅 (String) margin_net_amount: "0", # 融資淨額 (String) guarantee_amount: "0", # 保證金金額 (String) short_collateral: "0", # 融券擔保品 (String) short_fee: "0", # 融券手續費 (String) short_interest: "0", # 融券利息 (String) short_health_insurance_fee: "0", # 融券健保費 (String) short_net_amount: "0", # 融券淨額 (String) profit_loss: "0", # 損益 (String) buy_quantity: "0", # 買進股數 (String) sell_quantity: "0", # 賣出股數 (String) net_amount: "0", # 淨額 (String) securities_lending_differential_fee: "0", # 證券借貸價差費 (String) }, filled_records: [ StatementFilledProfile { branch_id: "592a", # 分公司代號 (String) cust_id: "0456125", # 帳號 (String) name: "xxx", # 姓名 (String) symbol: "3231", # 股票代號 (String) symbol_name: "緯創", # 股票名 (String) filled_date: "20241119", # 成交日期 (String) order_no: "i9294", # 委託書號 (String) filled_no: "0000004", # 成交序號 (String) order_type: "0", # 委託別 (String) order_type_name: "現買", # 委託別名稱 (String) buy_sell: "B", # 買賣別 (String) buy_sell_name: "買", # 買賣別名稱 (String) market_type: "0", # 盤別 (String) filled_price: "113.5000", # 成交價 (String) filled_qty: "1000", # 成交股數 (String) filled_amount: "113500", # 成交值 (String) tax: "0", # 交易稅 (String) fee: "161", # 手續費 (String) interest: "0", # 利息 (String) reverse_interest: "0", # 融券利息 (String) margin_amount: "0", # 信用金額 (String) short_amount: "0", # 借貸金額 (String) short_collateral: "0", # 擔保品 (String) guarantee_amount: "0", # 融券保證金 (String) short_selling_fee: "0", # 融券手續費 (String) income: "0", # 淨收金額 (String) cost: "0", # 淨付金額 (String) securities_lending_fee: "0", # 標借費 (String) net_amount: "-113661", # 預估淨額 (String) own_funds_amount: "0", # 自備款 (String) profit_loss: "0", # 損益 (String) securities_transaction_income_tax: "0", # 證所稅 (String) health_insurance_fee: "0", # 健保補充費 (String) is_day_trade: "N", # 是否為當沖 (String) securities_lending_differential_fee: "0", # 證券借貸價差費 (String) }, ] } ``` --- ### 帳戶損益速查 account\_total\_pnl #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | #### 帳戶損益速查 AccountQuickInquiryResponse 欄位[​](#帳戶損益速查-accountquickinquiryresponse--欄位 "Direct link to 帳戶損益速查 AccountQuickInquiryResponse 欄位") | 參數 | 類別 | 說明 | | ---------------------------------------- | ------ | ------------------ | | unrealized\_profit\_loss\_cash | String | 未實現損益(現股) | | unrealized\_profit\_loss\_margin | String | 未實現損益(融資) | | unrealized\_profit\_loss\_short\_selling | String | 未實現損益(融券) | | unrealized\_profit\_loss\_total | String | 未實現損益總計 | | realized\_profit\_loss\_cash | String | 已實現損益(現股) | | realized\_profit\_loss\_margin | String | 已實現損益(融資) | | realized\_profit\_loss\_short\_selling | String | 已實現損益(融券) | | realized\_profit\_loss\_total | String | 已實現損益總計 | | day\_trading\_profit\_loss\_credit | String | 當沖損益(信用) | | day\_trading\_profit\_loss\_cash | String | 當沖損益(現股) | | net\_amount | String | 淨收付金額 | | account\_maintenance\_rate | string | 整戶維持率 | | total\_profit\_loss\_cash | String | 總損益(現股) | | total\_profit\_loss\_margin | String | 總損益(融資) | | total\_profit\_loss\_short\_selling | String | 總損益(融券) | | total\_profit\_loss | String | 總損益 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.account_total_pnl(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py AccountQuickInquiryResponse = { unrealized_profit_loss_cash: "82593", # 未實現損益(現股) (string) unrealized_profit_loss_margin: "0", # 未實現損益(融資) (string) unrealized_profit_loss_short_selling: "0", # 未實現損益(融券) (string) unrealized_profit_loss_total: "82593", # 未實現損益總計 (string) realized_profit_loss_cash: "0", # 已實現損益(現股) (string) realized_profit_loss_margin: "0", # 已實現損益(融資) (string) realized_profit_loss_short_selling: "0", # 已實現損益(融券) (string) realized_profit_loss_total: "0", # 已實現損益總計 (string) day_trading_profit_loss_credit: "0", # 當沖損益(信用) (string) day_trading_profit_loss_cash: "0", # 當沖損益(現股) (string) net_amount: "-2904132", # 淨收付金額 (string) account_maintenance_rate: None, # 整戶維持率 (string) total_profit_loss_cash: "82593", # 總損益(現股) (string) total_profit_loss_margin: "0", # 總損益(融資) (string) total_profit_loss_short_selling: "0", # 總損益(融券) (string) total_profit_loss: "82593", # 總損益 (string) } ``` --- ### 分戶帳銀行餘額查詢 info 如是約定新光銀交割,請用 [新光銀餘額查詢](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/accountManagement/SkBankBalance) bank\_balance #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 餘額 Bankbalace 欄位[​](#餘額-bankbalace-欄位 "Direct link to 餘額 Bankbalace 欄位") Return type : Object | 參數 | 類別 | 說明 | | --------------------------- | ------ | ------------ | | available\_balance | double | 可用餘額 | | reserved\_amount | double | 圈存金額 | | dedicated\_account\_balance | double | 專戶餘額 | | withdrawal\_bank\_code | string | 出金銀行代號 | | withdrawal\_bank | string | 出金銀行名稱 | | withdrawal\_account | string | 出金銀行帳號 | | deposit\_bank\_code | string | 入金銀行代號 | | deposit\_account | string | 入金銀行帳號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.bank_balance(accounts[0]) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Bankbalace{ available_balance: "7015.00", # 可用餘額 (double) reserved_amount: "2041.00", # 圈存金額 (double) dedicated_account_balance: "9056.00", # 專戶餘額 (double) withdrawal_bank_code: "803", # 出金銀行代號 (string) withdrawal_bank: "聯邦", # 出金銀行名稱 (string) withdrawal_account: "046508006075", # 出金銀行帳號 (string) deposit_bank_code: "1030851", # 入金銀行代號 (string) deposit_account: "89600221676687" # 入金銀行帳號 (string) } ``` --- ### 庫存與未實現損益查詢 inventories #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | #### PositionResponse 欄位[​](#positionresponse--欄位 "Direct link to PositionResponse 欄位") | 參數 | 類別 | 說明 | | --------------------------------------- | ------ | -------------------------------------------------------------------- | | no | string | 序號 | | prev\_day\_quantity | string | 昨日庫存股數 | | current\_quantity | string | 即時庫存股數 | | today\_quantity | string | 今日增減成交股數 | | today\_buy\_quantity | string | 今日買進成交數量 | | today\_sell\_quantity | string | 今日賣出成交數量 | | cost | string | 付出成本 | | market\_value | string | 現值 | | unrealized\_profit\_loss | string | 未實現損益 | | unrealized\_profit\_loss\_rate | string | 未實現損益率 | | securities\_transaction\_income\_tax | string | 證券交易所得稅 | | health\_insurance\_fee | string | 健保補充費 | | fee | string | 手續費 | | tax | string | 交易稅 | | open\_margin\_amount | string | 未償還融資/券金額 | | open\_guarantee\_amount | string | 未償還融券保證金 | | open\_short\_collateral | string | 未償還擔保品 | | short\_selling\_fee | string | 融券手續費 | | own\_funds\_amount | string | 自備款 | | other\_cost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | interest | string | 利息 | | unrealized\_net\_amount | string | 預估淨收付 | | total\_profit\_loss | string | 總損益 | | realized\_profit\_loss | string | 當日已實現損益 | | dividend\_amount | string | 除息金額 | | **account\_summary** | object | 帳戶摘要 | | └─ margin\_position\_market\_value\_sum | string | 融資市值加總 | | └─ short\_position\_market\_value\_sum | string | 融券市值加總 | | └─ short\_collateral\_sum | string | 融券擔保品加總 | | └─ margin\_limit | string | 融資限額 | | └─ short\_limit | string | 融券限額 | | └─ guarantee\_amount\_sum | string | 擔保金總和 | | └─ margin\_amount\_sum | string | 融資金額總和 | | └─ short\_amount\_sum | string | 融券金額總和 | | └─ account\_maintenance\_rate | string | 帳戶維持率 | | └─ settlement\_today | string | 今日交割 | | └─ settlement\_yesterday | string | 昨日交割 | | └─ settlement\_net | string | 淨交割金額 | | **position\_summaries** | array | 持倉摘要清單 | | └─ branch\_id | string | 分公司代號 | | └─ cust\_id | string | 帳號 | | └─ no | string | 序號 | | └─ symbol | string | 股票代碼 | | └─ name | string | 用戶名 | | └─ symbol\_name | string | 股票名稱 | | └─ stock\_evaluation | string | 股票評價 | | └─ order\_type | string | 交易類型 : `0` 整股、`1 , 3` 融資、`2 , 4` 融券、`9` 現賣 ( 擔保品 ) | | └─ order\_type\_name | string | 交易類型名稱 | | └─ buy\_sell | string | 買賣別 : `B`、`S` | | └─ prev\_day\_quantity | string | 昨日庫存股數 | | └─ current\_quantity | string | 即時庫存股數 | | └─ total\_quantity | string | 今日交易增減成交股數 | | └─ total\_buy\_quantity | string | 今日買進成交股數 | | └─ total\_sell\_quantity | string | 今日賣出成交股數 | | └─ cost | string | 成本 | | └─ cost\_before\_dividend | string | 成本 (不扣除息金額) | | └─ average\_price | string | 成交均價 | | └─ open\_margin\_amount | string | 未償還融資金額 | | └─ guarantee\_amount | string | 保證金 | | └─ open\_guarantee\_amount | string | 未償還融券保證金 | | └─ short\_collateral | string | 擔保品 | | └─ open\_short\_collateral | string | 未償還擔保品 | | └─ short\_selling\_fee | string | 融券手續費 | | └─ own\_funds\_amount | string | 自備款 | | └─ guarantee\_default\_amount | string | 擔保金缺額 | | └─ current\_price | string | 現價 | | └─ market\_value | string | 市值 | | └─ unrealized\_profit\_loss | string | 未實現損益 | | └─ unrealized\_profit\_loss\_rate | string | 未實現損益率 | | └─ fee | string | 手續費 | | └─ tax | string | 稅金 | | └─ interest | string | 利息 | | └─ other\_cost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | └─ unrealized\_net\_amount | string | 預估淨收付金額 | | └─ target\_price | string | 標的股票現價 | | └─ portfolio\_type | string | 權證種類 :`1` 認購權證、`2`認售權證、`3`牛證、`4`熊證、 `空白` 整股 | | └─ holding\_percent | string | 持有比率 | | └─ securities\_income\_tax | string | 證券所得稅 | | └─ health\_insurance\_fee | string | 健保補充費 | | └─ reference\_price | string | 參考價格 | | └─ total\_profit | string | 總損益 | | └─ realized\_profit | string | 當日已實現損益 | | └─ pledge\_quantity | string | 質押數量 | | └─ amount | string | 會總成交價金 | | └─ average\_filled\_price | string | 平均成交價格 | | └─ break\_even\_price | string | 損益兩平價格 | | └─ dividend\_amount | string | 股利金額 | | └─ **position\_details** | array | 持倉明細 | |   └─ no | string | 序號 | |   └─ t\_date | string | 成交日期 | |   └─ order\_type | string | 交易類型 : `0` 整股、`1 , 3` 融資、`2 , 4` 融券、`9` 現賣 ( 擔保品 ) | |   └─ order\_type\_name | string | 訂單類型名稱 | |   └─ buy\_sell | string | 買賣別 : `B`、`S` | |   └─ delegate\_sequence | string | 委託書號 | |   └─ filled\_no | string | 成交序號 | |   └─ filled\_quantity | string | 成交數量 | |   └─ prev\_day\_quantity | string | 昨日庫存股數 | |   └─ filled\_price | string | 成交價格 | |   └─ filled\_amount | string | 成交金額 | |   └─ current\_price | string | 現價 | |   └─ market\_value | string | 市值 | |   └─ margin\_amount | string | 融資金額 | |   └─ open\_margin\_amount | string | 未償還融資/券金額 | |   └─ short\_collateral | string | 融券抵押品 | |   └─ open\_short\_collateral | string | 未償還擔保品 | |   └─ guarantee\_amount | string | 保證金 | |   └─ open\_guarantee\_amount | string | 未償還融券保證金 | |   └─ securities\_lending\_fee | string | 標借費 | |   └─ short\_selling\_fee | string | 融券費手續費 | |   └─ fee | string | 手續費 | |   └─ tax | string | 交易稅 | |   └─ interest | string | 利息 | |   └─ cost | string | 收付金額 | |   └─ cost\_before\_dividend | string | 收付金額(不扣除息金額) | |   └─ change\_type | string | 異動別 | |   └─ own\_funds\_amount | string | 自備款 | |   └─ portfolio\_type | string | 權證種類 | |   └─ cust\_id | string | 帳號 | |   └─ name | string | 名稱 | |   └─ branch\_id | string | 分行 ID | |   └─ other\_cost | string | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ is\_adjustable | string | 是否可調整成本:`Y`開放、`N`不開放 | |   └─ securities\_income\_tax | string | 證券所得稅 | |   └─ health\_insurance\_fee | string | 健康保險費 | |   └─ unrealized\_profit\_loss | string | 未實現損益 | |   └─ reference\_price | string | 參考價格 | |   └─ io\_flag | string | 異動代碼 | |   └─ io\_name | string | 異動名稱 | |   └─ break\_even\_price | string | 損益兩平價格 | |   └─ dividend\_amount | string | 股利金額 | |   └─ guarantee\_default\_amount | string | 擔保金缺額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.inventories(accounts) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py PositionResponse { no: "合計", # 序號 (string) prev_day_quantity: "26796", # 昨日庫存股數 (string) current_quantity: "26796", # 即時庫存股數 (string) today_quantity: "0", # 今日增減成交股數 (string) today_buy_quantity: "0", # 今日買進成交數量 (string) today_sell_quantity: "0", # 今日賣出成交數量 (string) cost: "348817", # 付出成本 (string) market_value: "549957", # 現值 (string) unrealized_profit_loss: "198916", # 未實現損益 (string) unrealized_profit_loss_rate: "57.03%", # 未實現損益率 (string) securities_transaction_income_tax: "0", # 證券交易所得稅 (string) health_insurance_fee: "0", # 健保補充費 (string) fee: "489", # 手續費 (string) tax: "0", # 交易稅 (string) open_margin_amount: "0", # 未償還融資/券金額 (string) open_guarantee_amount: "0", # 未償還融券保證金 (string) open_short_collateral: "0", # 未償還擔保品 (string) short_selling_fee: "0", # 融券手續費 (string) own_funds_amount: "0", # 自備款 (string) other_cost: "0", # 其他費用 (string) interest: "0", # 利息 (string) unrealized_net_amount: "547733", # 預估淨收付 (string) total_profit_loss: "198916.00", # 總損益 (string) realized_profit_loss: "0", # 當日已實現損益 (string) dividend_amount: "360.00", # 除息金額 (string) account_summary: AccountSummary { margin_position_market_value_sum: "0", # 融資市值加總 (string) short_position_market_value_sum: "0", # 融券市值加總 (string) short_collateral_sum: "0", # 融券擔保品加總 (string) margin_limit: "0", # 融資限額 (string) short_limit: "0", # 融券限額 (string) guarantee_amount_sum: "0", # 擔保金總和 (string) margin_amount_sum: "0", # 融資金額總和 (string) short_amount_sum: "0", # 融券金額總和 (string) account_maintenance_rate: "0%", # 帳戶維持率 (string) settlement_today: "0", # 今日交割 (string) settlement_yesterday: "0", # 昨日交割 (string) settlement_net: "0", # 淨交割金額 (string) }, position_summaries: [ PositionSummary { branch_id: "5920", # 分公司代號 (string) cust_id: "1234567", # 帳號 (string) no: "1", # 序號 (string) symbol: "00885", # 股票代碼 (string) name: "許OO", # 用戶名 (string) symbol_name: "富邦越南", # 股票名稱 (string) stock_evaluation: "", # 股票評價 (string) order_type: "0", # 交易類型 (string) order_type_name: "現買", # 交易類型名稱 (string) buy_sell: "B", # 買賣別 (string) prev_day_quantity: "1000", # 昨日庫存股數 (string) current_quantity: "1000", # 即時庫存股數 (string) total_quantity: "0", # 今日交易增減成交股數 (string) total_buy_quantity: "0", # 今日買進成交股數 (string) total_sell_quantity: "0", # 今日賣出成交股數 (string) cost: "16173", # 成本 (string) cost_before_dividend: "16173.00", # 成本 (不扣除息金額) (string) average_price: "16.17", # 成交均價 (string) open_margin_amount: "0", # 未償還融資金額 (string) guarantee_amount: "0", # 保證金 (string) open_guarantee_amount: "0", # 未償還融券保證金 (string) short_collateral: "0", # 擔保品 (string) open_short_collateral: "0", # 未償還擔保品 (string) short_selling_fee: "0", # 融券手續費 (string) own_funds_amount: "0", # 自備款 (string) guarantee_default_amount: "0", # 擔保金缺額 (string) current_price: "11.7", # 現價 (string) market_value: "11700", # 市值 (string) unrealized_profit: None, # 未實現損益 (None) unrealized_profit_loss_rate: "-27.85%", # 未實現損益率 (string) fee: "23", # 手續費 (string) tax: "0", # 稅金 (string) interest: "0", # 利息 (string) other_cost: "0", # 其他成本 (string) unrealized_net_amount: "11669", # 預估淨收付金額 (string) target_price: "0", # 標的股票現價 (string) portfolio_type: "", # 權證種類 (string) holding_percent: "2.13%", # 持有比率 (string) securities_income_tax: "0", # 證券所得稅 (string) health_insurance_fee: "0", # 健保補充費 (string) reference_price: "0", # 參考價格 (string) total_profit: "-4504.00", # 總損益 (string) realized_profit: "0", # 當日已實現損益 (string) pledge_quantity: "1000", # 質押數量 (string) amount: "16150.00", # 會總成交價金 (string) average_filled_price: "16.15", # 平均成交價格 (string) break_even_price: "16.22", # 損益兩平價格 (string) dividend_amount: "0", # 股利金額 (string) position_details: [ PositionDetail { no: "1", # 序號 (string) t_date: "20210419", # 成交日期 (string) order_type: "0", # 交易類型 (string) order_type_name: "現買", # 訂單類型名稱 (string) buy_sell: "B", # 買賣別 (string) delegate_sequence: "i0317", # 委託書號 (string) filled_no: "0000001", # 成交序號 (string) filled_quantity: "1000", # 成交數量 (string) prev_day_quantity: "1000", # 昨日庫存股數 (string) filled_price: "16.15", # 成交價格 (string) filled_amount: "16150.00", # 成交金額 (string) current_price: "11.7", # 現價 (string) market_value: "11700", # 市值 (string) margin_amount: "0", # 融資金額 (string) open_margin_amount: "0", # 未償還融資/券金額 (string) short_collateral: "0", # 融券抵押品 (string) open_short_collateral: "0", # 未償還擔保品 (string) guarantee_amount: "0", # 保證金 (string) open_guarantee_amount: "0", # 未償還融券保證金 (string) securities_lending_fee: "0",# 標借費 (string) short_selling_fee: "0", # 融券費手續費 (string) fee: "23", # 手續費 (string) tax: "0", # 交易稅 (string) interest: "0", # 利息 (string) cost: "16173", # 收付金額 (string) cost_before_dividend: "16173", # 收付金額(不扣除息金額) (string) change_type: "0", # 異動別 (string) own_funds_amount: "0", # 自備款 (string) portfolio_type: "", # 權證種類 (string) cust_sequence: "1234567", # 帳號序號 (string) name: "許OO", # 名稱 (string) branch_id: "5920", # 分行 ID (string) other_cost: "0", # 其他成本 (string) is_adjusted: None, # 是否可調整 (None) securities_income_tax: "0", # 證券所得稅 (string) health_insurance_fee: "0", # 健康保險費 (string) unrealized_profit_loss: "-4504", # 未實現損益 (string) unrealized_profit_loss_rate: None, # 未實現損益率 (None) reference_price: "0", # 參考價格 (string) io_flag: "", # 異動代碼 (string) io_name: "", # 異動名稱 (string) break_even_price: "16.22", # 損益兩平價格 (string) dividend_amount: "0", # 股利金額 (string) guarantee_default_amount: "0" # 擔保金缺額 (string) }, ], }, ... ] } ``` --- ### 歷史交割款查詢 history\_settlement #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ------------ | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢起始日期 | | end\_date | string | 查詢結束日期 | #### 交割款 SettlementResponse 欄位[​](#交割款-settlementresponse--欄位 "Direct link to 交割款 SettlementResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | --------------------------------------- | ------ | -------------- | | account\_summary | Object | 帳戶摘要 | | └─ margin\_position\_market\_value\_sum | String | 融資市值加總 | | └─ short\_position\_market\_value\_sum | String | 融券市值加總 | | └─ short\_collateral\_sum | String | 融券擔保品加總 | | └─ margin\_limit | String | 融資限額 | | └─ short\_limit | String | 融券限額 | | └─ guarantee\_amount\_sum | String | 融券保證金加總 | | └─ margin\_amount\_sum | String | 融資金額加總 | | └─ short\_amount\_sum | String | 融券金額加總 | | └─ settlement\_today | String | 今日結算金額 | | └─ settlement\_yesterday | String | 昨日結算金額 | | └─ settlement\_net | String | 結算淨額 | | settlements | Array | 結算記錄 | | └─ branch\_id | String | 分公司代號 | | └─ cust\_id | String | 帳號 | | └─ s\_date | String | 交割日期 | | └─ t\_date | String | 交易日期 | | └─ net\_amount | String | 淨收付金額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.history_settlement(account,"20241001","20241010") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py SettlementResponse = { account_summary: { # 帳戶摘要 (AccountSummary object) margin_position_market_value_sum: "0", # 融資市值加總 (string) short_position_market_value_sum: "0", # 融券市值加總 (string) short_collateral_sum: "0", # 融券擔保品加總 (string) margin_limit: "0", # 融資限額 (string) short_limit: "0", # 融券限額 (string) guarantee_amount_sum: "0", # 融券保證金加總 (string) margin_amount_sum: "0", # 融資金額加總 (string) short_amount_sum: "0", # 融券金額加總 (string) settlement_today: "0", # 今日交割金額 (string) settlement_yesterday: "0", # 昨日交割金額 (string) settlement_net: "0", # 交割金額 (string) }, settlements: [ # 結算記錄 (Array) SettlementDailySummary { branch_id: "592a", # 分公司代號 cust_id: "123456", # 帳號 s_date: "20241014", # 交割日期 t_date: "20241009", # 交易日期 net_amount: "-1640300.00" # 淨收付金額 } ] } ``` --- ### 今日交割款查詢 today\_settlement #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | ---- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | #### 交割款 PaymentResponse 欄位[​](#交割款-paymentresponse-欄位 "Direct link to 交割款 PaymentResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ---------------------------- | ------ | ------------------ | | s\_date | String | 交割日期 | | t\_date | String | 交易日期 | | net\_amount | String | 總淨收付金額 | | settle\_sum | Object | 現金結算彙總 | | └─ buy\_amount | String | 今日現股買金額 | | └─ sell\_amount | String | 今日現股賣金額 | | └─ fee | String | 手續費 | | └─ tax | String | 交易稅 | | └─ net\_amount | String | 淨收付金額 | | settle\_credit\_sum | Object | 融資結算摘要 | | └─ margin\_quantity | String | 當日融資額度 | | └─ margin\_quantity\_left | String | 當日可用融資餘額 | | └─ margin\_collateral | String | 融資自備款 | | └─ margin\_collateral\_buy | String | 融資自備款買入 | | └─ margin\_collateral\_sell | String | 融資自備款賣出 | | └─ margin\_amount | String | 融資金額 | | └─ margin\_amount\_buy | String | 融資買入金額 | | └─ margin\_amount\_sell | String | 融資賣出金額 | | └─ margin\_net\_amount\_buy | String | 融資買入應收付金額 | | └─ margin\_net\_amount\_sell | String | 融資賣出應收付金額 | | └─ interest | String | 融資利息 | | └─ fee | String | 手續費 | | └─ tax | String | 交易稅 | | └─ net\_amount | String | 淨收付金額 | | settle\_debit\_sum | Object | 融券結算摘要 | | └─ short\_quantity | String | 當日融券額度 | | └─ short\_quantity\_left | String | 當日可用融資餘額 | | └─ guarantee\_amount | String | 融券保證金 | | └─ guarantee\_amount\_buy | String | 融券保證金券買 | | └─ guarantee\_amount\_sell | String | 融券保證金券賣 | | └─ short\_collateral | String | 融券擔保品 | | └─ short\_collateral\_buy | String | 融券擔保品券買 | | └─ short\_collateral\_sell | String | 融券擔保品券賣 | | └─ short\_net\_amount\_buy | String | 融券券買應收付金額 | | └─ short\_net\_amount\_sell | String | 融券券賣應收付金額 | | └─ short\_selling\_fee | String | 融券手續費 | | └─ interest | String | 融券利息 | | └─ net\_amount | String | 融券淨收付金額 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.today_settlement(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py PaymentResponse = { s_date: "20241209", # 交割日期 (string) t_date: "20241205", # 交易日期 (string) net_amount: "-150213", # 總淨收付金額 (string) settle_sum: { # 現金結算摘要 buy_amount: "150000", # 今日現股買金額 (string) sell_amount: "0", # 今日現股賣金額 (string) fee: "213", # 手續費 (string) tax: "0", # 交易稅 (string) net_amount: "0", # 淨金額 (string) }, settle_credit_sum: { # 融資結算摘要 margin_quantity: "0", # 當日融資額度 (string) margin_quantity_left: "0", # 剩餘融資數量 (string) open_short_collateral: "0", # 融資自備款 (string) open_short_collateral_buy: "0", # 融資自備款買入 (string) open_short_collateral_sell: "0", # 融資自備款賣出 (string) margin_amount: "0", # 融資金額 (string) margin_amount_buy: "0", # 融資買入金額 (string) margin_amount_sell: "0", # 融資賣出金額 (string) margin_net_amount_buy: "0", # 融資淨買入金額 (string) margin_net_amount_sell: "0", # 融資淨賣出金額 (string) interest: "0", # 融資利息 (string) fee: "0", # 費用 (string) tax: "0", # 交易稅 (string) net_amount: "0", # 融資淨額 (string) }, settle_debit_sum: { # 融券結算摘要 (SettlementShortSummary object) short_quantity: "0", # 融券數量 (string) short_quantity_left: "0", # 當日可用融資餘額 (string) guarantee_amount: "0", # 保證金金額 (string) guarantee_amount_buy: "0", # 融券保證金券買 (string) guarantee_amount_sell: "0", # 融券保證金券賣 (string) short_collateral: "0", # 融券擔保品 (string) short_collateral_buy: "0", # 融券擔保品券買 (string) short_collateral_sell: "0", # 融券擔保品券賣 (string) short_net_amount_buy: "0", # 融券券買應收付金額 (string) short_net_amount_sell: "0", # 融券券賣應收付金額 (string) short_selling_fee: "0", # 融券手續費 (string) interest: "0", # 融券利息 (string) net_amount: "0", # 融券淨收付金額 (string) } } ``` --- ### 已實現損益查詢 realized\_profit\_and\_loses #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢起始日 ( YYYYMMDD ) | | end\_date | string | 查詢終止日 ( YYYYMMDD ) | | symbol | string | 股票代號 | #### 已實現 Realized 欄位[​](#已實現-realized-欄位 "Direct link to 已實現 Realized 欄位") Return type : Object | Parameter | Type | Description | | ------------------------------------------- | ------ | ------------------------------------------------------------------------------------------- | | no | String | 編號 | | cost | String | 買入成本 | | income | String | 賣出成本 | | profit\_loss | String | 損益 | | profit\_loss\_rate | String | 損益率 | | accumulated\_cost | String | 累計成本 | | accumulated\_profit\_loss | String | 累計損益 | | accumulated\_profit\_loss\_rate | String | 累計損益率 | | short\_selling\_fee | String | 融券手續費 | | interest | String | 利息 | | closed\_margin\_amount | String | 償還融資金額 | | dividend\_amount | String | 股利金額 | | securities\_lending\_differential\_fee | String | 券差借券費 | | **profit\_loss\_summary** | List | 損益摘要 | | └─ no | String | 編號 | | └─ t\_date | String | 交易日期 | | └─ branch\_id | String | 分公司代號 | | └─ cust\_id | String | 帳號 | | └─ name | String | 客戶姓名 | | └─ order\_type | String | 委託別 (`0` 整股, `1,3` 融資, `2,4` 融券, `9` 現賣) | | └─ order\_type\_name | String | 委託類型名稱 | | └─ buy\_sell | String | 買賣別 (`B`, `S`) | | └─ symbol | String | 股票代號 | | └─ symbol\_name | String | 股票名稱 | | └─ target\_price | String | 標的現價 | | └─ portfolio\_type | String | 權證種類 - | | └─ order\_no | String | 委託序號 | | └─ filled\_no | String | 成交序號 | | └─ closed\_quantity | String | 沖銷股數 | | └─ filled\_price | String | 成交價格 | | └─ closed\_margin\_amount | String | 償還融資金額 | | └─ closed\_short\_collateral | String | 償還擔保品 | | └─ closed\_guarantee\_amount | String | 償還融券保證金 | | └─ interest | String | 利息 | | └─ short\_selling\_fee | String | 借券費 | | └─ cost | String | 成本 | | └─ cost\_before\_dividend | String | 成本 (不扣除息金額) | | └─ income | String | 賣出收入 | | └─ profit\_loss | String | 損益 | | └─ profit\_loss\_rate | String | 損益率 | | └─ other\_cost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | | └─ close\_type | String | 沖銷類別 (`0` 現股, `1` 融資, `2` 融券, `3` 信用當沖, `4` 現股當沖, `5` 現賣) | | └─ order\_type\_name\_2 | String | 委託類別名稱 | | └─ dividend\_amount | String | 除息金額 | | └─ securities\_lending\_differential\_fee | String | 券差借券費 | | **buy\_detail** | object | 買入詳情 | |   └─ filled\_quantity | String | 成交數量 | |   └─ filled\_amount | String | 成交金額 | |   └─ net\_amount | String | 淨收付 | |   └─ margin\_amount | String | 融資金額 | |   └─ guarantee\_amount | String | 保證金金額 | |   └─ short\_collateral | String | 融券擔保品 | |   └─ securities\_lending\_fee | String | 標借費 | |   └─ adjustment\_date | String | 調整日期 | |   └─ order\_type | String | 委託別 : `0` 整股、`1、3`融資、`2、4`融券、 `9`現賣(擔保品) | |   └─ order\_type\_name | String | 委託類型名稱 | |   └─ buy\_sell | String | 買賣方向 | |   └─ change\_type | String | 變更類型 | |   └─ is\_adjusted | String | 是否開放調整成本 | |   └─ io\_flag | String | 異動代碼 | |   └─ io\_name | String | 異動名稱 | |   └─ no | String | 編號 | |   └─ t\_date | String | 交易日期 | |   └─ order\_no | String | 委託序號 | |   └─ filled\_no | String | 成交序號 | |   └─ closed\_quantity | String | 沖銷股數 | |   └─ filled\_price | String | 成交價格 | |   └─ closed\_margin\_amount | String | 償還融資金額 | |   └─ closed\_shortCollateral | String | 償還擔保品 | |   └─ closed\_guarantee\_amount | String | 償還融券保證金 | |   └─ fee | String | 手續費 | |   └─ interest | String | 利息 | |   └─ tax | String | 稅金 | |   └─ short\_selling\_fee | String | 借券費 | |   └─ cost | String | 成本 | |   └─ cost\_before\_dividend | String | 成本 (不扣除息金額) | |   └─ income | String | 賣出收入 | |   └─ profit\_loss | String | 損益 | |   └─ profit\_loss\_rate | String | 損益率 | |   └─ other\_cost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ close\_type | String | 沖銷類別 : `0`現股、`1`融資、`2`融券、`3`信用當沖、`4`現股當沖、`5`現賣(未買回)/券差(買進) | |   └─ securities\_transaction\_tax | String | 證所稅 | |   └─ health\_insurance\_premium | String | 健保補充費 | |   └─ order\_type\_name2 | String | 委託類別 | |   └─ dividend\_amount | String | 除息金額 | |   └─ securities\_lending\_differential\_fee | String | 券差借券費 | | **sell\_detail** | object | 賣出詳情 | |   └─ filled\_quantity | String | 成交數量 | |   └─ filled\_amount | String | 成交金額 | |   └─ net\_amount | String | 淨收付 | |   └─ margin\_amount | String | 融資金額 | |   └─ guarantee\_amount | String | 保證金金額 | |   └─ short\_collateral | String | 融券擔保品 | |   └─ securities\_lending\_fee | String | 標借費 | |   └─ adjustment\_date | String | 調整日期 | |   └─ order\_type | String | 委託別 : `0` 整股、`1、3`融資、`2、4`融券、 `9`現賣(擔保品) | |   └─ order\_type\_name | String | 委託類型名稱 | |   └─ buy\_sell | String | 買賣方向 | |   └─ change\_type | String | 變更類型 | |   └─ is\_adjusted | String | 是否開放調整成本 | |   └─ io\_flag | String | 異動代碼 | |   └─ io\_name | String | 異動名稱 | |   └─ no | String | 編號 | |   └─ t\_date | String | 交易日期 | |   └─ order\_no | String | 委託序號 | |   └─ filled\_no | String | 成交序號 | |   └─ closed\_quantity | String | 沖銷股數 | |   └─ filled\_price | String | 成交價格 | |   └─ closed\_margin\_amount | String | 償還融資金額 | |   └─ closed\_shortCollateral | String | 償還擔保品 | |   └─ closed\_guarantee\_amount | String | 償還融券保證金 | |   └─ fee | String | 手續費 | |   └─ interest | String | 利息 | |   └─ tax | String | 稅金 | |   └─ short\_selling\_fee | String | 借券費 | |   └─ cost | String | 成本 | |   └─ cost\_before\_dividend | String | 成本 (不扣除息金額) | |   └─ income | String | 賣出收入 | |   └─ profit\_loss | String | 損益 | |   └─ profit\_loss\_rate | String | 損益率 | |   └─ other\_cost | String | 其他費用 ( 除手續費、交易稅外的費用項目 (資/券利息也包含在內) ) | |   └─ close\_type | String | 沖銷類別 : `0`現股、`1`融資、`2`融券、`3`信用當沖、`4`現股當沖、`5`現賣(未買回)/券差(買進) | |   └─ securities\_transaction\_tax | String | 證所稅 | |   └─ health\_insurance\_premium | String | 健保補充費 | |   └─ order\_type\_name2 | String | 委託類別 | |   └─ dividend\_amount | String | 除息金額 | |   └─ securities\_lending\_differential\_fee | String | 券差借券費 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.realized_profit_and_loses(account,"20241101","20241201") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py RealizedProfitLossResponse = { no: "合計", # 編號 ( String ) cost: "83618", # 買入總成本 ( String ) income: "81462", # 賣出總收入 ( String ) profit_loss: "-2156", # 總損益 ( String ) profit_loss_rate: "-2.58%", # 總損益率 ( String ) accumulated_cost: "0", # 累計成本 ( String ) accumulated_profit_loss: "-2156", # 累計損益 ( String ) accumulated_profit_loss_rate: "-2.58%", # 累計損益率 ( String ) short_selling_fee: "0", # 融券手續費 ( String ) interest: "0", # 利息 ( String ) closed_margin_amount : "0", # 償還融資金額 ( String ) dividend_amount : "0", # 股利金額 ( String ) securities_lending_differential_fee : "0", # 券差借券費 ( String ) profit_loss_summary : [ { no : "1", # 編號 ( String ) t_date : "20240808", # 交易日期 ( String ) filled_no : "0000001", # 成交編號 ( String ) closed_quantity : "1000", # 平倉數量 ( String ) filled_price : "81.70", # 成交價格 ( String ) closed_margin_amount : "0", # 償還融資金額 ( String ) closed_short_collateral : "0", # 償還擔保品 ( String ) closed_guarantee_amount : "0", # 償還保證金 ( String ) interest : "0", # 利息 ( String ) short_selling_fee : "0", # 融券費用 ( String ) cost : "83618", # 買入成本 ( String ) cost_before_dividend : "83618", # 買入成本 (未扣除股息) ( String ) income : "81462", # 賣出收入 ( String ) profit_loss : "-2156", # 損益 ( String ) profit_loss_rate : "-2.58%", # 損益率 ( String ) other_cost : "0", # 其他成本 ( String ) closed_type : "4", # 平倉類型 ( String ) order_type_name2 : "現沖", # 委託類型名稱2 ( String ) dividend_amount : "0", # 股息金額 ( String ) securities_lending_differential_fee : "0", # 券差借券費 ( String ) branch_id : "5920", # 分公司代號 ( String ) cust_id : "9816000", # 客戶帳號 ( String ) name : "陳XXX", # 客戶姓名 ( String ) order_type : "0", # 委託類型 ( String ) order_type_name : "現股", # 委託類型名稱 ( String ) buy_sell : "Sell", # 買賣方向 ( String ) symbol : "3663", # 股票代號 ( String ) symbol_name : "鑫科", # 股票名稱 ( String ) target_price : "0", # 標的價格 ( String ) portfolio_type : "", # 投資組合類型 ( String ) buy_detail: RealizedProfitLossDetail { no : "1", # 編號 ( String ) t_date : "20240808", # 交易日期 ( String ) order_no : "o0179", # 委託序號 ( String ) filled_no : "0000002", # 成交編號 ( String ) closed_quantity : "1000", # 平倉股數 ( String ) filled_price : "83.50", # 成交價格 ( String ) closed_margin_amount : "0", # 償還融資金額 ( String ) closed_short_collateral : "0", # 償還擔保品 ( String ) closed_guarantee_amount : "0", # 償還保證金 ( String ) fee : "118", # 手續費 ( String ) interest : "0", # 利息 ( String ) tax : "0", # 稅金 ( String ) short_selling_fee : "0", # 融券費用 ( String ) cost : "83618", # 買入成本 ( String ) cost_before_dividend : "83618", # 買入成本 (未扣除股息) ( String ) income : "81462", # 賣出收入 ( String ) profit_loss : "-2156", # 損益 ( String ) profit_loss_rate : "-2.58%", # 損益率 ( String ) other_cost : "0", # 其他成本 ( String ) closed_type : "4", # 平倉類型 ( String ) securities_transaction_tax : "0", # 證券交易稅 ( String ) health_insurance_premium : "0", # 健保費用 ( String ) order_type_name2 : "買沖", # 委託類型名稱2 ( String ) dividend_amount : "0", # 股息金額 ( String ) securities_lending_differential_fee : "0", # 券差借券費 ( String ) filled_quantity : "1000", # 成交數量 ( String ) filled_amount : "83500", # 成交金額 ( String ) net_amount : "-83618", # 淨支付金額 ( String ) margin_amount : "0", # 融資金額 ( String ) guarantee_amount : "0", # 保證金金額 ( String ) short_collateral : "0", # 融券擔保品 ( String ) securities_lending_fee : "0", # 證券借貸費用 ( String ) adjustment_date : "", # 調整日期 ( String ) order_type : "0", # 委託類型 ( String ) order_type_name : "現股", # 委託類型名稱 ( String ) buy_sell : "B", # 買賣方向 ( String ) change_type : "0", # 變更類型 ( String ) is_adjusted : "N", # 是否已調整 ( String ) io_flag : "", # 異動代碼 ( String ) io_name : "", # 異動名稱 ( String ) }, sell_detail : RealizedProfitLossDetail { no : "1", # 編號 ( String ) t_date : "20240808", # 交易日期 ( String ) order_no : "g0050", # 委託序號 ( String ) filled_no : "0000001", # 成交編號 ( String ) closed_quantity : "1000", # 平倉股數 ( String ) filled_price : "81.70", # 成交價格 ( String ) closed_margin_amount : "0", # 償還融資金額 ( String ) closed_short_collateral : "0", # 償還擔保品 ( String ) closed_guarantee_amount : "0", # 償還保證金 ( String ) fee : "116", # 手續費 ( String ) interest : "0", # 利息 ( String ) tax : "122", # 稅金 ( String ) short_selling_fee : "0", # 融券費用 ( String ) cost : "0", # 成本 ( String ) cost_before_dividend : "0", # 成本 (未扣除股息) ( String ) income : "81462", # 賣出收入 ( String ) profit_loss : "0", # 損益 ( String ) profit_loss_rate : "100.00%", # 損益率 ( String ) other_cost : "0", # 其他成本 ( String ) closed_type : "4", # 平倉類型 ( String ) securities_transaction_tax : "0", # 證券交易稅 ( String ) health_insurance_premium : "0", # 健保費用 ( String ) order_type_name2 : "賣沖", # 委託類型名稱2 ( String ) dividend_amount : "0", # 股息金額 ( String ) securities_lending_differential_fee : "0", # 券差借券費 ( String ) filled_quantity : "1000", # 成交數量 ( String ) filled_amount : "81700", # 成交金額 ( String ) net_amount : "81462", # 淨收入金額 ( String ) margin_amount : "0", # 融資金額 ( String ) guarantee_amount : "0", # 保證金金額 ( String ) short_collateral : "0", # 融券擔保品 ( String ) securities_lending_fee : "0", # 證券借貸費用 ( String ) adjustment_date : "", # 調整日期 ( String ) order_type : "0", # 委託類型 ( String ) order_type_name : "現股", # 委託類型名稱 ( String ) buy_sell : "S", # 買賣方向 ( String ) change_type : "", # 變更類型 ( String ) is_adjusted : None, # 是否已調整 ( None 或 String ) io_flag : "", # 異動代碼 ( String ) io_name : "", # 異動名稱 ( String ) } } ] } ``` --- ### 新光銀行餘額查詢 info 如是約定分戶帳交割,請用 [分戶帳餘額查詢](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/accountManagement/Balance.md) skbank\_balance #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 餘額 SKBankbalace 欄位[​](#餘額-skbankbalace-欄位 "Direct link to 餘額 SKBankbalace 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------ | ------ | -------- | | balance | double | 帳戶餘額 | | available\_balance | double | 可用餘額 | | currency | string | 幣別 | | branch\_id | string | 分公司 | | cust\_id | string | 帳號 | | bank\_account | string | 銀行帳號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.skbank_balance(account[0]) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py SKBankbalace{ balance: "7015.00", # 帳戶餘額 (double) available: "7015.00", # 可用餘額 (double) currency: "TWD", # 幣別 (string) branch_id: "592W", # 分公司代號 (string) cust_id: "1222344", # 證券帳號 (string) bank_account: "046508006075" # 銀行帳號 (string) } ``` --- ### 今日買賣日報與即時庫存 today\_trade\_summary #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | symbol | String ( Optional ) | 股票代號 | #### RealtimePositionQuantityOutput 欄位[​](#realtimepositionquantityoutput--欄位 "Direct link to RealtimePositionQuantityOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------------------------------------------- | ------ | ---------------------------------------- | | symbol | String | 股票代號 | | market\_type | String | 市場別 : `T` 上市 、 `O` 上櫃、 `R` 興櫃 | | common\_stock\_quantity | String | 昨日餘額普通股股數 | | margin\_stock\_quantity | String | 昨日餘額融資股數 | | short\_stock\_quantity | String | 昨日餘額融券股數 | | odd\_lot\_quantity | String | 昨日餘額零股股數 | | real\_time\_depository\_quantity | String | 今日餘額普通股股數 | | real\_time\_margin\_quantity | String | 今日餘額融資股數 | | real\_time\_short\_selling\_quantity | String | 今日餘額融券股數 | | real\_time\_odd\_lot\_quantity | String | 今日餘額零股股數 | | today\_depository\_buy\_order\_quantity | String | 今日普通股委託買進股數 | | today\_margin\_buy\_order\_quantity | String | 今日融資委託買進股數 | | today\_short\_selling\_buy\_order\_quantity | String | 今日融券委託買進股數 | | today\_odd\_lot\_buy\_order\_quantity | String | 今日零股委託買進股數 | | today\_depository\_sell\_order\_quantity | String | 今日普通股委託賣出股數 | | today\_margin\_sell\_order\_quantity | String | 今日融資委託賣出股數 | | today\_short\_selling\_sell\_order\_quantity | String | 今日融券委託賣出股數 | | today\_odd\_lot\_sell\_order\_quantity | String | 今日零股委託賣出股數 | | today\_depository\_buy\_executed\_quantity | String | 今日普通股買進成交股數 | | today\_margin\_buy\_executed\_quantity | String | 今日融資買進成交股數 | | today\_short\_selling\_buy\_executed\_quantity | String | 今日融券買進成交股數 | | today\_odd\_lot\_buy\_executed\_quantity | String | 今日零股買進成交股數 | | today\_depository\_sell\_executed\_quantity | String | 今日普通股賣出成交股數 | | today\_margin\_sell\_executed\_quantity | String | 今日融資賣出成交股數 | | today\_short\_selling\_sell\_executed\_quantity | String | 今日融券賣出成交股數 | | today\_odd\_lot\_sell\_executed\_quantity | String | 今日零股賣出成交股數 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.accounting.today_trade_summary(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py RealtimePositionQuantityOutput { symbol: "1108", # 商品代碼 (String) market_type: "T", # 市場別 (String) : T 上市 、 O 上櫃、 R 興櫃 common_stock_quantity: "0", # 昨日餘額普通股股數 (String) margin_stock_quantity: "0", # 昨日餘額融資股數 (String) short_selling_quantity: "0", # 昨日餘額融券股數 (String) odd_lot_quantity: "0", # 昨日餘額零股股數 (String) real_time_depository_quantity: "1000", # 即時普通股股數 (String) real_time_margin_quantity: "0", # 即時融資股數 (String) real_time_short_selling_quantity: "0", # 即時融券股數 (String) real_time_odd_lot_quantity: "0", # 即時零股股數 (String) today_depository_buy_order_quantity: "1000", # 今日普通股委託買進股數 (String) today_margin_buy_order_quantity: "0", # 今日融資委託買進股數 (String) today_short_selling_buy_order_quantity: "0", # 今日融券委託買進股數 (String) today_odd_lot_buy_order_quantity: "0", # 今日零股委託買進股數 (String) today_depository_sell_order_quantity: "0", # 今日普通股委託賣出股數 (String) today_margin_sell_order_quantity: "0", # 今日融資委託賣出股數 (String) today_short_selling_sell_order_quantity: "0", # 今日融券委託賣出股數 (String) today_odd_lot_sell_order_quantity: "0", # 今日零股委託賣出股數 (String) today_depository_buy_executed_quantity: "1000", # 今日普通股買進成交股數 (String) today_margin_buy_executed_quantity: "0", # 今日融資買進成交股數 (String) today_short_selling_buy_executed_quantity: "0", # 今日融券買進成交股數 (String) today_odd_lot_buy_executed_quantity: "0", # 今日零股買進成交股數 (String) today_depository_sell_executed_quantity: "0", # 今日普通股賣出成交股數 (String) today_margin_sell_executed_quantity: "0", # 今日融資賣出成交股數 (String) today_short_selling_sell_executed_quantity: "0", # 今日融券賣出成交股數 (String) today_odd_lot_sell_executed_quantity: "0", # 今日零股賣出成交股數 (String) } ``` --- ### 參數對照表 #### 類別[​](#類別 "Direct link to 類別") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | --------------- | --------------------------- | ------------------------------------------------------------------------------------------------------- | | buy\_sell | [BSAction](#bsaction) | 買賣別 : `Buy`、`Sell` | | stock\_no | string | 股票代號 | | price | string | 委託價格 | | quantity | int | 委託數量 | | market\_type | [MarketType](#markettype) | 盤別 可選用參數`Common` 整股、`Fixing`定盤、`IntradayOdd` 盤中零股、`Odd` 盤後零股、`Emg` 興櫃 | | price\_type | [PriceType](#pricetype) | 價格旗標 : 可選用參數為 `Limit`限價、`LimitUp`漲停、`LimitDown`跌停、`Market`市價、`Reference`平盤 | | time\_in\_force | [TimeInForce](#timeinforce) | 委託條件: 可選用參數為 `ROD`、`FOK`、`IOC` | | order\_type | [OrderType](#ordertype) | 委託類別 : 可選用參數為 `Stock`現股、`Margin`融資、`Short`融券、`DayTradeShort`現股當沖(for 現沖先賣) | caution 不同 MarketType 對應的 quantity 之單位及範圍不同,請參考 [盤別](#markettype) 說明。 caution 當 MarketType 爲 MarketType.Common, MarketType.Odd, MarketType.IntradayOdd 其中之一,且 priceType 爲 PriceType.Limit 時,需填入 price 欄位,其餘時候 price 欄位為空值或為None。 caution 現沖先賣時 , order\_type = DayTrade , buy\_sell 需為 Sell , market\_type 需為Common ##### OrderRecord[​](#orderrecord "Direct link to OrderRecord") 委託列表,透過 [get\_order\_result(accounts)](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/trade/GetOrderResults.md) 取得。 | 參數 | 類別 | 說明 | | --------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | work\_date | String | 有效交易日期 | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | | sys\_code | String | 來源別 | | order\_no | String | 委託書號 | | symbol | String | 股票代號 | | buy\_sell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 | | market\_type | [MarketType](#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | price\_type | [PriceType](#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價、 、 | | time\_in\_force | [TimeInForce](#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | order\_type | [OrderType](#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`ShortSale` 借券、 | | order\_price | Double | 委託價格 | | org\_qty | Int | 原始下單股數 | | filled\_qty | Int | 已成交股數 | | cel\_qty | Int | 已取消股數 | | can\_cancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | err\_code | String | 錯誤代碼 | | err\_msg | String | 錯誤訊息 | | seq\_no | String | 流水號 | | is\_pre\_order | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 | | pre\_order\_no | String | 預約單號碼 | | avg\_price | Double | 成交均價 | | chg\_time | String | 變動時間 | | chg\_date | String | 變動日期 | ##### Ack Object[​](#ack-object "Direct link to Ack Object") 委託回報物件 | 參數 | 類別 | 說明 | | ------------------- | --------------------------- | -------------------------------------------------------------------------------------------------- | | work\_date | String | 有效交易日期 | | order\_date\_time | String | 原始委託日期 | | org\_request\_no | String | 原始委託 Request 序號 | | sys\_code | String | 來源別 | | org\_sys\_code | String | 原始委託來源 | | request\_no | String | 刪改委託 Request 序號 | | order\_no | String | 委託書號 | | symbol | String | 股票代號 | | buy\_sell | [BSAction](#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market\_type | [MarketType](#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | price\_type | [PriceType](#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、 `LimitUp`漲停價、`LimitDown`跌停價、`Reference`平盤價 | | time\_in\_force | [TimeInForce](#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | order\_type | [OrderType](#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券 | | order\_price | Double | 委託價格 | | org\_qty | Int | 原始下單股數 | | filled\_qty | Int | 已成交股數 | | cel\_qty | Int | 已取消股數 | | can\_cancel | Boolean | 是否可取消 | | err\_code | String | 錯誤代碼 | | err\_msg | String | 錯誤訊息 | | act | String | 新單 / 刪改 : `0` 新單、`M`改量、`C`刪單、`R`改價 | | kind | String | 種類 : `ACK` 委託 `MAT` 成交 | | account | String | 帳號 | | before\_qty | Int | 變更前股數 | | after\_qty | Int | 變更後股數 | | line\_no | String | 行號 | | order\_seq\_no | String | 流水號 | | is\_pre\_order | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 | | org\_pre\_order\_no | String | 原始預約單委託書編號 | | pre\_order\_no | String | 預約單號碼 | ##### Mat Object[​](#mat-object "Direct link to Mat Object") 成交回報物件 | 參數 | 類型 | 說明 | | -------------- | ------------------------- | -------------------------------------------------------------------------------------------------- | | order\_no | String | 委託書號 | | org\_sys\_code | String | 原始委託來源別 | | symbol | String | 股票代號 | | order\_seq\_no | String | 網單序號 | | mkt\_seq\_no | String | 成交序號 | | market\_type | [MarketType](#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | buy\_sell | [BsAction](#bsaction) | 買賣方向 : `Buy` 買、`Sell` 賣 | | order\_type | [OrderType](#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券 | | pay\_price | Int | 價金 | | line\_no | String | 行號 | | kind | String | 種類:`MAT` 成交 、`ACK` 委託 | | account | String | 帳號 | | filled\_time | String | 成交時間 | | filled\_qty | Int | 成交股數 | | filled\_price | Double | 成交價格 | ##### Account[​](#account "Direct link to Account") 帳號資訊 | Parameter | Type | Meaning | | ------------- | ------ | --------------------------------------------------------------------------------- | | account | string | 分公司+帳號 | | account\_type | string | 帳號類型 | | s\_mark | string | 現股當沖狀態 : `B` 可先賣後買與先買後賣、 `Y`、`A` 可先買後賣、其餘回傳未符合資格 | | name | string | 姓名 | #### Constants ( 欄位對應數值 )[​](#constants--欄位對應數值- "Direct link to Constants ( 欄位對應數值 )") ##### BSAction[​](#bsaction "Direct link to BSAction") 買賣別 : `Buy`、`Sell` (buySell) | Name | Meaning | | ---- | ------- | | Buy | 買 | | Sell | 賣 | ##### MarketType[​](#markettype "Direct link to MarketType") 盤別 | Name | Meaning | | ----------- | -------- | | Common | 整股 | | Fixing | 定盤 | | IntradayOdd | 盤中零股 | | Odd | 盤後零股 | | Emg | 興櫃 | | EmgOdd | 興櫃零股 | 使用不同 MarketType 時,相對應的Quantity所代表的單位及範圍也會不同,詳如下表: | Name | Quantity Unit | Quantity Ranges | | ----------- | ------------- | --------------- | | Common | 千股 | 1000 ~ 499000 | | Fixing | 千股 | 1000 ~ 499000 | | IntradayOdd | 股 | 1 ~ 999 | | Odd | 股 | 1 ~ 999 | | Emg | 千股 | 1000 ~ 499000 | | EmgOdd | 股 | 1 ~ 999 | 使用不同 MarketType 時,可使用的 PriceType , TimeInForce 會不同,詳如下表: | MarketType | Available PriceType | Available TimeInForce | | ----------- | ---------------------------------------------------- | --------------------- | | Common | Limit 、 LimitUp 、 LimitDown 、 Market 、 Reference | ROD 、 IOC 、 FOK | | Fixing | Reference | ROD | | IntradayOdd | Limit 、 LimitUp 、 LimitDown 、 Reference | ROD | | Odd | Limit 、 LimitUp 、 LimitDown 、 Reference | ROD | | Emg | Limit | ROD | | EmgOdd | Limit | ROD | ##### PriceType[​](#pricetype "Direct link to PriceType") 價格類型 (priceType) | Name | Meaning | | --------- | ----------------------- | | Limit | 限價 | | LimitUp | 漲停 | | LimitDown | 跌停 | | Market | 市價 | | Reference | 參考價 (定盤時為定盤價) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") 委託條件 (TimeInForce) | Name | Meaning | | ---- | ------------------------------------- | | ROD | 當日有效(Rest of Day) | | FOK | 全部成交否則取消(Fill-or-Kill) | | IOC | 立即成交否則取消(Immediate-or-Cancel) | ##### OrderType[​](#ordertype "Direct link to OrderType") 委託類別 (orderType) | Name | Meaning | | ------------- | ---------- | | Stock | 現股 | | Margin | 融資 | | Short | 融券 | | DayTradeShort | 現股當沖賣 | ##### market[​](#market "Direct link to market") 市場 | Name | Value | | ---- | ----- | | 上市 | T | | 上櫃 | O | | 興櫃 | R | ##### QueryType[​](#querytype "Direct link to QueryType") 查詢類別 (QueryType) | Name | Meaning | | -------------- | ---------- | | All | 全部 | | Reservation | 預約單 | | RegularSession | 盤中 | | Cancelable | 可取消委託 | | Failed | 失敗單 | --- ### 取得交易日 get\_market\_time #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ---- | ------ | -------- | | date | String | 查詢日期 | #### TradingSchedule 回傳[​](#tradingschedule-回傳 "Direct link to TradingSchedule 回傳") | 參數 | 類別 | 說明 | | ---------------------- | ------- | -------------------------------- | | **regular** | Object | 正常交易時段 | | └─ open\_time | String | 正常交易開始時間("0930") | | └─ close\_time | String | 正常交易結束時間("1800") | | **after\_market** | Object | 盤後交易時段 | | └─ open\_time | String | 盤後交易開始時間("1400") | | └─ close\_time | String | 盤後交易結束時間("1600") | | **odd\_lot** | Object | 零股交易時段 | | └─ open\_time | String | 零股交易開始時間("1400") | | └─ close\_time | String | 零股交易結束時間("1600") | | **intraday\_odd\_lot** | Object | 零股當日盤交易時段 | | └─ open\_time | String | 零股當日盤交易開始時間("0930") | | └─ close\_time | String | 零股當日盤交易結束時間("1800") | | **emg** | Object | 興櫃交易時段 | | └─ open\_time | String | 興櫃交易開始時間("1100") | | └─ close\_time | String | 興櫃交易結束時間("1900") | | is\_trading\_day | Boolean | 是否為交易日(true/false) | | last\_trading\_day | String | 上一個交易日("20240916") | | next\_trading\_day | String | 下一個交易日("20240919") | | next\_trading\_day2 | String | 下下個交易日("20240920") | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.get_market_time("20241008") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py TradingSchedule { regular: TimeRange { open_time: "0930", # 正常交易開始時間 (String) close_time: "1800", # 正常交易結束時間 (String) }, after_market: TimeRange { open_time: "1400", # 盤後交易開始時間 (String) close_time: "1600", # 盤後交易結束時間 (String) }, odd_lot: TimeRange { open_time: "1400", # 零股交易開始時間 (String) close_time: "1600", # 零股交易結束時間 (String) }, intraday_odd_lot: TimeRange { open_time: "0930", # 零股當日盤交易開始時間 (String) close_time: "1800", # 零股當日盤交易結束時間 (String) }, emg: TimeRange { open_time: "1100", # 興櫃交易開始時間 (String) close_time: "1900", # 興櫃交易結束時間 (String) }, is_trading_day: true, # 是否為交易日 (Boolean) last_trading_day: "20241007", # 上一個交易日 (String) next_trading_day: "20241009", # 下一個交易日 (String) next_trading_day2: "20241011", # 下下個交易日 (String) } ``` --- ### 登入 login #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------------ | ------ | ---------- | | personal\_id | String | 登入的ID | | password | String | 登入的密碼 | | cert\_path | String | 憑證路徑 | | cert\_pass | String | 憑證密碼 | #### 帳號資訊 Account 欄位[​](#帳號資訊--account-欄位 "Direct link to 帳號資訊 Account 欄位") Return type: Object | 參數 | 類別 | 說明 | | ------------- | ------ | --------------------------------------------------------------------------------- | | branch\_name | String | 分公司名 | | account | String | 分公司代號 + 帳號 | | account\_type | String | 帳號類型 回傳 `stk` 證券 | | name | String | 姓名 | | s\_mark | String | 現股當沖狀態 : `B` 可先賣後買與先買後賣、 `Y`、`A` 可先買後賣、其餘回傳未符合資格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py from taishin_sdk import TaishinSDK, Order, BSAction, TimeInForce, OrderType, PriceType, MarketType sdk = TaishinSDK() accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") print(accounts) #若有多帳號,則回傳多個 ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py [Account { branch_name :"桃園", account: "592v980000", account_type: "stk", s_mark: "N", name: "許" }, Account { branch_name :"營業部", account: "5920981100", account_type: "stk", s_mark: "N", name: "許" }, Account { branch_name :"松德", account: "592a980222", account_type: "stk", s_mark: "N", name: "許" }] ``` --- ### API 資格開通 register\_api\_auth #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------- | ---- | | account | Account | 帳號 | #### 回傳[​](#回傳 "Direct link to 回傳") Return type: bool #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py from taishin_sdk import TaishinSDK, Order, BSAction, TimeInForce, OrderType, PriceType, MarketType sdk = TaishinSDK() accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") print(accounts) #若有多帳號,則回傳多個 sdk.register_api_auth(accounts[0]) # 放入已簽屬完成的帳號 ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py True ``` --- ### 查詢歷史成交 filled\_history #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢開始日 ( YYYYMMDD ) | | end\_date | string | 查詢終止日 ( YYYYMMDD ) | #### 成交資訊 FilledData 欄位[​](#成交資訊-filleddata-欄位 "Direct link to 成交資訊 FilledData 欄位") Return type : Object | 參數 | 類型 | 說明 | | ------------- | ---------- | -------------------------------------------------------------------------------------------------- | | order\_no | String | 委託書號 | | sys\_code | String | 來源別 | | symbol | String | 股票代號 | | mkt\_seq\_no | String | 成交序號 | | market\_type | MarketType | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | buy\_sell | String | 買賣方向 : `Buy` 買、`Sell` 賣 | | order\_type | String | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`ShortSale` 借券、 | | payment | Double | 應收付總金額 | | filled\_date | String | 成交日期 | | filled\_time | String | 成交時間 | | filled\_qty | Int | 成交股數 | | filled\_price | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.filled_history(account,"20241004","20241004") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py FilledRecordOutput { order_no: "g0002", # 委託書號 (String) sys_code: "4U", # 來源別 (String) symbol: "2889", # 股票代號 (String) mkt_seq_no: "00000009", # 成交序號 (String) market_type: Common, # 盤別 (MarketType) market: "T", # 市場 (String) buy_sell: "B", # 買賣方向 (String) order_type: "0", # 委託單類型 (String) payment: 15000.0, # 應收付總金額 (Double) filled_date: "20241004", # 成交日期 (String) filled_time: "152549030", # 成交時間 (String) filled_qty: 1000, # 成交股數 (Int) filled_price: 15.0, # 成交價格 (Double) } ``` --- ### 查詢歷史成交明細 filled\_history\_detail #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢開始日 ( YYYYMMDD ) | | end\_date | string | 查詢終止日 ( YYYYMMDD ) | #### 成交資訊 FilledDetailOutput 欄位[​](#成交資訊-filleddetailoutput-欄位 "Direct link to 成交資訊 FilledDetailOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ------------- | ---------- | -------------------------------------------------------------------------------------------------- | | order\_no | String | 委託書號 | | sys\_code | String | 來源別 | | symbol | String | 股票代號 | | mkt\_seq\_no | String | 成交序號 | | market\_type | MarketType | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | buy\_sell | String | 買賣方向 : `Buy` 買、`Sell` 賣 | | order\_type | String | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`ShortSale` 借券、 | | payment | Double | 應收付總金額 | | filled\_date | String | 成交日期 | | filled\_time | String | 成交時間 | | filled\_qty | Int | 成交股數 | | filled\_price | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.filled_history(account,"20241004","20241004") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py FilledDetailOutput { order_no: "g0002", # 委託書號 (String) sys_code: "4U", # 來源別 (String) symbol: "2889", # 股票代號 (String) mkt_seq_no: "00000009", # 成交序號 (String) market_type: Common, # 盤別 (MarketType) market: "T", # 市場 (String) buy_sell: "B", # 買賣方向 (String) order_type: "0", # 委託單類型 (String) payment: 15000.0, # 應收付總金額 (Double) filled_date: "20241004", # 成交日期 (String) filled_time: "152549030", # 成交時間 (String) filled_qty: 1000, # 成交股數 (Int) filled_price: 15.0, # 成交價格 (Double) } ``` --- ### 查詢今日成交彙總 get\_filled #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | symbol | string ( Optional ) | 股票代號 | #### 成交資訊 FilledData 欄位[​](#成交資訊-filleddata-欄位 "Direct link to 成交資訊 FilledData 欄位") Return type : Object | 參數 | 類型 | 說明 | | ------------- | ---------- | -------------------------------------------------------------------------------------------------- | | order\_no | String | 委託書號 | | sys\_code | String | 來源別 | | symbol | String | 股票代號 | | mkt\_seq\_no | String | 成交序號 | | market\_type | MarketType | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | buy\_sell | String | 買賣方向 : `Buy` 買、`Sell` 賣 | | order\_type | String | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`ShortSale` 借券、 | | payment | Double | 應收付總金額 | | filled\_date | String | 成交日期 | | filled\_time | String | 成交時間 | | filled\_qty | Int | 成交股數 | | filled\_price | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.filled(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py FilledRecordOutput { order_no: "g0002", # 委託書號 (String) sys_code: "4U", # 來源別 (String) symbol: "2889", # 股票代號 (String) mkt_seq_no: "00000009", # 成交序號 (String) market_type: Common, # 盤別 (MarketType) market: "T", # 市場 (String) buy_sell: "B", # 買賣方向 (String) order_type: "0", # 委託單類型 (String) payment: 15000.0, # 應收付總金額 (Double) filled_date: "20241004", # 成交日期 (String) filled_time: "152549030", # 成交時間 (String) filled_qty: 1000, # 成交股數 (Int) filled_price: 15.0, # 成交價格 (Double) } ``` --- ### 查詢今日成交明細 get\_filled\_detail #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | symbol | string ( Optional ) | 股票代號 | #### 成交資訊 FilledDetailOutput 欄位[​](#成交資訊-filleddetailoutput--欄位 "Direct link to 成交資訊 FilledDetailOutput 欄位") Return type : Object | 參數 | 類型 | 說明 | | ------------- | ---------- | -------------------------------------------------------------------------------------------------- | | order\_no | String | 委託書號 | | sys\_code | String | 來源別 | | symbol | String | 股票代號 | | market\_type | MarketType | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | buy\_sell | String | 買賣方向 : `Buy` 買、`Sell` 賣 | | order\_type | String | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券、`ShortSale` 借券、 | | payment | Double | 應收付總金額 | | filled\_date | String | 成交日期 | | filled\_qty | Int | 成交股數 | | filled\_price | Double | 成交價格 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.filled(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py FilledRecordOutput { order_no: "g0002", # 委託書號 (String) sys_code: "4U", # 來源別 (String) symbol: "2889", # 股票代號 (String) market_type: Common, # 盤別 (MarketType) market: "T", # 市場 (String) buy_sell: "Buy", # 買賣方向 (String) order_type: "0", # 委託單類型 (String) payment: 15000.0, # 應收付總金額 (Double) filled_date: "20241004", # 成交日期 (String) filled_qty: 1000, # 成交股數 (Int) filled_price: 15.0, # 成交價格 (Double) } ``` --- ### 取得委託單結果 get\_order\_results #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | query\_type | [QueryType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#querytype) | 盤別 : `All` 全部、`Reservation` 預約單 、`RegularSession` 盤中、`Cancelable` 可取消委託、`Failed` 失敗單 | #### OrderRecord 回傳[​](#orderrecord-回傳 "Direct link to OrderRecord 回傳") Return type : Object | 參數 | 類別 | 說明 | | --------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | work\_date | String | 有效交易日期 | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | | sys\_code | String | 來源別 | | order\_no | String | 委託書號 | | symbol | String | 股票代號 | | buy\_sell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | market\_type | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | price\_type | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、 、 | | time\_in\_force | [TimeInForce](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | order\_type | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券 、`DayTradeShort` 現股當沖賣 | | order\_price | Double | 委託價格 | | org\_qty | Int | 原始下單股數 | | filled\_qty | Int | 已成交股數 | | cel\_qty | Int | 已取消股數 | | can\_cancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | err\_code | String | 錯誤代碼 | | err\_msg | String | 錯誤訊息 | | seq\_no | String | 流水號 | | is\_pre\_order | Boolean | 是否預約單 : `true` 是預約單、`false`不是預約單 | | pre\_order\_no | String | 預約單號碼 | | avg\_price | Double | 成交均價 | | chg\_time | String | 變動時間 | | chg\_date | String | 變動日期 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.get_order_results(accounts.data[0]) # 帶入查詢參數 # sdk.stock.get_order_results(accounts.data[0], QueryType.All) ``` #### 回傳範例[​](#回�傳範例 "Direct link to 回傳範例") ```py OrderRecord { work_date: "20241007", # 有效交易日期 (String) order_date: "20241007", # 委託日期 (String) order_time: "153823610", # 委託時間 (String) sys_code: "4U", # 來源別 (String) order_no: "f0002", # 委託書號 (String) symbol: "2889", # 股票代號 (String) buy_sell: Buy, # 買賣方向 (BSAction) market: "T", # 市場 (String) market_type: Common, # 盤別 (MarketType) price_type: Limit, # 價格類型 (Enum) time_in_force: ROD, # 委託條件 (Enum) order_type: "Stock", # 委託類型 (String) order_price: 15.0, # 委託價格 (Double) org_qty: 300000, # 原始下單股數 (Int) filled_qty: 300000, # 已成交數量 (Int) cel_qty: 0, # 已取消數量 (Int) can_cancel: false, # 是否可取消 (Boolean) err_code: "000000", # 錯誤代碼 (String) err_msg: "", # 錯誤訊息 (String) seq_no: "10000043", # 流水號 (String) is_pre_order: false, # 是否預約單 (Boolean) pre_order_no: "", # 預約單號碼 (String) avg_price: 15.0, # 平均成交價格 (Double) chg_time: "153823610", # 異動時間 (String) chg_date: "20241007", # 異動日期 (String) } ``` --- ### 資券配額查詢 margin\_quota #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | --------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | stock\_no | String | 股票代碼 | | query\_type | String | 查詢類別:`1` 融資、`2` 融券 | #### MarginShortQuotaOutput 欄位[​](#marginshortquotaoutput--欄位 "Direct link to MarginShortQuotaOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | -------------- | ------ | ---------------------------------------------------- | | symbol | String | 股票代號 | | kind | String | 類別 (1: 融資, 2: 融券) | | tqty | String | 資券限額 : `數量` 、`停資`、`停券`、`不限資` | | stop | String | 是否停止融資/融券交易 (Y: 是, N: 否) | | cr\_percentage | String | 融資成數 (如 :0600 表0.6) | | db\_percentage | String | 融券成數 (如 :0900 表0.9) | | bl\_mark | String | 融券核准記號 | | cr\_status | String | 融資狀態 (查詢融資時才有) (如: 資0900 代表資成數) | | db\_status | String | 融券狀態 (查詢融券時才有) (如: 券0900 代表券成數) | | cr\_flag | String | 信用交易資格: `Y` 無信用交易資格、`N` 有信用交易資格 | | lu\_msg | String | 平盤下是否可券賣 | | dte\_msg | String | 是否可當沖、禁98戶 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.margin_quota(account, "2330") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py MarginShortQuotaOutput { symbol: "2330", # 股票代號 (String) kind: "1", # 類別 (String) tqty: "不限資", # 資券限額 (String) stop: "N", # 是否停止融資/融券交易 (String) cr_percentage: "0600", # 融資成數 (String) db_percentage: "0900", # 融券成數 (String) bl_mark: "1", # 融券核准記號 (String) cr_status: None, # 融資狀態 (String) db_status: "券0900", # 融券狀態 (String) cr_flag: "N", # 信用交易資格 (String) lu_msg: "平盤下可券", # 平盤下可券賣 (String) dte_msg: "可當沖", # 可當沖 (String) } ``` --- ### 修改委託價格 modify\_price #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | account | \[Account] | 帳號 | | OrderRecord | [OrderRecord](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#orderrecord) | 預計修改的委託單 | | price | string | 修改後的價格 | | priceType | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#pricetype) | 修改後的價格旗標 : `Limit` 限價、`Market` 市價、`LimitUp` 漲停價 、 `LimitDown` 跌停價、`Reference` 平盤價 | caution 僅盤前可以修改 PriceType,盤中時段不支援改 PriceType caution 當 price 欄位有填入值時,priceType 欄位 Limit ; 當 priceType 不為 Limit 時,price 為 `0` #### 修改資訊 ModifiedResponse 欄位[​](#修改資訊-modifiedresponse-欄位 "Direct link to 修改資訊 ModifiedResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----------- | ------ | -------- | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.modify_price(account, order_res, "14.5", PriceType.Limit) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py ModifiedResponse { order_date: "20241106", # 委託日期 (String) order_time: "153607690" # 委託時間 (String) } ``` --- ### 刪、改委託單數量 modify\_volume #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | orderRecord | [OrderRecord](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#orderrecord) | 預計修改的委託單 | | volume | int | 刪減股數 (設為 `0` 表刪單) | #### ModifiedResponse 回傳[​](#modifiedresponse--回傳 "Direct link to ModifiedResponse 回傳") Return type : Object | 參數 | 類別 | 說明 | | ----------- | ------ | -------- | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.modify_volume(account, target_order, 1000) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py ModifiedResponse { order_date: "20241106", # 委託日期 (String) order_time: "153607690" # 委託時間 (String) } ``` --- ### 查詢歷史委託 order\_history #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ----------- | ------------------------------------------------------------------------------------------------------------ | ----------------------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | start\_date | string | 查詢開始日 ( YYYYMMDD ) | | end\_date | string | 查詢終止日 ( YYYYMMDD ) | #### OrderRecord 回傳[​](#orderrecord-回傳 "Direct link to OrderRecord 回傳") | 參數 | 類別 | 說明 | | --------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | work\_date | String | 有效交易日期 | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | | sys\_code | String | 來源別 | | order\_no | String | 委託書號 | | symbol | String | 股票代號 | | buy\_sell | [BSAction](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#bsaction) | 買賣方向 :`Buy` 買、`Sell` 賣 | | market | String | 市場 :`T` 上市、`O` 上櫃、`R` 興櫃 | | market\_type | [MarketType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#markettype) | 市場類型 :`Common` 整股、`AfterMarket` 盤後 、`Odd` 盤後零股、`Emg`、 興櫃、`IntradayOdd` 盤中零股 | | price\_type | [PriceType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#pricetype) | 價格類型 : `Limit` 限價、`Market` 市價、 、 | | time\_in\_force | [TimeInForce](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#timeinforce) | 委託條件別 : `ROD` 、 `IOC` 、 `FOK` | | order\_type | [OrderType](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#ordertype) | 委託單類型 : `Stock` 股票 、 `Margin` 融資、 `Short` 融券 | | order\_price | Double | 委託價格 | | org\_qty | Int | 原始下單股數 | | filled\_qty | Int | 已成交股數 | | cel\_qty | Int | 已取消股數 | | can\_cancel | Boolean | 是否可取消 : `true` 可取消、`false`不可取消 | | err\_code | String | 錯誤代碼 | | err\_msg | String | 錯誤訊息 | | seq\_no | String (optional) | 流水號 | | is\_pre\_order | Boolean (optional) | 是否預約單 : `true` 是預約單、`false`不是預約單 | | pre\_order\_no | String (optional) | 預約單號碼 | | avg\_price | Double (optional) | 成交均價 | | chg\_time | String (optional) | 變動時間 | | chg\_date | String (optional) | 變動日期 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.order_history(account,"20230921","20230922") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py [OrderRecord { work_date: "20241007", # 有效交易日期 (String) order_date: "20241007", # 委託日期 (String) order_time: "153718236", # 委託時間 (String) sys_code: "4U", # 來源別 (String) order_no: "", # 委託書號 (String) symbol: "2889", # 股票代號 (String) buy_sell: Buy, # 買賣方向: `Buy` 買 (String) market: "T", # 市場代號("T":台股)(String) market_type: Common, # 盤別 (String) price_type: Limit, # 價格類型 (String) time_in_force: ROD, # 委託條件 (String) order_type: "Stock", # 委託類型 (String) order_price: 15.0, # 委託價格 (Double) org_qty: 150000, # 委託數量 (Int) filled_qty: 0, # 已成交數量 (Int) cel_qty: 0, # 已取消數量 (Int) can_cancel: false, # 是否可取消 (Boolean) err_code: "889", # 錯誤代號 (String) err_msg: "委託額度逾電交投資能力, 請洽營業員!", # 錯誤訊息 (String) seq_no: None, # 流水號 (String) is_pre_order: None, # 是否為預訂單 (Boolean) pre_order_no: None, # 預訂單號碼 (String) avg_price: None, # 平均成交價格 (Double) chg_time: None, # 異動時間 (String) chg_date: None, # 異動日期 (String) }, OrderRecord { work_date: "20241007", # 有效交易日期 (String) order_date: "20241007", # 委託日期 (String) order_time: "153617390", # 委託時間 (String) sys_code: "4U", # 來源別 (String) order_no: "h0001", # 委託書號 (String) symbol: "2889", # 股票代號 (String) buy_sell: Buy, # 買賣方向 (String) market: "T", # 市場代號 (String) market_type: Common, # 盤別 (String) price_type: Limit, # 價格類型 (String) time_in_force: ROD, # 委託條件 (String) order_type: "Stock", # 委託類型 (String) order_price: 15.0, # 委託價格 (Double) org_qty: 15000, # 委託數量 (Int) filled_qty: 15000, # 已成交數量 (Int) cel_qty: 0, # 已取消數量 (Int) can_cancel: false, # 是否可取消 (Boolean) err_code: "000000", # 錯誤代號 (String) err_msg: "", # 錯誤訊息 (String) seq_no: None, # 流水號 (String) is_pre_order: None, # 是否為預訂單 (Boolean) pre_order_no: None, # 預訂單號碼 (String) avg_price: None, # 平均成交價格 (Double) chg_time: None, # 異動時間 (String) chg_date: None, # 異動日期 (String) }] ``` --- ### 建立委託單 place\_order #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | order\_object | [OrderObject](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#orderobject) | 委託內容 | #### 委託資訊 PlaceOrderResponse 欄位[​](#委託資訊-placeorderresponse-欄位 "Direct link to 委託資訊 PlaceOrderResponse 欄位") Return type : Object | 參數 | 類別 | 說明 | | -------------- | ------ | ------------ | | order\_date | String | 委託日期 | | order\_time | String | 委託時間 | | work\_date | String | 有效交易日期 | | is\_pre\_order | Bool | 預約單註記 | | order\_no | String | 委託書號 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py order = Order( BSAction.Buy, "2887", 1000, MarketType.Common, PriceType.Limit, TimeInForce.ROD, OrderType.Stock, "15.0" ) sdk.stock.place_order(account, order) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py PlaceOrderResponse { order_date: "20241004", # 委託日期 (String) order_time: "152549030", # 委託時間 (String) work_date: "20241004", # 有效交易日期 (String) is_pre_order: false, # 委託單狀態 (Bool) order_no: "g0002" # 委託書編號 (String) } ``` --- ### 警示股票查詢 query\_attention\_stock #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | symbol | String ( Optional ) | 股票代號 | #### AlertStockOutput 欄位[​](#alertstockoutput---欄位 "Direct link to AlertStockOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------------------------ | ------ | ----------------------------------------------------------------- | | market\_type | Int | 市場別 : `0` 上市、`1`上櫃、`3`興櫃 | | symbol | String | 股票代號 | | lower\_limit\_price | Double | 跌停價 | | closing\_price | Double | 收盤價 | | upper\_limit\_price | Double | 漲停價 | | alert\_start\_date | String | 警示開始日期 | | alert\_end\_date | String | 警示結束日期 | | alert\_handling\_mode | Int | 警示處理模式 : `1` 受處置、`2`再處置 、 非`1`、`2` 為正常 | | stock\_name | String | 股票名稱 | | message\_description | String | 訊息說明(風控股票提示) | | short\_selling\_at\_flat\_mark | String | 平盤下可否券賣(`1` 表示可平盤下券賣、不為 `1` 則不可平盤下券賣) | | short\_selling\_at\_flat\_allowed | String | 平盤下可券賣狀態 ( 當股查詢時才有值 ) | | day\_trading\_and\_account98\_status | String | 是否可當沖及禁98戶 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py # 查詢全部 sdk.stock.query_attention_stock(account) # 查詢單檔 sdk.stock.query_attention_stock(account,"9945") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py AlertStockOutput { market_type: 0, # 市場別 (Int) symbol: "9945", # 股票代號 (String) lower_limit_price: 43.65, # 當日跌停價 (Double) closing_price: 48.45, # 當日收盤價 (Double) upper_limit_price: 53.20, # 當日漲停價 (Double) alert_start_date: "20241008", # 警示開始日期 (String) alert_end_date: "20241011", # 警示結束日期 (String) alert_handling_mode: 0, # 警示處理模式 (Int) stock_name: "潤泰新", # 股票名稱 (String) message_description: "風控股票,請務必查詢是否委託成功,或洽營業員辦理!", # 訊息說明 (String) short_selling_at_par_mark: "1", # 平盤下可否券賣 (String) short_selling_at_par_allowed: "平盤下可券", # 平盤下可券賣狀態 (String) day_trading_and_account98_status: "禁當沖", # 當沖及帳戶98狀態 (String) } ``` --- ### 處置股票查詢 query\_disposition\_stock #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | ------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | symbol | string | 股票代號 | #### StockStatusOutput 欄位[​](#stockstatusoutput--欄位 "Direct link to StockStatusOutput 欄位") Return type : Object | 參數 | 類別 | 說明 | | ------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | 股票代號 | | abnormal\_recommendation\_mark | string | 異常推介註記 : `0` 表示正常、`1`投資理財節目異常推介 | | abnormal\_description | string | 異常說明 | | special\_abnormal\_mark | string | 特殊異常註記 : `0` 表示正常、`1`特殊異常有價證券 | | special\_abnormal\_description | string | 特殊異常說明 | | disposition\_stock\_mark | string | 處置股票註記 : `0` 表示正常、`1` 處置股票、`2` 再次處置、`3`彈性處置 | | disposition\_description | string | 處置說明 | | internal\_control\_category | string | 內控類別 : `0` 表示正常、`AA`委託超過 30 萬需預收、`A` 委託超過 50 萬需預收、`B` 委託超過 300 萬需預收、`C` 委託超過 500 萬需預收 | | internal\_control\_description | string | 內控類別說明 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.query_disposition_stock(account,"4956") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py StockStatusOutput { symbol: "4956", # 股票代號 (String) abnormal_recommendation_mark: "0", # 異常推介註記 (String) : `0` 表示正常、`1`投資理財節目異常推介 abnormal_description: "", # 異常說明 (String) special_abnormal_mark: "0", # 特殊異常註記 (String) : `0` 表示正常、`1`特殊異常有價證券 special_abnormal_description: "", # 特殊異常說明 (String) disposition_stock_mark: "1", # 處置股票註記 (String) : `0` 表示正常、`1` 處置股票、`2` 再次處置、`3`彈性處置 disposition_description: "處置有價證券,請注意交易風險!", # 處置股票說明 (String) internal_control_category: "0", # 內控類別 (String) : `0` 表示正常、`AA`委託超過 30 萬需預收、`A` 委託超過 50 萬需預收、`B` 委託超過 300 萬需預收、`C` 委託超過 500 萬需預收 internal_control_description: "", # 內控類別說明 (String) } ``` --- ### 現冲券餘額查詢 short\_daytrade\_quota #### 輸入參數[​](#輸入參數 "Direct link to 輸入參數") | 參數 | 類別 | 說明 | | --------- | ------------------------------------------------------------------------------------------------------------ | -------- | | account | [Account](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/library/python/EnumMatrix.md#account) | 帳號 | | stock\_no | string | 股票代碼 | #### ShortResource 欄位[​](#shortresource--欄位 "Direct link to ShortResource 欄位") Return type : Object | 參數 | 類別 | 說明 | | ----- | ------ | -------------- | | quota | String | 現沖券剩餘張數 | | total | String | 現冲券原始額度 | | used | String | 現冲券使用額度 | #### 請求範例[​](#請求範例 "Direct link to 請求範例") ```py sdk.stock.short_daytrade_quota(account, "2330") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py ShortResource { quota: "00000740", # 現沖券剩餘張數 (String) total: "00000740", # 現冲券原始額度 (String) used: "00000000", # 現冲券使用額度 (String) } ``` --- ### 事前準備 caution 開始 Nova API 前,須完成以下步驟 1. 完成線上開戶 [線上開戶](https://eopen.tssco.com.tw/eopen/#/select-opentype-ledgerbank?ReferralOffice=174\&ReferralCompany=8\&ReferralCode=J1154285\&Source=fugle\&user=api) 2. 申請憑證 3. 簽署 API 使用風險暨聲明書 4. 完成認證 (若先前已使用台新) #### 完成線上開戶[​](#完成線上開戶 "Direct link to 完成線上開戶") 若您已有台新證券帳戶請跳過此步驟,若尚未開戶請點選 [線上開戶](https://eopen.tssco.com.tw/eopen/#/select-opentype-ledgerbank?ReferralOffice=174\&ReferralCompany=8\&ReferralCode=J1154285\&Source=fugle\&user=api) #### 申請憑證[​](#申請憑證 "Direct link to 申請憑證") 至 [憑證申請專區](https://www.tssco.com.tw/CAinfo) 申請憑證 #### 簽署[​](#簽署 "Direct link to 簽署") 依照下方連結範例簽署
[線上簽署連結](https://mlapi.masterlink.com.tw/web_api/service/fugle-api-sign) ![線上簽署](/FugleSDK/assets/images/signSOP-3e197844a9d353e01bcbd2510c239913.png) caution 簽屬完畢後,需間隔一天才會生效 ##### 安裝套件[​](#安裝套件 "Direct link to ��安裝套件") 至 [SDK 下載頁面](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/download/download-sdk.md) 下載相關套件 * Python * Node.js ```python pip install taishinsdk--cp37-abi3-win_amd64.whl ``` 目前支援 3.7、3.8、3.9、3.10、3.11 與 3.12。 首先先建立一個 project 資料夾,並利用下列指令初始化 ```bash npm init ``` 官網下載回來的檔案會像是 taishinsdk-\.tgz,並且把它放入剛剛建立的資料夾中 把 node.js project 裡面的 package.json 增加一行 ```json "dependencies": { ... "taishin-sdk": "file:///taishinsdk-.tgz", ... } ``` 然後到命令行輸入以下指令 ```bash npm install ``` 目前支援 Node.js 16 以上版本。 ##### 執行認證,開啟程式交易之旅[​](#執行認證開啟程式交易之旅 "Direct link to 執行認證,開啟程式交易之旅") * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order, TimeInForce, OrderType, PriceType, MarketType, BSAction # 載入設定檔與登入 sdk = TaishinSDK() accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") acc = accounts[0] sdk.register_api_auth(acc) # 未開通過台新 API 之用戶,第一次登入時,需加入此行程式認證,認證完畢後,即可移除此行 ``` 可先單獨執行以上程式,
完成認證後,即可使用 SDK 各項功能 ```python #建立委託物件 order = Order( buy_sell = BSAction.Buy, symbol = "2887", quantity = 2000, price = "15", market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, ) order_res = sdk.stock.place_order(acc, order) print(order_res) ``` 太棒了🎊,完成下單任務,即可看到系統回覆的結果 ```python PlaceOrderResponse { order_date: "20241028", order_time: "095945300", work_date: "20241028", is_pre_order: false, order_no: "h0001" } ``` ```js const { TaishinSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('taishin-sdk'); // const sdk = new TaishinSDK(); const accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") const acc = accounts[0]; const register = sdk.registerApiAuth(acc) // 未開通過台新 API 之用戶,第一次登入時,需加入此行程式,認證完畢後,即可移除此行 ``` 可先單獨執行以上程式,
完成認證後,即可使用 SDK 各項功能 ```js const order = { buySell: BSAction.Buy, symbol: "2887", price: "15", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, }; // sdk.stock.placeOrder(acc,order); ``` 太棒了🎊,完成下單任務,即可看到系統回覆的結果 ```js { orderDate: "20241028", orderTime: "095945300", workDate: "20241028", isPreOrder: false, orderNo: "h0001" } ``` --- ### 快速開始 請先參考 [事前準備](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/trading/prepare.md) 完成風險預告書申請與憑證下載。 若您還未安裝 SDK 套件,可至 [SDK 下載頁面](https://ml-fugle-api.masterlink.com.tw/FugleSDK/docs/download/download-sdk.md) 下載後,找到存放路徑,使用以下指令安裝: #### 套件安裝[​](#套件安裝 "Direct link to 套件安裝") * Python * Node.js ```py pip install taishinsdk--cp37-abi3-win_amd64.whl ``` 首先先建立一個 project 資料夾,並利用下列指令初始化 ```bash npm init ``` 官網下載回來的檔案會像是 taishinsdk-\.tgz,並且把它放入剛剛建立的資料夾中 把 node.js project 裡面的 package.json 增加一行 ```json "dependencies": { ... "taishin-sdk": "file:///taishinsdk-.tgz", ... } ``` 然後到命令行輸入以下指令 ```bash npm install ``` 並將憑證放置您的資料夾結構應該像是: ```text . └── XXXXXXXXXX.pfx ``` * Python * Node.js ```python from taishin_sdk import TaishinSDK, Order, TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = TaishinSDK() accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證位置", "您的憑證密碼") #若有開多個帳號,則會回傳多筆帳號資訊 acc = accounts[0] ``` 若您未曾使用 SDK 進行過登入,或更換了 SDK 執行環境,請在資料夾新增一個 `index.js` 檔案,貼上以下內容並執行: ```js const { TaishinSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('taishin-sdk'); const sdk = new TaishinSDK(); const accounts = sdk.login("您的身分證字號", "您的登入密碼", "您的憑證路徑" ,"您的憑證密碼"); const acc = accounts[0]; ``` #### 送出委託,買入股票[​](#送出委託買入股票 "Direct link to 送出委託,買入股票") 再將以下範例程式碼補上, 將示範如何使用 Nova API 送出一張以跌停價買入 台新金(2887) 的限價委託: * Python * Node.js ```py order = Order( buy_sell = BSAction.Buy, symbol = "2887", price = None, quantity = 2000, market_type = MarketType.Common, price_type = PriceType.LimitDown, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock ) sdk.stock.place_order(acc, order) ``` ```js const order = { buySell: BSAction.Buy, symbol: "2887", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.LimitDown, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock }; // sdk.stock.placeOrder(acc, order); ``` ---