# 富邦新一代 API|程式交易的新武器 ## TradeAPI ### SDK Download *** Key takeaways * Download SDKs for the Fubon Neo API in multiple languages. * Latest version is **v2.2.8** with [migration notes](#version-migration-notes) below. * API Key login requires >= v2.2.7; web certificate export login requires >= v2.2.8. | Item | Details | | --------------------- | ------------------------------------------------------------------------------------------------------- | | Latest version | v2.2.8 | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Platforms | Windows / macOS / Linux (by language) | | API Key login | >= v2.2.7 | | Web cert export login | >= v2.2.8 | info 1. Test environment is available for Fubon Neo API. Please refer to [User Guide](https://www.fbs.com.tw/TradeAPI/en/docs/welcome.md#test-environment) for more detail.
2. [Web Certificate Export](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) can be used for API login (version requirement: >= v2.2.8). API Key Login Feature (for version >= 2.2.7) * [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md)
* [Apply for API Key](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) Notes for versions >=2.2.4 1. New rule verification reminder for the user\_def field in securities orders.
a. Only ***uppercase and lowercase English letters and the numbers 0-9*** are accepted, with a maximum of 10 characters. (***Rule updated >=2.2.8***)
b. If the character string is legal but exceeds 10 characters, it will be automatically shortened to 10 characters and included in the order; the transaction event callback will send a reminder message.
c. If the character string is not legal, the user\_def field will be automatically filled with a null value; the transaction event callback will send a reminder message.
(***Note***: **Even if the user\_def field does not conform to the rules, the order will still be submitted**, but the field value will be automatically adjusted. Please refer to points ***b*** and ***c*** above for the adjustment method.) 2. For Python Market Data Web API, exception handling has been changed to using the ***Exception*** mechanism. For details, please refer to the Python code examples in the Market Data Web API documentation. Notes for versions >=2.2.0 1. The following condition order functions do not support futures/options after-hours session: a. Time slice
b. Trail profit
c. Time triggered conditions
2. A new parameter `trigger` is added to the take-profit/stop-loss order object (TPSLOrder). For stock condition order, the trigger price can be set to a. the best bid price, b. the best sell price, and c. the matched price. This paramter is optional, the default tartget is the matched price. For more details, please refer to condition order -> \[List of Enumerations] (***Note:*** For C#, this parameter must be filled with ***null*** to use the default target. For Python and JS, this parameter can be ignored)
(***Note 2:*** **Futures** TP/SL order object (FutOptTpslOrder) also has this newly added field, although not for actual use yet. For C#, please filled this field with ***null***, and for Python and JS, this parameter can be ignored) #### SDK Files[​](#sdk-files "Direct link to SDK Files") ##### Python[​](#python "Direct link to Python") Support Python 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13. Python 3.7 is not supported since v2.0.1 (3.14 not supported). **SDK:** * Windows 64 Bit [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon_neo-2.2.8-cp37-abi3-win_amd64.zip) * MacOs * Arm 64 Bit [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon_neo-2.2.8-cp37-abi3-macosx_11_0_arm64.zip) * X86 64 Bit [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon_neo-2.2.8-cp37-abi3-macosx_10_12_x86_64.zip) * Linux 64 Bit [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon_neo-2.2.8-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.zip) info **Code Example:** [Python example](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/python_sample_code.zip) (.ipynb, Jupyter. Need to install the SDK before use.) ##### JavaScript[​](#javascript "Direct link to JavaScript") Support Node.js 16 and above **SDK:** * Fubon-Neo.tgz [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon-neo-2.2.8.nodejs.zip) info **Code Example:** [JS example](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/js_sample_code.zip) (.ipynb, Jupyter. Need to install the SDK before use.) ##### C#[​](#c "Direct link to C#") Developed with .NET Standard 2.0, Suggest using .netcoreapp 3.1 and above or .NETFramework 4.7.2 and above **SDK:** * nupkg(64 Bit) [download](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/FubonNeo.2.2.8.nupkg.zip) info **Code Example:** [C# example (Trade)](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/fubondotnetsdkgui.zip) (Visual Studio project (WPF). Need to install the SDK before use.)
**Code Example:** [C# example (Market Data and Accounting)](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/marketdata_n_accounting.zip) (Visual Studio project (Windows Forms). Need to install the SDK before use.) ##### C++[​](#c-1 "Direct link to C++") For C++ 20 and above * [SDK and Example Code](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/FubonNeo.2.2.8_CppSDKPackage.zip) ##### Golang[​](#golang "Direct link to Golang") * [SDK and Example Code](https://www.fbs.com.tw/TradeAPI_SDK/fubon_binary/fubon-neo-2.2.8.golang.zip) #### Connection Test[​](#connection-test "Direct link to Connection Test") **Connection Test Helper:** [download](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/API_Sign_Test.zip) (for Windows) #### Version migration notes.[​](#version-migration-notes "Direct link to Version migration notes.") ##### 2.2.8[​](#228 "Direct link to 2.2.8") * New feature: (Securities) 1. Added a **Stock Affairs** data API to Market Data. 2. Added an **Adjusted Price** option to [Historical Candles](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/historical/candles.md). * Added page [Building with LLMs](https://www.fbs.com.tw/TradeAPI/en/docs/welcome/build-with-llm.md) Version Notes **>=2.2.8** 1. New rule verification reminder for the user\_def field in securities orders.
a. Only ***uppercase/lowercase English letters and digits 0–9*** are allowed, up to 10 characters (***rule updated >=2.2.8***)
2. The forced disconnect mechanism triggered by API Key permission changes has been adjusted to apply only to the keys affected by the change (Example: logged in simultaneously with key1 and key2; delete key1 => key1 session is forcibly disconnected; key2 session is not affected)
3. [Certificates exported](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) from the web page can be used for API login ##### 2.2.7[​](#227 "Direct link to 2.2.7") * New feature: APY-KEY Login and CA Certificate Export info * [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md)
* [Apply for API Key](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) ##### 2.2.6[​](#226 "Direct link to 2.2.6") * Golang version of the SDK (Stocks: Trade & account Management) * New feature: (Stocks) Marketdata Web API for realtime technical indicators ##### 2.2.5[​](#225 "Direct link to 2.2.5") * New feature: (Stocks) Stock Quote Information Query Functions * New feature: (Stocks) Added a new field **Disposition Status** to the function ***Get Daytrade Quota and Precollect Information*** * Upgraded connection management components ##### 2.2.4[​](#224 "Direct link to 2.2.4") * New feature: (Stocks) Day trade condition orders now available * New feature: (Stocks) Now support first-in-first-out account inquiries * New feature: (Stocks) Added a callback reminder to alert for invalid input in the user\_def field of securities orders * Added C++ version of the SDK (Stocks: Trade, account management and condition orders) Notes for versions >=2.2.4 1. Adds a new rule verification reminder for the user\_def field in securities orders.
a. Only characters in the ***ASCII range 33-126*** are accepted, with a maximum of 10 characters.
b. If the character string is legal but exceeds 10 characters, it will be automatically shortened to 10 characters and included in the order; the transaction event callback will send a reminder message.
c. If the character string is not legal, the user\_def field will be automatically filled with a null value; the transaction event callback will send a reminder message.
(***Note***: **Even if the user\_def field does not conform to the rules, the order will still be submitted**, but the field value will be automatically adjusted. Please refer to points ***b*** and ***c*** above for the adjustment method.) 2. For Python Market Data Web API, exception handling has been changed to using the ***Exception*** mechanism. For details, please refer to the Python code examples in the Market Data Web API documentation. ##### 2.2.3[​](#223 "Direct link to 2.2.3") * Exception handling components optimization ##### 2.2.2[​](#222 "Direct link to 2.2.2") * Upgrade the place order module again for EVEN BETTER speed ##### 2.2.1[​](#221 "Direct link to 2.2.1") * New feature: WebSocket parameter settings ( [Reference](https://www.fbs.com.tw/TradeAPI/en/docs/trading/guide/advance/ping_pong.md) ) ##### 2.2.0[​](#220 "Direct link to 2.2.0") * New feature: (Stocks) Condition TP/SL order can set different trigger price types (best sell, best buy, and matched) * New feature: (Futures/Options) Condition order can be placed for after-hours session (FutureNight/OptionNight) Notes for versions >=2.2.0 1. The following condition order functions do not support futures/options after-hours session: a. Time slice b. Trail profit c. Time triggered conditions 2. A new parameter `trigger` is added to the take-profit/stop-loss order object (TPSLOrder). For stock condition order, the trigger price can be set to a. the best bid price, b. the best sell price, and c. the matched price. This paramter is optional, the default tartget is the matched price. For more details, please refer to condition order -> \[List of Enumerations] (***Note:*** For C#, this parameter must be filled with ***null*** to use the default target. For Python and JS, this parameter can be ignored)
(***Note 2:*** **Futures** TP/SL order object (FutOptTpslOrder) also has this newly added field, although not for actual use yet. For C#, please filled this field with ***null***, and for Python and JS, this parameter can be ignored) ##### 2.1.1[​](#211 "Direct link to 2.1.1") * New feaure: (Stocks) Longer term historical orders and filled records (each inquiry can cover up to 30-day date range) * New feaure: (Futures/Options) Trail-profit and time-slice condition order ##### 2.1.0[​](#210 "Direct link to 2.1.0") * New feaure: Futures/Options condition order * (Stocks) Add new fields 'status' and 'err\_msg' to 'details' of OrderResult ##### 2.0.1[​](#201 "Direct link to 2.0.1") * New functions for futures/options trade and account information * Python SDK supports Python 3.12 (**cease the support for Python 3.7**) ##### 1.3.2[​](#132 "Direct link to 1.3.2") * Upgrade the place order module for better speed ##### 1.3.1[​](#131 "Direct link to 1.3.1") * New feaure: Stock condition order * New feaure: Futures/Options market data * (C#) New ways to use trade callback function (for more information, please refer to Trading Doc -> SDK Refernce -> [Version Upgrade Guide](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/upgrade-guide.md)) ##### 1.0.4[​](#104 "Direct link to 1.0.4") * Add 'details' field to OrderResult object * New mode for realtime market data (for more information, please refer to Market Data Doc -> WebSocket -> [Mode Switching](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/upgrade-guide.md)) --- ### Install & Compatibility Key takeaways * Languages: Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only). * Minimum versions: Python 3.8–3.13 (3.14 not supported), Node.js 16+, .NET Standard 2.0, C++20+, Go 1.19+. * SDK downloads: see [SDK Download](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md). * This page summarizes the minimal install steps and compatibility. #### Supported environments & compatibility[​](#supported-environments--compatibility "Direct link to Supported environments & compatibility") | Language | Minimum version | Supported OS | Install type | Notes | | -------------------- | ----------------------- | ----------------------- | ------------ | ------------------------------------------------------------ | | Python | 3.8–3.13 (since v2.0.1) | Windows / macOS / Linux | `.whl` | Python 3.7 is not supported since v2.0.1; 3.14 not supported | | JavaScript (Node.js) | 16+ | Windows / macOS / Linux | local `.tgz` | Install as a local Node.js package | | C# | .NET Standard 2.0 | Windows | `.nupkg` | Recommended: .NET Core 3.1+ or .NET Framework 4.7.2+ | | C++ | C++20+ | Windows / macOS / Linux | SDK files | Securities trading accounting and condition orders only | | Go | 1.19+ | Windows / macOS / Linux | SDK files | Securities trading accounting and condition orders only | #### Minimal installation steps[​](#minimal-installation-steps "Direct link to Minimal installation steps") ##### Python[​](#python "Direct link to Python") 1. Download the platform-specific `.whl`. 2. Install: ```bash pip install fubon_neo--cp37-abi3-win_amd64.whl ``` ##### JavaScript (Node.js)[​](#javascript-nodejs "Direct link to JavaScript (Node.js)") 1. Download the `.tgz` and place it in your project folder. 2. Add to `package.json`: ```json "dependencies": { "fubon-neo": "file:///fubon-neo-.tgz" } ``` 3. Install: ```bash npm install ``` ##### C#[​](#c "Direct link to C#") 1. Download the `.nupkg`. 2. Install via Visual Studio NuGet Package Manager or a local NuGet source. ##### C++[​](#c-1 "Direct link to C++") 1. Download the C++ SDK and sample code. 2. Configure include/lib paths based on the sample project. ##### Go[​](#go "Direct link to Go") 1. Download the Go SDK and sample code (Go 1.19+). 2. Configure `go.mod` and local module paths based on the sample project. #### Package naming[​](#package-naming "Direct link to Package naming") * `fubon_neo--cp37-abi3-win_amd64.whl` * `fubon-neo-.tgz` * `FubonNeo..nupkg` #### Version highlights[​](#version-highlights "Direct link to Version highlights") * API Key login: >= v2.2.7 * Web certificate export login: >= v2.2.8 * Python 3.7: not supported since v2.0.1 * Python 3.14: not supported For full version notes, see [Version Migration](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md#version-migration-notes). #### FAQ[​](#faq "Direct link to FAQ") **Q1: How do I verify the SDK works after installation?**
A: Complete login and connection testing, then call any API method. **Q2: Why can’t I install on Python 3.7?**
A: Python 3.7 is not supported since v2.0.1. **Q3: Is Python 3.14 supported?**
A: Not at the moment; use Python 3.8–3.13. **Q4: Why are C++ / Go features limited?**
A: They currently support securities trading accounting and condition orders only. #### Next steps[​](#next-steps "Direct link to Next steps") * [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md) * [Quick Start](https://www.fbs.com.tw/TradeAPI/en/docs/trading/quickstart.md) * [API Key Application](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) --- ### API Key Application & Management Version Support Available since v2.2.7 Web Certificate Export Starting from v2.2.8, exporting credentials after logging in on this page can be used to login API. API Key Application & Management You can still log in and use the API with your existing account credentials.
**API Key is an optional feature** that provides **enhanced security and flexibility**, ideal for advanced users. ##### Why Choose API Key?[​](#why-choose-api-key "Direct link to Why Choose API Key?") * **Granular Access Control**: Restrict keys to specific functions (e.g., market data only, no order placement). * **IP Whitelisting**: Allow access only from trusted IP addresses to reduce external risks. * **Quick Revocation**: Disable a key instantly without affecting your main account. This feature is **not mandatory**, but if you want to improve security or need more flexible integration, **we recommend enabling API Key**. Important Notice **Please note!** When there are changes to the API Key list (such as adding or removing keys), all sessions logged in using an API Key will be forcibly logged out. Mechanism Change since v2.2.8 (with SDK update) The forced disconnect mechanism triggered by API Key permission changes has been adjusted to apply only to the keys affected by the change (Example: logged in simultaneously with key1 and key2; delete key1 => key1 session is forcibly disconnected; key2 session is not affected). #### Apply for a Certificate[​](#apply-for-a-certificate "Direct link to Apply for a Certificate") Before applying for an API Key, you must first apply for your web certificate. Once that's done, you can proceed with the API Key application. 1. Enter your ID number and corresponding password ![key\_login\_step2](/TradeAPI/en/assets/images/key_login_step2-e8aa8f122ec1bd5960ba14bd4b0491eb.png) 2. Apply for a web certificate and receive the OTP ![OTP](/TradeAPI/en/assets/images/OTP-3771c5ab5c12c603f48994c14e130c77.png) 3. After completing the certificate application, you can export the certificate and add a new key ![key\_login\_step3](/TradeAPI/en/assets/images/key_login_step3-add15e5759914e12519b00657532f988.png) CA Certificate with a Default Password Use your login ID when prompted to enter the certificate password. 4. Apply for a key * Click `Add API Key `![add\_key](/TradeAPI/en/assets/images/add_key-5ca3ffea5b0e4c620d916dc950914d40.png) * Set control permissions ( Leave IP or date blank if you do not want to set corresponding controls ) ![add\_key\_step2](/TradeAPI/en/assets/images/add_key_step2-569f33ff9a7763a3a75e1611a83b3c47.png) * After successful setup, the Secret Key will be displayed ( **Once the Secret Key is closed, it will no longer be shown** ) ![add\_key\_step3](/TradeAPI/en/assets/images/add_key_step3-2d2331bc6aadbb61ee743ebc4d2ff3fd.png) 5. You can view previously applied keys or deactivate them ( You can activate for up to 30 keys at the same time ) ![key\_list](/TradeAPI/en/assets/images/key_list-65170f1813ace159f2ac109b2287d624.png) Key takeaways * Apply for and manage API Keys for the Fubon Neo API. * API Keys can be used for login and permission control. * After creation, you can review, update, or revoke keys. | Item | Details | | ------------- | ---------------------------------------- | | Feature | API Key application and management | | Product | Fubon Neo API | | Primary use | Login and permission control | | Related pages | API Key Introduction / Apply for API Key | --- ### Corporate Actions Capital Changes Get capital changes data for par value changes, capital reductions, splits ```text GET /corporate-actions/capital-changes/ ``` Version Note Available since v2.2.8 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------- | | `start_date` | string | Start date (format: `yyyy-MM-dd`) | | `end_date` | string | End date (format: `yyyy-MM-dd`) Future dates are supported, allowing you to retrieve upcoming announcement information. | | `sort` | string | Sort order (`asc`, `desc`) | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | `data`\* | object\[] | Capital changes data | | `data.symbol` | string | Ticker symbol | | `data.name` | string | Security name | | `data.actionType` | string | Action type: `etf_split_or_merge` ETF split or reverse split, `par_value_change` par value change, `capital_reduction` capital reduction | | `data.effectiveDate` | string | Trading resumption date (YYYY-MM-DD) | | `data.adjustmentFactor` | number | Adjustment factor | | `data.haltDate` | string | Trading halt date (YYYY-MM-DD) | | `data.resumeDate` | string | Trading resumption date (YYYY-MM-DD) | | `data.raw` | object | Raw data | | `data.raw.exchangeRatio` | number | Exchange ratio (only available for par value changes and capital reductions) | | `data.raw.parValueBefore` | number | Par value before change (only available for par value changes) | | `data.raw.parValueAfter` | number | Par value after change (only available for par value changes) | | `data.raw.lastClosePrice` | number | Last closing price before trading halt | | `data.raw.referencePrice` | number | Reference price on trading resumption | | `data.raw.limitUpPrice` | number | Limit-up price | | `data.raw.limitDownPrice` | number | Limit-down price | | `data.raw.openingReferencePrice` | number | Opening call-auction reference price | | `data.raw.splitType` | string | Split type: `Split`, `Reverse Split` | | `data.raw.reductionReason` | string | Reason for capital reduction (only available for capital reductions) | | `data.raw.refundPerShare` | number | Refund per share (TWD) (only available for capital reductions) | | `data.raw.rightsOfferingRatio` | number | Rights offering ratio after capital reduction (only available for capital reductions) | | `data.raw.rightsOfferingPrice` | number | Rights subscription price (TWD) (only available for capital reductions) | | `data.raw.exRightsReferencePrice` | number | Ex-rights reference price (only available for capital reductions) | #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later using following Exception for error handling from fubon_neo.sdk import FugleAPIError try: response = reststock.corporate_actions.capital_changes(**{"start_date": "2025-12-06", "end_date": "2026-01-08"}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") print(f"Response Text: {e.response_text}") print(response) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection const client = sdk.marketdata.restClient client.stock.corporateActions.capitalChanges({ start_date: '2025-12-06', end_date: '2026-01-08' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.CorporateActions; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; var dividend = await rest.CorporateActions.CapitalChanges(new() { StartDate = fromDate, EndDate = toDate, Sort = SortType.Desc // Optional }); var dividend_cont = dividend.Content.ReadAsStringAsync().Result; Console.WriteLine(dividend_cont); ``` 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 Retrieve ex-dividend and ex-rights data (query by date) ```text GET /corporate-actions/dividends/ ``` Version Note Available since v2.2.8 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------- | | `start_date` | string | Start date (format: `yyyy-MM-dd`) | | `end_date` | string | End date (format: `yyyy-MM-dd`) Future dates are supported, allowing you to retrieve upcoming announcement information. | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------------------- | --------- | -------------------------------------------------------------------- | | `data`\* | object\[] | Ex-rights and ex-dividend data | | `data.date`\* | string | Ex-rights / ex-dividend date | | `data.exchange` | string | Exchange | | `data.symbol` | string | Ticker symbol | | `data.name` | string | Security name | | `data.previousClose` | number | Closing price before ex-rights / ex-dividend | | `data.referencePrice` | number | Ex-rights / ex-dividend reference price | | `data.dividend` | number | Total amount of rights and dividends (rights value + dividend value) | | `data.dividendType` | string | Dividend type | | `data.limitUpPrice` | number | Limit-up price after ex-rights | | `data.limitDownPrice` | number | Limit-down price after ex-rights | | `data.openingReferencePrice` | number | Opening call-auction reference price | | `data.exdividendReferencePrice` | number | Ex-dividend reference price (after deducting dividends) | | `data.cashDividend` | number | Cash dividend | | `data.stockDividendShares` | number | Stock dividend shares per 1,000 shares | #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later using following Exception for error handling from fubon_neo.sdk import FugleAPIError try: response = reststock.corporate_actions.dividends(**{"start_date": "2025-08-26", "end_date": "2026-01-08"}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # ex: 429 print(f"Response Text: {e.response_text}") # ex: {"statusCode":429,"message":"Rate limit exceeded"} print(response) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // 建立行情連線 const client = sdk.marketdata.restClient client.stock.corporateActions.dividends({ start_date: '2025-08-26', end_date: '2026-01-08' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.CorporateActions; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; var dividend = await rest.CorporateActions.Dividends(new() { StartDate = fromDate, EndDate = toDate, Sort = SortType.Desc // Optional }); var dividend_cont = dividend.Content.ReadAsStringAsync().Result; Console.WriteLine(dividend_cont); ``` Response Body: ```json { "data": [ { // Prices will not be included for upcoming (future) ex-rights / ex-dividend events. "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 }, { // For ex-rights / ex-dividend events that have already occurred, price fields will be included (cash dividend only). "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 }, { // Capital increase (on the prior trading day, the opening reference price will equal the ex-dividend reference price, or `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 }, { // For ex-rights / ex-dividend events that have already occurred, price fields will be included (rights only). "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 }, { // For ex-rights / ex-dividend events that have already occurred, price fields will be included (both rights and dividends). "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 Retrieve listing application data for companies applying to list on TWSE or TPEx ```text GET /corporate-actions/listing-applicants/ ``` Version Note Available since v2.2.8 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------- | | `start_date` | string | Start date (format: `yyyy-MM-dd`) | | `end_date` | string | End date (format: `yyyy-MM-dd`) Future dates are supported, allowing you to retrieve upcoming announcement information. | | `sort` | string | Sort order (`asc`, `desc`) | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------------- | ------ | ------------------------------------------------ | | `symbol` | string | Company ticker | | `name` | string | Company short name | | `exchange` | string | Application type: `TWSE` (listed) / `TPEx` (OTC) | | `applicationDate` | string | Application date | | `chairman` | string | Chairman | | `capitalAtApplication` | number | Capital at application (thousand TWD) | | `reviewCommitteeDate` | string | Listing Review Committee date | | `boardApprovalDate` | string | Exchange board approval date | | `contractFilingDate` | string | Competent authority approval date | | `listedDate` | string | Listing / OTC trading start date | | `underwriter` | string | Underwriter | | `underwritingPrice` | number | Underwriting price | | `remarks` | string | Remarks | #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later using following Exception for error handling from fubon_neo.sdk import FugleAPIError try: response = reststock.corporate_actions.listing_applicants(**{"start_date": "2025-01-07", "end_date": "2026-01-07"}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # ex: 429 print(f"Response Text: {e.response_text}") # ex: {"statusCode":429,"message":"Rate limit exceeded"} print(response) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.stock.corporateActions.listingApplicants({ start_date: '2025-01-07', end_date: '2026-01-07' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.CorporateActions; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.Stock; var listing = await rest.CorporateActions.ListingApplicants(new() { StartDate = fromDate, EndDate = toDate, Sort = SortType.Desc // Optional }); var listing_cont = listing.Content.ReadAsStringAsync().Result; Console.WriteLine(listing_cont); ``` 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": "" } ] } ``` --- ### Quick Start Key takeaways * Fubon Market Data Web API provides intraday, snapshot, and historical data for Taiwan equities. * Exceeding limits returns status code `429`. * SDK examples are available for Python, Node.js, and C#. | Item | Details | | ---------- | -------------------------------- | | Interface | Web API | | Market | Taiwan equities | | Data types | Intraday / Snapshot / Historical | | Rate limit | `429` on exceed | | SDK | Python / Node.js / C# | Fubon Market Data Web API provides developer-friendly services. You can access intraday, snapshot, and historical market data for Taiwan equities. #### Rate Limit[​](#rate-limit "Direct link to Rate Limit") If your API requests exceed the limit, you will receive a response with a status code `429` ( For detailed limitations, please refer to [Rate Limit](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/rate-limit.md) ) #### API Category[​](#api-category "Direct link to API Category") API are categorized based on data types into **intraday(盤中行情)**、**snapshot(行情快照)**、**historical(歷史行情)** * `/intraday/tickers` - [Stock or index lists (query by conditions)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/tickers.md) * `/intraday/ticker/{symbol}` - [Stock information (query by stock number)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/ticker.md) * `/intraday/quote/{symbol}` - [Real-time quotes (query by stock number)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/quote.md) * `/intraday/candles/{symbol}` - [Stock KLine(query by stock number)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/candles.md) * `/intraday/trades/{symbol}` - [Stock trade details (query by stock number).](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/trades.md) * `/intraday/volumes/{symbol}` - [Stock price-volume data(query by stock number)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/intraday/volumes.md) * `/snapshot/quotes/{market}` - [Stock market snapshot (by market type).](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/snapshot/quotes.md) * `/snapshot/movers/{market}` - [Stock price change ranking (by market type)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/snapshot/movers.md) * `/snapshot/actives/{market}` - [Stock trading value ranking (by market type).](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/snapshot/actives.md) * `/historical/candles/{symbol}` - [Retrieve historical stock prices within 1 year (query by stock number))](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/historical/candles.md) * `/historical/stats/{symbol}` - [Retrieve recent 52-week stock price data (query by stock number)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/historical/stats.md) #### Using SDK[​](#using-sdk "Direct link to Using SDK") Fubon Market Data Web API offers Python, Node.js, and C# SDKs. You can access the API through the following methods: * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order # Since version 2.2.4, add the following import: # from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient const stock = client.stock; ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; ``` --- ### Historical Candles Retrieve historical stock prices within 1 year (query by stock number)) ```text historical/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | ----------------------------------------------------------------------------------------------------------- | | `symbol`\* | string | Stock Number | | `from` | string | Start Date(Format:`yyyy-MM-dd`) | | `to` | string | End Date(Format:`yyyy-MM-dd`) | | `timeframe` | string | KLine TimeFrame, offer `1` 1m;`5` 5m;`10` 10m;`15` 15m;`30` 30m;`60` 60m;`D` day;`W` week;`M` month | | `adjusted` | string | Adjusted stock price, Option: `true`、`false` ***(Available >= v2.2.8)*** | | `fields` | string | Fields, offer:`open,high,low,close,volume,turnover,change` | | `sort` | string | Sorting, default `desc` descent, Also offer `asc` ascent | caution Currently, for K-line data, you cannot specify a start date (from) and end date (to) on minute timeframe. The API will always return data for the most recent five days, and you cannot choose the turnover and change on the fields."。 #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.historical.candles(**{"symbol": "0050", "from": "2023-02-06", "to": "2023-02-08"}) # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.historical.candles(**{"symbol": "0050", "from": "2023-02-06", "to": "2023-02-08"}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; //import HistoryTimeFrame using FugleMarketData.QueryModels; //import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var candle = await rest.History.Candles("2330", new(DateTime.Today.AddDays(-100),DateTime.Today,HistoryTimeFrame.Week,FieldsType.High|FieldsType.Low)); var candle_con = candle.Content.ReadAsStringAsync().Result; Console.WriteLine(candle_con); ``` 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 | Date | | `type`\* | string | Data Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Stokc Number | | `timeframe*` | string | KLine Timeframe | | `data` | Candle | KLine Data | info '\*' Indicates mandatory disclosure fields. --- ### Historical Stats Retrieve recent 52-week stock price data (query by stock number) ```text historical/stats/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------ | | `symbol`\* | string | Stock Number | #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.historical.stats(symbol = "0050") # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.historical.stats(symbol = "0050") except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.historical.stats({ symbol: '0050' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var stats = await rest.History.Stats("0050"); var stats_cont = stats.Content.ReadAsStringAsync().Result; Console.WriteLine(stats_cont); ``` 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 | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market`\* | string | Market Type | | `symbol`\* | string | Stock Number | | `name`\* | string | Stock Abbreviation in Chinese | | `openPrice`\* | number | Opening price on the last trading day | | `highPrice`\* | number | Highest price on the last trading day | | `lowPrice`\* | number | Lowest price on the last trading day | | `closePrice`\* | number | Close price on the last trading day | | `change`\* | number | Price change on the last trading day | | `changePercent`\* | number | Price change percentage on the last trading day | | `tradeVolume`\* | number | Volume on the last trading day | | `tradeValue`\* | number | Value on the last trading day | | `previousClose`\* | number | Previous trading day's closing price | | `week52High`\* | number | 52-week High | | `week52Low`\* | number | 52-week Low | info '\*' Indicates mandatory disclosure fields. --- ### Intraday Candles Stock KLine(query by stock number) ```text intraday/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | ----------------------------------------------------------------------------- | | `symbol`\* | string | Stock Number | | `type` | string | Ticker Type,Also offer `oddlot` odd-lot | | `timeframe` | string | KLine Timeframe,offer `1` 1m;`5` 5m;`10` 10m;`15` 15m;`30` 30m;`60` 60m | | `sort` | string | Sorting,default `asc` ascent Also offer `desc` descent | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | --------- | --------------------------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange Type | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `timeframe`\* | number | KLine Timeframe | | `data`\* | object\[] | List | | >> `open` | number | Opening Price | | >> `high` | number | Highest Price | | >> `low` | number | Lowest Price | | >> `close` | number | Close Price | | >> `volume` | number | Volume (Common: sheets ; Emg / Odd-lot : share ; Index : Value) | | >> `average` | number | Average Price | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.candles(symbol='2330') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.candles(symbol='2330') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday.candles({ symbol: '2330' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var candles = await rest.Intraday.Candles("2330"); // var candles = await rest.Intraday.Candles("2330", new(){TimeFrame=FugleMarketData.QueryModels.Stock.Intraday.IntradayTimeFrame.TenMin}); // 10-min timeframe var candle_cont = candles.Content.ReadAsStringAsync().Result; Console.WriteLine(candle_cont); ``` 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 Real-time quotes (query by stock number) ```text intraday/quote/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | --------------------------------- | | `symbol`\* | string | Stock Number | | `type` | string | Type,Also offer `oddlot` odd-lot | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | ----------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market`\* | string | Market Type | | `symbol`\* | string | Stock Number | | `name`\* | string | Stock Abbreviation in Chinese | | `referencePrice` | number | Reference Price | | `previousClose` | number | The closing price of the previous trading day | | `openPrice` | number | Opening Price | | `openTime` | number | Opening price transaction time | | `highPrice` | number | Highest Trading Price | | `highTime` | number | Highest Trading Price transaction time | | `lowPrice` | number | Lowest Trading Price | | `lowTime` | number | Lowest Trading Price transaction time | | `closePrice` | number | Close Price | | `closeTime` | number | Close Price transaction time | | `lastPrice` | number | Last Price(include trial) | | `lastSize` | number | Last Trading Volume(include trial) | | `avgPrice` | number | Trading Average Price Today | | `change` | number | Last Trading Price Change | | `changePercent` | number | Last Trading price Change Percentage | | `amplitude` | number | Price Range Today | | `bids` | object\[] | Top 5 bid | | >> `price` | number | Top 5 bid price | | >> `size` | number | Top 5 bid volume | | `asks` | object\[] | Top 5 ask | | >> `price` | number | Top 5 ask price | | >> `size` | number | Top 5 ask volume | | `total` | object | list | | >> `tradeValue` | number | Accumulative Trading Value | | >> `tradeVolume` | number | Accumulative Trading Volume | | >> `tradeVolumeAtBid` | number | Total Bid Order Count | | >> `tradeVolumeAtAsk` | number | Total Ask Order Count | | >> `transaction` | number | Accumulative Transaction Count | | >> `time` | number | Accumulative Time Interval | | `lastTrade` | object | list | | >> `bid` | number | Last Trading Bid Price | | >> `ask` | number | Last Trading Ask Price | | >> `price` | number | Last Trading Price | | >> `size` | number | Last Trading Volume | | >> `time` | number | Last Trading Time | | `lastTrial` | object | list | | >> `bid` | number | Last Trial Bid Price | | >> `ask` | number | Last Trial Ask Price | | >> `price` | number | Last Trial Matched Price | | >> `size` | number | Last Trial Matched Volume | | >> `time` | number | Last Trial Matched Time | | `opHaltStatus` | object | list | | >> `isHalted` | boolean | Suspended:`true`;Resumed:`false` | | >> `time` | number | Suspended / Resumed Trading Time | | `isLimitDownPrice` | boolean | Last Matched is Fall Stop Price:`true` | | `isLimitUpPrice` | boolean | Last Matched is Rise Stop Price:`true` | | `isLimitDownBid` | boolean | Optimal position purchase Fall remarks:`true` | | `isLimitUpBid` | boolean | Optimal position purchase Rise remarks:`true` | | `isLimitDownAsk` | boolean | Optimal position Sale Fall remarks:`true` | | `isLimitUpAsk` | boolean | Optimal position Sale Rise remarks:`true` | | `isLimitDownHalt` | boolean | Held Match And Instantaneous Fall Trend:`true` | | `isLimitUpHalt` | boolean | Held Match And Instantaneous Rise Trend:`true` | | `isTrial` | boolean | Trial:`true` | | `isDelayedOpen` | boolean | Delayed Open:`true` | | `isDelayedClose` | boolean | Delayed Close:`true` | | `isContinuous` | boolean | Last Matched is Continuous Market:`true` | | `isOpen` | boolean | Open Mark:`true` | | `isClose` | boolean | Close Mark:`true` | | `lastUpdated` | number | Last Updated Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.quote(symbol='2330') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.quote(symbol='2330') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday.quote({ symbol: '2330' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var quote = await rest.Intraday.Quote("2330"); // var quote = await rest.Intraday.Quote("2330", new(){Type=FugleMarketData.QueryModels.TickerType.OddLot}); // Odd lot var quote_cont = quote.Content.ReadAsStringAsync().Result; Console.WriteLine(quote_cont); ``` 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 Stock information (query by stock number) ```text intraday/ticker/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------- | | `symbol`\* | string | Stock number | | `type` | string | Type,offer `oddlot` odd-lot | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------------------- | ------- | --------------------------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange Type | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `name`\* | string | Stock Abbreviation in Chinese | | `nameEn` | string | Stock Abbreviation in English | | `industry` | string | Industry | | `securityType` | string | Stock coding Type,refer to [Stock coding Type](#security-type) | | `referencePrice` | number | Reference Price | | `limitUpPrice` | number | Rise Stop Price | | `limitDownPrice` | number | Fall Stop Price | | `canDayTrade` | boolean | Day Trading Indicator | | `canBuyDayTrade` | boolean | Day Trading Indicator (Buy first then sell) | | `canBelowFlatMarginShortSell` | boolean | Exemption of Unchanged Market Margin Sale Indicator | | `canBelowFlatSBLShortSell` | boolean | Exemption of Unchanged Market Lending Sale Indicator | | `isAttention` | boolean | Attention | | `isDisposition` | boolean | Disposition | | `isUnusuallyRecommended` | boolean | Abnormal recommendation indicator | | `isSpecificAbnormally` | boolean | Abnormal securities indicator | | `matchingInterval` | number | Matching Cycle Seconds | | `securityStatus` | string | Status,include `NORMAL`, `TERMINATED`, `SUSPENDED` | | `boardLot` | number | Trading Unit | | `tradingCurrency` | string | Trading Currency | | `exercisePrice` | number | Exercise (Strike) price (warrant) | | `exercisedVolume` | number | Previous Business Day Exercise Volume (warrant) | | `cancelledVolume` | number | Previous Business Day Cancellation Volume (warrant) | | `remainingVolume` | number | Issuing Balance (Volume) (warrant) | | `exerciseRatio` | number | Strike Ratio (warrant) | | `knockInPrice` | number | Upper Limit Price (warrant) | | `knockOutPrice` | number | Lower Limit Price (warrant) | | `maturityDate` | string | Maturity Date (warrant) | | `previousClose` | number | Yesterday closing price | | `openTime` | string | Opening time(index) | | `closeTime` | string | Close time(index) | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.ticker(symbol='2330') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.ticker(symbol='2330') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday.ticker({ symbol: '2330' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var ticker = await rest.Intraday.Ticker("2330"); var ticker_cont = ticker.Content.ReadAsStringAsync().Result; Console.WriteLine(ticker_cont); ``` 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" } ``` #### Security Type[​](#security-type "Direct link to Security Type") | Code | Security Type | Code | Security Type | | ---- | ------------------------------------------------------------------------------------------------------------------------------ | ---- | ----------------------------------------------------- | | `01` | Common Stocks | `24` | ETF | | `02` | Convertible Bonds | `25` | ETF(in foreign currencies) | | `03` | Exchangeable Corporate Bonds, Exchangeable Financial Bonds | `26` | Leveraged ETFs | | `04` | General Preferred Stocks | `27` | Leveraged ETFs (in foreign currencies) | | `05` | Exchangeable Preferred Stocks | `28` | Inverse ETFs | | `06` | Subscription warrants | `29` | Inverse ETFs (in foreign currencies) | | `07` | Preferred Stocks with Warrants | `30` | Futures Trust ETFs | | `08` | Debentures with Warrants | `31` | Futures Trust ETFs (in foreign currencies) | | `09` | Cooperate Bonds of Performed Debentures with Warrants | `32` | Bond ETF | | `10` | Callable Bull Contract with domestic securities or index as underlying assets. | `33` | Bond ETF(in foreign currencies) | | `11` | Callable Bear Contract with domestic securities or index as underlying assets | `34` | Financial Asset Securitization Beneficiary Securities | | `12` | Callable Bull Contract with foreign securities or indexes as underlying assets | `35` | Real Estate Asset Trust Beneficiary Securities | | `13` | Callable Bear Contract with foreign securities or indexes as underlying assets | `36` | Real Estate Investment Trust Beneficiary Securities | | `14` | “Lower Limit Callable Bull Contract” (Bull Contract) with domestic securities or indexes as underlying assets | `37` | ETN | | `15` | “Upper Limit Callable Bear Contract” (Bear Contract) with domestic securities or indexes as underlying assets | `38` | Leveraged ETN | | `16` | “Open-End Callable Bull Contract” whose underlying assets are domestic securities or indices (Open-End Callable Bull Contract) | `39` | Inverse ETN | | `17` | “Open-End Callable Bear Contract” whose underlying assets are domestic securities or indices (Open-End Callable Bear Contract) | `40` | Bond ETN | | `18` | Beneficiary Certificate | `41` | Strategy ETN | | `19` | Depository Receipt | `42` | Government Bonds | | `20` | Corporate Bond Convertible into Depository Receipts | `43` | Foreign Securities | | `21` | Corporate Bond with Warrants on Depository Receipts | `44` | Spot gold market | | `22` | Remaining Corporate Bond with Warrants Exercised for Depository Receipts | `00` | Remain | | `23` | Warrant on Depository Receipts | | | --- ### Intraday Tickers Stock or index lists (query by conditions) ```text intraday/tickers ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | --------------- | ------- | ------------------------------------------------------------------------------- | | `type`\* | string | Ticker Type, `EQUITY` stock;`INDEX` index;`WARRANT` warrant `ODDLOT` odd-lot | | `exchange` | string | exchange, `TWSE` twse;`TPEx` tpex | | `market` | string | market type, `TSE` ;`OTC` ;`ESB` ;`TIB` ;`PSB` | | `industry` | string | [Industry Code](#industry-code) | | `isNormal` | boolean | Normal status(Not Attention and Disposition):`true` | | `isAttention` | boolean | Attention:`true` | | `isDisposition` | boolean | Disposition :`true` | | `isHalted` | boolean | Suspended : `true` | 股票專用條件 `isNormal`、`isAttention`、`isDisposition`、`isHalted` are inquiry flags specifically for stocks. If one of these flags is set, the returned list will be the corresponding stocks. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------- | --------- | ---------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker type | | `exchange`\* | string | exchange type | | `market` | string | market type | | `industry` | string | industry code | | `isNormal` | boolean | Normal status(Not Attention and Disposition) | | `isAttention` | boolean | Attention | | `isDisposition` | boolean | Disposition | | `isHalted` | boolean | Suspended | | `data` | object\[] | list | | >> `symbol` | string | Stock number | | >> `name` | string | Stock Abbreviation in Chinese | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.tickers(type='EQUITY', exchange="TWSE", isNormal=True) # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.tickers(type='EQUITY', exchange="TWSE", isNormal=True) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday .tickers({ type: "EQUITY", exchange: "TWSE", isNormal: true }) .then((data) => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var ticker = await rest.Intraday.Tickers(FugleMarketData.QueryModels.Stock.Intraday.TickersType.Equity); var ticker_cont = ticker.Content.ReadAsStringAsync().Result; Console.WriteLine(ticker_cont); ``` 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": "富邦科技" }, ...... ] } ``` #### Industry Code[​](#industry-code "Direct link to Industry Code") | Code | Industry | Code | Industry | Code | Industry | | ---- | ------------------------------------- | ---- | ---------------------------------------- | ---- | ----------------------------------------- | | `01` | Cement Industry | `16` | Tourism and Hospitality | `29` | Electronic Products Distribution Industry | | `02` | Food Industry | `17` | Finance & Insurance | `30` | Information Service Industry | | `03` | Plastic Industry | `18` | ~~Wholesale & Retailing~~ | `31` | Other Electronic Industry | | `04` | Textile & Fiber | `19` | Miscellaneous | `32` | Cultural and Creative Industries | | `05` | Electrical Engineering & Machinery | `20` | Other | `33` | Agricultural Technology Industry | | `06` | Appliance & Cable | `21` | Chemical Industry | `34` | ~~E commerce~~ | | `08` | Glass & Ceramics | `22` | Biotechnology & Medical Care | `35` | Green Energy and Environmental Services | | `09` | Papermaking Industry | `23` | Oil, Gas and Electricity Industry | `36` | Digital and Cloud Services | | `10` | Steel & Iron Industry | `24` | Semiconductor Industry | `37` | Sports and Leisure | | `11` | Rubber Industry | `25` | Computer & Peripheral Equipment Industry | `38` | Household | | `12` | Auto Industry | `26` | Optoelectronic Industry | `80` | TDR | | `14` | Construction Materials & Construction | `27` | Communications and Internet Industry | | | | `15` | Sea Transport Industry | `28` | Electronic Parts/Components Industry | | | --- ### Intraday Trades Stock trade details (query by stock number). ```text intraday/trades/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------------------- | | `symbol`\* | string | Stock Number | | `type` | string | Ticker Type,Also offer `oddlot` Odd-lot | | `offset` | number | Offset | | `limit` | number | Limit | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | -------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `data`\* | object\[] | list | | >> `bid` | number | Trading Bid Price | | >> `ask` | number | Trading Ask Price | | >> `price` | number | Trading Price | | >> `size` | number | Trading Volume | | >> `volume` | number | Trading Total Volume | | >> `time` | number | Trading Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.trades(symbol='2330') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.trades(symbol='2330') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday.trades({ symbol: '2330' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var trade = await rest.Intraday.Trades("2330"); // var trade = await rest.Intraday.Trades("2330", new(){Type=FugleMarketData.QueryModels.TickerType.OddLot}); // Odd lot var trade_cont = trade.Content.ReadAsStringAsync().Result; Console.WriteLine(trade_cont); ``` 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 Stock price-volume data(query by stock number) ```text intraday/volumes/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | --------------------------------- | | `symbol`\* | string | Stock Number | | `type` | string | Type,Also offer `oddlot` odd-lot | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------- | --------- | --------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker type | | `exchange`\* | string | Exahange | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `data` | object\[] | list | | >> `price` | number | Trading Price | | >> `volume` | number | Accumulative Volume on this Price | | >> `volumeAtBid` | number | Accumulative Bid Volume | | >> `volumeAtAsk` | number | Accumulative Ask Volume | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.intraday.volumes(symbol='2330') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.intraday.volumes(symbol='2330') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.intraday.volumes({ symbol: '2330' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var volume = await rest.Intraday.Volume("2330"); // var volume = await rest.Intraday.Volume("2330", , new(){Type=FugleMarketData.QueryModels.TickerType.OddLot}); // Odd lot var volume_cont = volume.Content.ReadAsStringAsync().Result; Console.WriteLine(volume_cont); ``` 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 Stock trading value ranking (by market type). ```text snapshot/actives/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------- | | `market`\* | string | Market Type,offer `TSE` ;`OTC` ;`ESB` ;`TIB` ;`PSB` | | `trade`\* | string | Trading Volume/Value,offer `volume` ;`value` | | `type` | string | Asset type options,offer `ALLBUT099` for common stocks, preferred stocks, and ETFs; `COMMONSTOCK` for common stocks only | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | ----------------------------- | | `date`\* | string | Date | | `time`\* | string | Time | | `market`\* | string | Market Type | | `trade`\* | string | Trading Volume/Value | | `data`\* | object\[] | list | | >> `type` | string | Ticker Type | | >> `symbol` | string | Stock Number | | >> `name` | string | Stock Abbreviation in Chinese | | >> `openPrice` | number | Opening Price | | >> `highPrice` | number | Highest Price | | >> `lowPrice` | number | Lowest Price | | >> `closePrice` | number | Close Price | | >> `change` | number | Price Change | | >> `changePercent` | number | Price Change Percentage | | >> `tradeVolume` | number | Trading Volume | | >> `tradeValue` | number | Trading Value | | >> `lastUpdated` | number | Snapshot Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.snapshot.actives(market='TSE', trade='value') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.snapshot.actives(market='TSE', trade='value') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.snapshot.actives({ market: 'TSE', trade: 'value' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var quote = await rest.Snapshot.Quotes(FugleMarketData.QueryModels.MarketType.TSE) var quote_cont = quote.Content.ReadAsStringAsync().Result; Console.WriteLine(quote_cont); ``` 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 Stock Price Change Ranking (by market type) ```text snapshot/movers/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- | | `market`\* | string | Market Type | | `direction`\* | string | Rise/Fall,Offer `up` Rise;`down` Fall | | `change`\* | string | Change/Change percentage,Offer `percent` ;`value` | | `type` | string | Asset type options,offer `ALLBUT099` for common stocks, preferred stocks, and ETFs; `COMMONSTOCK` for common stocks only | | `gt` | number | Filter Greater than `change` | | `gte` | number | Filter Greater than or equal to `change` | | `lt` | number | Filter Less then `change` | | `lte` | number | Filter Less than or equal to `change` | | `eq` | number | Filter Equal to `change` | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | ----------------------------- | | `date`\* | string | Date | | `time`\* | string | Time | | `market`\* | string | Market Type | | `change`\* | string | Change/Change percentage | | `data`\* | object\[] | list | | >> `type` | string | Ticker Type | | >> `symbol` | string | Stock Number | | >> `name` | string | Stock Abbreviation in Chinese | | >> `openPrice` | number | Opening Price | | >> `highPrice` | number | Highest Price | | >> `lowPrice` | number | Lowest Price | | >> `closePrice` | number | Close Price | | >> `change` | number | Price Change | | >> `changePercent` | number | Price Change Percentage | | >> `tradeVolume` | number | Trading Volume | | >> `tradeValue` | number | Trading Value | | >> `lastUpdated` | number | Snapshot Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```py from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.snapshot.movers(market='TSE', direction='up', change='percent') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.snapshot.movers(market='TSE', direction='up', change='percent') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.snapshot.movers({ market: 'TSE', direction: 'up', change: 'percent' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var movers = await rest.Snapshot.Movers(FugleMarketData.QueryModels.MarketType.TSE, FugleMarketData.QueryModels.DirectionType.Up, FugleMarketData.QueryModels.ChangeType.Percent); var movers_cont = movers.Content.ReadAsStringAsync().Result; Console.WriteLine(movers_cont); ``` 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 Stock market snapshot (by market type). ```text snapshot/quotes/{market} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------- | | `market`\* | string | Market Type,Offer `TSE`; `OTC`;`ESB`;`TIB`;`PSB` | | `type` | string | Asset type options,offer `ALLBUT099` for common stocks, preferred stocks, and ETFs; `COMMONSTOCK` for common stocks only | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | --------- | ----------------------------- | | `date`\* | string | Date | | `time`\* | string | Time | | `market`\* | string | Market Type | | `data`\* | object\[] | list | | >> `type` | string | Ticker Type | | >> `symbol` | string | Stock Number | | >> `name` | string | Stock Abbreviation in Chinese | | >> `openPrice` | number | Opening Price | | >> `highPrice` | number | Highest Price | | >> `lowPrice` | number | Lowest Price | | >> `closePrice` | number | Close Price | | >> `change` | number | Price Change | | >> `changePercent` | number | Price Change Percentage | | >> `tradeVolume` | number | Trading Volume | | >> `tradeValue` | number | Trading Value | | >> `lastUpdated` | number | Last Snapshot time | | >> `lastPrice` | number | Last Price(include trial) | | >> `isTrial` | boolean | Trial:`true` | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login first before connecting market-data sdk.init_realtime() # Establish market-data reststock = sdk.marketdata.rest_client.stock # reststock.snapshot.quotes(market='TSE') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: reststock.snapshot.quotes(market='TSE') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data const client = sdk.marketdata.restClient client.stock.snapshot.quotes({ market: 'TSE' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market-data var rest = sdk.MarketData.RestClient.Stock; var quotes = await rest.Snapshot.Quotes(FugleMarketData.QueryModels.MarketType.TSE); var quotes_cont = quotes.Content.ReadAsStringAsync().Result; Console.WriteLine(quotes_cont); ``` 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 Get Bollinger Bands for a specific stock within a specified time range ```text technical/bb/{symbol} ``` Version Note Available since v2.2.6 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date (format: `yyyy-MM-dd`) | | `to`\* | string | End date (format: `yyyy-MM-dd`) | | `timeframe`\* | string | K-line period, options: `1` 1-min K; `5` 5-min K; `10` 10-min K; `15` 15-min K; `30` 30-min K; `60` 60-min K; `D` daily K; `W` weekly K; `M` monthly K | | `period`\* | number | Bollinger period | caution Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------- | ------ | --------------------- | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date | | `to`\* | string | End date | | `timeframe`\* | string | K-line period | | `period`\* | string | RSI period | | `data` | Object | RSI data | | >> `data[0].date` | string | Data date | | >> `data[0].upper` | number | Bollinger upper band | | >> `data[0].middle` | number | Bollinger middle band | | >> `data[0].lower` | number | Bollinger lower band | info '\*' indicates required fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later use simplified approach (using Exception for error handling) from fubon_neo.sdk import FugleAPIError try: reststock.technical.bb(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 10}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Example: 429 print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame using FugleMarketData.QueryModels; // Import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; DateTime fromDate = new DateTime(2024, 8, 1); DateTime toDate = new DateTime(2024, 8, 10); var bband = await rest.Technical.Bb("2330" ,new(10, fromDate, toDate, HistoryTimeFrame.Day)); //BbRequest parameters (period, DateTime, DateTime, HistoryTimeFrame) var bband_con = bband.Content.ReadAsStringAsync().Result; Console.WriteLine(bband_con); ``` 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 Get Stochastic Indicator (KDJ) for a specific stock within a specified time range ```text technical/kdj/{symbol} ``` Version Note Available since v2.2.6 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date (format: `yyyy-MM-dd`) | | `to`\* | string | End date (format: `yyyy-MM-dd`) | | `timeframe`\* | string | K-line period, options: `1` 1-min K; `5` 5-min K; `10` 10-min K; `15` 15-min K; `30` 30-min K; `60` 60-min K; `D` daily K; `W` weekly K; `M` monthly K | | `rPeriod`\* | number | KDJ period | | `kPeriod`\* | number | %K period | | `dPeriod`\* | number | %D period | caution Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ------------- | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date | | `to`\* | string | End date | | `timeframe`\* | string | K-line period | | `rPeriod`\* | number | KDJ period | | `kPeriod`\* | number | %K period | | `dPeriod`\* | number | %D period | | `data`\* | Object | KDJ data | | >> `data[0].date` | string | Data date | | >> `data[0].k` | number | K | | >> `data[0].d` | number | D | | >> `data[0].j` | number | J | info '\*' indicates required fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later use simplified approach (using Exception for error handling) from fubon_neo.sdk import FugleAPIError try: reststock.technical.kdj(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "rPeriod": 9, "kPeriod":3, "dPeriod":3}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Example: 429 print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame using FugleMarketData.QueryModels; // Import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; DateTime fromDate = new DateTime(2024, 8, 1); DateTime toDate = new DateTime(2024, 8, 10); var kdj = await rest.Technical.Kdj("2330" ,new(9,3,3, fromDate, toDate, HistoryTimeFrame.Day)); //Kdj parameters (rPeriod, kPeriod, dPeriod, DateTime, DateTime, HistoryTimeFrame) var kdj_con = kdj.Content.ReadAsStringAsync().Result; Console.WriteLine(kdj_con); ``` 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 Get Moving Average Convergence Divergence (MACD) for a specific stock within a specified time range ```text technical/macd/{symbol} ``` Version Note Available since v2.2.6 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date (format: `yyyy-MM-dd`) | | `to`\* | string | End date (format: `yyyy-MM-dd`) | | `timeframe`\* | string | K-line period, options: `1` 1-min K; `5` 5-min K; `10` 10-min K; `15` 15-min K; `30` 30-min K; `60` 60-min K; `D` daily K; `W` weekly K; `M` monthly K | | `fast`\* | number | Fast line period | | `slow`\* | number | Slow line period | | `signal`\* | number | Signal line period | caution Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------------- | ------ | ------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date | | `to`\* | string | End date | | `timeframe`\* | string | K-line period | | `fast`\* | number | Fast line period | | `slow`\* | number | Slow line period | | `signal`\* | number | Signal line period | | `data` | Object | RSI data | | >> `data[0].date` | string | Data date | | >> `data[0].macdLine` | number | MACD line | | >> `data[0].signalLine` | number | Signal line | info '\*' indicates required fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later use simplified approach (using Exception for error handling) from fubon_neo.sdk import FugleAPIError try: reststock.technical.macd(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "fast": 12, "slow":26, "signal":9}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Example: 429 print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame using FugleMarketData.QueryModels; // Import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; DateTime fromDate = new DateTime(2024, 8, 1); DateTime toDate = new DateTime(2024, 8, 10); var macd = await rest.Technical.Macd("2330" ,new( 12, 26, 9, fromDate, oDate, HistoryTimeFrame.Day)); //MacdRequest parameters (fast, slow, signal DateTime, DateTime, HistoryTimeFrame) var macd_con = macd.Content.ReadAsStringAsync().Result; Console.WriteLine(macd_con); ``` 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 Get Relative Strength Index (RSI) for a specific stock within a specified time range ```text technical/rsi/{symbol} ``` Version Note Available since v2.2.6 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date (format: `yyyy-MM-dd`) | | `to`\* | string | End date (format: `yyyy-MM-dd`) | | `timeframe`\* | string | K-line period, options: `1` 1-min K; `5` 5-min K; `10` 10-min K; `15` 15-min K; `30` 30-min K; `60` 60-min K; `D` daily K; `W` weekly K; `M` monthly K | | `period`\* | number | RSI period | caution Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ------------- | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date | | `to`\* | string | End date | | `timeframe`\* | string | K-line period | | `period`\* | string | RSI period | | `data` | Object | RSI data | | >> `data[0].date` | string | Data date | | >> `data[0].rsi` | number | RSI | info '\*' indicates required fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later use simplified approach (using Exception for error handling) from fubon_neo.sdk import FugleAPIError try: reststock.technical.rsi(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 6}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Example: 429 print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame using FugleMarketData.QueryModels; // Import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; DateTime fromDate = new DateTime(2024, 8, 1); DateTime toDate = new DateTime(2024, 8, 10); var rsi = await rest.Technical.Rsi("2330" ,new(6, fromDate, toDate, HistoryTimeFrame.Day)); //RsiRequest parameters (period, DateTime, DateTime, HistoryTimeFrame) var rsi_con = rsi.Content.ReadAsStringAsync().Result; Console.WriteLine(rsi_con); ``` 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 Get Simple Moving Average (SMA) for a specific stock within a specified time range ```text technical/sma/{symbol} ``` Version Note Available since v2.2.6 #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date (format: `yyyy-MM-dd`) | | `to`\* | string | End date (format: `yyyy-MM-dd`) | | `timeframe`\* | string | K-line period, options: `1` 1-min K; `5` 5-min K; `10` 10-min K; `15` 15-min K; `30` 30-min K; `60` 60-min K; `D` daily K; `W` weekly K; `M` monthly K | | `period`\* | int | SMA period | caution Currently, minute K-lines cannot specify start date (from) and end date (to), and will always return the most recent 30 days of data. #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ----------------- | ------ | ------------- | | `symbol`\* | string | Stock symbol | | `from`\* | string | Start date | | `to`\* | string | End date | | `timeframe`\* | string | K-line period | | `period`\* | string | SMA period | | `data` | Object | SMA data | | >> `data[0].date` | string | Data date | | >> `data[0].sma` | number | SMA | info '\*' indicates required fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # Login required to obtain market data permissions sdk.init_realtime() # Establish market data connection reststock = sdk.marketdata.rest_client.stock ## Version 2.2.6 and later use simplified approach (using Exception for error handling) from fubon_neo.sdk import FugleAPIError try: reststock.technical.sma(**{"symbol": "2330", "from": "2024-08-01", "to": "2024-08-10","timeframe":"D", "period": 5}) except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Example: 429 print(f"Response Text: {e.response_text}") # Example: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); // Establish market data connection 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)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.Stock.History; // Import HistoryTimeFrame using FugleMarketData.QueryModels; // Import FieldsType var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); // Establish market data connection var rest = sdk.MarketData.RestClient.Stock; DateTime fromDate = new DateTime(2024, 8, 1); DateTime toDate = new DateTime(2024, 8, 10); var sma = await rest.Technical.Sma("2330" ,new(5, fromDate, toDate, HistoryTimeFrame.Day)); //SmaRequest parameters (period, DateTime, DateTime, HistoryTimeFrame) var sma_con = sma.Content.ReadAsStringAsync().Result; Console.WriteLine(sma_con); ``` 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 } ] } ``` --- ### Fubon Neo API Securities Market Data Key takeaways * Fubon Neo API Securities Market Data provides real-time and historical data for Taiwan markets. * Interfaces include Web API and WebSocket API. * Data sources are official exchanges and vendors; please follow usage regulations. * Next step: [Web API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/getting-started.md) or [WebSocket API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md). | Item | Details | | ------------ | ------------------------ | | Service | Securities Market Data | | Markets | Taiwan securities market | | Interfaces | Web API / WebSocket API | | Data sources | TWSE, TPEx, TAIFEX | The real-time market data source includes the Taiwan Stock Exchange (TWSE), and the Taiwan Futures Exchange.
Please refer to the relevant [regulations and statements](#statement) for more information. #### Web API[​](#web-api "Direct link to Web API") Fubon Market Data [Web API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/http-api/getting-started.md) provides developer-friendly services. You can access intraday data, snapshots, and historical market data for the Taiwan stock market. Data sources are Infotimes and Fugle. #### WebSocket API[​](#websocket-api "Direct link to WebSocket API") Fubon Market Data [WebSocket API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md) provides real-time stock market data for Taiwan. Use the WebSocket API to receive real-time data. #### Usage regulations and statements[​](#statement "Direct link to Usage regulations and statements") * The market data obtained through this service is for reference only. It does not include odd-lot or block trades in the transaction value and volume. Users are responsible for any trading losses incurred based on this data。 * Fubon is not responsible for data content errors, delays in updates, or transmission interruptions. You are solely responsible for any financial or investment decisions you make。 * Users are required to follow the [Regulations on the Use of Trading Information of Taiwan Stock Exchange Corporation](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10809760\&releaseDate=2021-12-24&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQSkUGuPSgl5XdBmvh4pfksZDSCPO97cowzuq2kozOK-jcEsrQLo0zV7piJ2v-0_Iu0T59qkMYtXhtWTHqd_tx99cczJ-iz2jNYx0wjaCIZTYDYTsJtarx1wUtmCH2y7hZs)、[Regulations on the Use of Trading Information of Taiwan Futures Exchange Corporation](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10815483\&releaseDate=2020-02-13&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQRBdJkoAtEZZLAng4diPK7D2b226xLMNWc93GlTy5KWHc25EhHhnPDU9iJRdDvbu7cldj7dJMTv9vZoFF4brLW6KY3MFCc-KIzRZueu2MFWP01PaDehsVdaM0YPBB_ZJGI)、[Regulations on the Use of Trading Information of the Taiwan Securities Association](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10813063\&releaseDate=2024-01-23&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQQis8j2jnRvWRu6TJnh7JHmOGCfonv9gz0Q6ez38d3M_-Em3KcMbA7v6qUbziRLV83yyombkIWengQFc1Bgtz23kCC-y2GvB5YVrS2h4b1v5c8JSKvjZsEkwSQKCPI3SmQ)、Users are required to comply with the information usage regulations established by each information source provider, as well as relevant intellectual property laws. All information is subject to the data officially announced by each information source provider. Any unauthorized interception, retransmission of trading information, or any other form of selling, renting, transferring, or re-authorizing trading information, or resampling trading information to create indices, other derivative products, or transmitting it to third parties may result in legal consequences, including civil and criminal liability for breach of contract and infringement。 * Fubon Neo API Market Data is developed and provided by the [Fugle](https://www.fugle.tw/) technology team。 --- ### Establish Connections ##### Establish Market Data Connections[​](#establish-market-data-connections "Direct link to Establish Market Data Connections") Key takeaways * Demonstrates how to establish multiple WebSocket connections (limit 5). * Web API rate limits are shared; WebSocket limit is 200 subscriptions per connection. The following example demonstrates how to establish five WebSocket connections for market data simultaneously. info Typically, multiple simultaneous connections are only needed when using WebSocket. For Web API, it is recommended to use a single connection for easier management. Web API rate limits are shared across all connections; each WebSocket connection can subscribe to up to 200 targets. * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") # Login is required to obtain market data permissions websockets = [] # List of WebSocket interfaces for different connections for _ in range(5): # Create 5 connections sdk.init_realtime() # Start a market data connection ws = sdk.marketdata.websocket_client.stock # WebSocket interface (Stocks) #ws = sdk.marketdata.websocket_client.futopt # WebSocket interface (Futures/Options) # Add the interface to the available list websockets.append(ws) # Set WebSocket callbacks and open connections for ws in websockets: ## Callback functions need to be defined separately ## ws.on('message', handle_message) # Register market data callback ws.on("connect", handle_connect) # Register connection event callback ws.on("disconnect", handle_disconnect) # Register disconnection event callback ws.on("error", handle_error) # Register error event callback ws.connect() # Activate the connection # Disconnect connections # for ws in websockets: # we.disconnect() ``` ```js const { FubonSDK } = require('fubon-neo'); // Login is required to obtain market data permissions const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); const websockets = []; // List of WebSocket interfaces for different connections // Create 5 market data connections for (let i = 0; i < 5; i++) { // Start a market data connection sdk.initRealtime(); // Get WebSocket interface const ws = sdk.marketdata.webSocketClient.stock; // (Stocks) //const ws = sdk.marketdata.webSocketClient.futopt; // (Futures/Options) // Add the interface to the available list websockets.push(ws); } // Set WebSocket callbacks and open connections for (const ws of websockets) { /* -- Callback functions need to be defined separately -- */ ws.on('message', handle_message); // Register market data callback ws.on('connect', handle_connect); // Register connection event callback ws.on('disconnect', handle_disconnect); // Register disconnection event callback ws.on('error', handle_error); // Register error event callback // Activate the connection (async () => { await ws.connect(); })() } // Disconnect connections //for (const ws of websockets) { // (async () => { // await ws.disconnect(); // })() //} ``` ```cs using FubonNeo.Sdk; // Login is required to obtain market data permissions var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); // List of WebSocket interfaces for different connections var websockets = new List(); // (Stocks) //var websockets = new List(); // (Futures/Options) // Create 5 market data connections for (int i = 0; i < 5; i++) { sdk.InitRealtime(); // Start a market data connection // Get WebSocket interface var ws = sdk.MarketData.WebSocketClient.Stock; // (Stocks) //var ws = sdk.MarketData.WebSocketClient.FutureOption; // (Futures/Options) // Add the interface to the available list websockets.Add(ws); } // Set WebSocket callbacks and open connections foreach (var ws in websockets) { ws.OnMessage = (msg) => Console.WriteLine($"OnMessage receive: {msg}"); // Register market data callback ws.OnError = (msg) => Console.WriteLine($"OnError receive: {msg}"); // Register error event callback ws.OnConnected = (msg) => Console.WriteLine($"OnConnected receive: {msg}"); // Register connection event callback ws.OnDisconnected = (msg) => Console.WriteLine($"OnDisconnected receive: {msg}"); // Register disconnection event callback // Activate the connection await ws.Connect(); } // Disconnect connections // foreach (var ws in websockets) // { // await ws.Disconnect(); // } ``` --- ### Rate Limit ##### Rate Limit[​](#rate-limit "Direct link to Rate Limit") Key takeaways * This page lists Web API and WebSocket rate limits for Fubon Neo API Market Data. * Exceeding limits returns `429` or WebSocket subscription errors. * Rapid connection bursts may be blocked. | Item | Limit | | ---------- | ----------------------------------------------- | | Intraday | 300 / min | | Snapshot | 300 / min | | Historical | 60 / min | | WebSocket | 200 subscriptions per connection; 5 connections | Fubon Neo API Market Data provides Web API and WebSocket with the following access restrictions. * Intraday : 300 / min * WebSocket : 200 Subscription;5 Connection * Snapshot : 300 / min * Historical : 60 / min If your API requests exceed the limit, you will receive a response with status code `429`. Please wait for 1 minute before making additional requests. ```json {"statusCode":429,"message":"Rate limit exceeded"} ``` If your WebSocket subscriptions exceed the upper limit, you will receive the following message:" ```json { "event": "error", "data": { "code": 1001, "message": "Maximum number of connections reached" } } ``` caution If a large number of Socket connections are established within a short period, the system will consider it a malicious attack and block your connection requests (404 Not Found error). If you encounter this situation, please contact . --- ### Quick Start Key takeaways * Fubon Market Data WebSocket API provides real-time market data subscriptions. * Supports `Speed` and `Normal` modes. * Login is required before subscribing to channels. | Item | Details | | ------------ | ---------------------------------- | | Interface | WebSocket API | | Market | Taiwan equities | | Modes | Speed / Normal | | SDK | Python / Node.js / C# | | Subscription | Connect then subscribe to channels | Fubon Market Data WebSocket API provides real-time stock market data services for Taiwan. Use WebSocket to receive real-time market data. #### Using SDK[​](#using-sdk "Direct link to Using SDK") Fubon Market Data WebSocket API provides Python, Node.js, and C# SDKs. You can access the WebSocket API through the following methods: And subscribe webSocket callback method to receive the callback messages below. info WebSocket api provides Low Latency `Speed` Mode and Multi-Information `Normal` Mode. * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Mode def handle_message(message): print(message) sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime() # Establish market-data # Offer MarketData Mode , Default : Speed # sdk.init_realtime(Mode.Speed) or sdk.init_realtime(Mode.Normal) stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(); // Establish market-data // Offer MarketData Mode , Default : Speed // sdk.initRealtime(Mode.Speed) or sdk.initRealtime(Mode.Normal) 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': '2881' }); })() ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); // Establish market-data // Offer MarketData Mode , Default : Speed // sdk.InitRealtime(Mode.Speed) or sdk.InitRealtime(Mode.Normal) var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); ``` #### Authenticated[​](#authenticated "Direct link to Authenticated") When the verification is successful, you will receive the following message: ```json { "event": "authenticated", "data": { "message": "Authenticated successfully" } } ``` When the verification is failed, you will receive the following message: ```json { "event": "error", "data": { "message": "Invalid authentication credentials" } } ``` #### Heartbeat[​](#heartbeat "Direct link to Heartbeat") Every 30 seconds, the WebSocket server will send out a heartbeat message: ```json { "event": "heartbeat", "data": { "time": "" } } ``` #### Ping/Pong[​](#pingpong "Direct link to Ping/Pong") Every 5 seconds, sdk will send the following JSON-formatted message to the WebSocket Server, or follow the below example (where `state` is optional): * Python * Node.js * C# ```python stock.ping({ 'state' : '' }) ``` ```js stock.ping({state:''}); ``` ```cs stock.ping(""); ``` The WebSocket Server will respond with the following message (if `ping` was sent, the `state` field will not be present): ```json { "event": "pong", "data": { "time": "", "state": "" } } ``` #### Channels[​](#channels "Direct link to Channels") The Fubon Market Data WebSocket API currently provides the following subscribable channels: * `trades` - [Subscribe to the latest stock trade information](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/market-data-channels/trades.md) * `books` - [Subscribe to the latest top five bid and ask information for stocks](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/market-data-channels/books.md) * `indices` - [Subscribe to the latest index market data](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/market-data-channels/indices.md) ##### Subscribe Channel[​](#subscribe-channel "Direct link to Subscribe Channel") Subscribe to a channel, send following example to the WebSocket Server: * Python * Node.js * C# ```python stock.subscribe({ "channel" : "", "symbol" : "" #"intradayOddLot": True Subscribe intradayOdd }) ``` ```js stock.subscribe({ channel: '', symbol: '', //intradayOddLot: true Subscribe intradayOdd }); ``` ```cs stock.Subscribe(StockChannel.,""); //stock.Subscribe(StockChannel.Trades,new StockSubscribeParams{Symbol="", IntradayOddLot=true}); Subscribe intradayOdd ``` After a successful subscription, you will receive the following event response: ```json { "event": "subscribed", "data": { "id": "", "channel": "", "symbol": "" } } ``` Supports the subscription of multiple stocks within the same channel: * Python * Node.js * C# ```python stock.subscribe({ "channel" : "", "symbols" : ["",""] #"intradayOddLot": True Subscribe intradayOdd }) ``` ```js stock.subscribe({ channel: '', symbols: ['',''] //intradayOddLot: true Subscribe intradayOdd }); ``` ```cs stock.Subscribe(StockChannel.,"",""); //stock.Subscribe(StockChannel.Trades, new StockSubscribeParams{Symbols = new List{"", ""}, IntradayOddLot=true}); Subscribe intradayOdd ``` After a successful subscription, you will receive the following event response: ```json { "event": "subscribed", "data": [ { "id": "", "channel": "", "symbol": "" }, { "id": "", "channel": "", "symbol": "" } ] } ``` ##### Unsubscribe[​](#unsubscribe "Direct link to Unsubscribe") Unsubscribe from a subscribed channel, please send the following example to WebSocket Server: * Python * Node.js * C# ```python stock.unsubscribe({ 'id':'' }) ``` ```js stock.unsubscribe({ id : '' }); ``` ```cs stock.Unsubscribe(""); ``` After a successful unsubscription, you will receive the following event response: ```json { "event": "unsubscribed", "data": { "id": "", "channel" : "", "symbol" : "" } } ``` Supports the unsubscription from multiple channels: * Python * Node.js * C# ```python stock.unsubscribe({ 'ids':['',''] }) ``` ```js stock.unsubscribe({ ids : ['',''] }); ``` ```cs stock.Unsubscribe("",""); ``` After a successful unsubscription, you will receive the following event response: ```json { "event": "unsubscribed", "data": [ { "id": "", "channel" : "", "symbol" : "" }, { "id": "", "channel" : "", "symbol" : "" } ] } ``` #### Error Handle[​](#error-handle "Direct link to Error Handle") When there is an anomaly in the WebSocket callback you subscribed to or processed, you can handle error messages as follows: * Python * Node.js * C# ```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); }); ``` ```cs stock.OnError += (errmsg) => Console.WriteLine($"handle error: {errmsg}"); stock.OnConnected += (connmsg) => Console.WriteLine($"Connect: {connmsg}"); stock.OnDisconnected += (disconmsg) => Console.WriteLine($"Disconnect: {disconmsg}"); ``` ##### Reconnection[​](#reconnection "Direct link to Reconnection") The following is a simple demonstration that automatically reconnects the websocket when a disconnection event is detected using a callback: * Python * Node.js * C# ```python def handle_disconnect(code, message): print(f'market data disconnect: {code}, {message}') stock.connect() print("Reconnected Succuess") print("Resubscribe") stock.subscribe({ # Resubscribe to the channels and symbols that you have previously subscribed 'channel': '', 'symbol': '' }) ``` ```js stock.on("disconnect", (message) => { console.log(message); stock.connect() console.log("Reconnected Succuess"); stock.subscribe({ channel: '', symbol: '' }); //Resubscribe to the channels and symbols that you have previously subscribed }); ``` ```cs stock.OnDisconnected += async (msg) => { Console.WriteLine($"disconnected at {DateTime.Now}"); await Task.Delay(10); Console.WriteLine("Try Reconnected"); await stock.Connect(); Console.WriteLine("Reconnected Success"); Console.WriteLine("Resubscribe..."); await stock.Subscribe(StockChannel., ""); //Resubscribe to the channels and symbols that you have previously subscribed Console.WriteLine("Resubscribe Success"); }; ``` --- ### Aggregates Subscribe to aggregated market data for stocks #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------------------- | | `channel`\* | string | Subscribe Channel:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | Stock Number | | `intradayOddLot` | boolean | `intradayOddLot` true: intraday OddLot, false: Common Stock, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | ----------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `name`\* | string | Stock Abbreviation in Chinese | | `referencePrice` | number | Reference Price | | `previousClose` | number | The closing price of the previous trading day. | | `openPrice` | number | Opening Price | | `openTime` | number | The opening price transaction time | | `highPrice` | number | Highest Trading Price | | `highTime` | number | Highest Trading Price transaction time | | `lowPrice` | number | Lowest Trading Price | | `lowTime` | number | Lowest Trading Price transaction time | | `closePrice` | number | Close Price | | `closeTime` | number | Close Price transaction time | | `avgPrice` | number | Trading Average Price Today | | `change` | number | Last Trading Price Change | | `changePercent` | number | Last Trading price Change Percentage | | `amplitude` | number | Price Range Today | | `lastPrice` | number | Last Price(include trial) | | `lastSize` | number | Last Trading Volume(include trial) | | `bids` | object\[] | Top 5 bid | | >> `price` | number | Top 5 bid price | | >> `size` | number | Top 5 bid volume | | `asks` | object\[] | Top 5 ask | | >> `price` | number | Top 5 ask price | | >> `size` | number | Top 5 ask volume | | `total` | object | list | | >> `tradeValue` | number | Accumulative Trading Value | | >> `tradeVolume` | number | Accumulative Trading Volume | | >> `tradeVolumeAtBid` | number | Total Bid Order Count | | >> `tradeVolumeAtAsk` | number | Total Ask Order Count | | >> `transaction` | number | Accumulative Transaction count | | >> `time` | number | Accumulative Time Interval | | `lastTrade` | object | list | | >> `bid` | number | Last Trading Bid Price | | >> `ask` | number | Last Trading Ask Price | | >> `price` | number | Last Trading Price | | >> `size` | number | Last Trading Volume | | >> `time` | number | Last Trading Time | | `lastTrial` | object | list | | >> `bid` | number | Last Trial Bid Price | | >> `ask` | number | Last Trial Ask Price | | >> `price` | number | Last Trial Matched Price | | >> `size` | number | Last Trial Matched Volume | | >> `time` | number | Last Trial Matched Time | | `isLimitDownPrice` | boolean | Last Matched is Fall Stop Price:`true` | | `isLimitUpPrice` | boolean | Last Matched is Rise Stop Price:`true` | | `isLimitDownBid` | boolean | Optimal position purchase Fall remarks:`true` | | `isLimitUpBid` | boolean | Optimal position purchase Rise remarks:`true` | | `isLimitDownAsk` | boolean | Optimal position Sale Fall remarks:`true` | | `isLimitUpAsk` | boolean | Optimal position Sale Rise remarks:`true` | | `isLimitDownHalt` | boolean | Held Match And Instantaneous Fall Trend:`true` | | `isLimitUpHalt` | boolean | Held Match And Instantaneous Rise Trend:`true` | | `isTrial` | boolean | Trial:`true` | | `isDelayedOpen` | boolean | Delayed Open:`true` | | `isDelayedClose` | boolean | Delayed Close:`true` | | `isContinuous` | boolean | Last Matched is Continuous Market:`true` | | `isOpen` | boolean | Open Mark:`true` | | `isClose` | boolean | Close Mark:`true` | | `lastUpdated` | number | Last Updated Time | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order, Mode def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime(Mode.Normal) # Establish market-data stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'aggregates', 'symbol': '2330' }) ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(Mode.Normal); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(Mode.Normal); // Establish market-data var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); await stock.Subscribe(StockChannel.Aggregates, "2330"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest top five bid and ask information for stocks #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------------------- | | `channel`\* | string | Subscribe Channel:`trades`, `books`, `indices` | | `symbol`\* | string | Stock Number | | `intradayOddLot` | boolean | `intradayOddLot` true: intraday OddLot, false: Common Stock, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ---------------- | | `symbol`\* | string | Stock Number | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Typ | | `time`\* | number | Time | | `bids` | object\[] | Top 5 bid | | >> `price` | number | Top 5 bid price | | >> `size` | number | Top 5 bid volume | | `asks` | object\[] | Top 5 ask | | >> `price` | number | Top 5 ask price | | >> `size` | number | Top 5 ask volume | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime() # Establish market-data stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'books', 'symbol': '2330' }) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); // Establish market-data var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); await stock.Subscribe(StockChannel.Books, "2330"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest minute K-line data for stocks #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | --------------------------------------------------------------------------- | | `channel`\* | string | Subscribe Channel:`trades`, `candles`, `books`, `aggregates`, `indices` | | `symbol`\* | string | Stock Number | | `intradayOddLot` | boolean | `intradayOddLot` true: intradayOddLot , false: Common Stock, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | ------ | --------------------------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `timeframe`\* | number | KLine Timeframe | | `open`\* | number | Opening Price | | `high`\* | number | Highest Price | | `low`\* | number | Lowest Price | | `close`\* | number | Close Price | | `volume`\* | number | Volume (Common: sheets ; Emg / Odd-lot : share ; Index : Value) | | `average`\* | number | Average Price | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order, Mode def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime(Mode.Normal) # Establish market-data stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'candles', 'symbol': '2330' }) ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(Mode.Normal); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(Mode.Normal); // Establish market-data var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); await stock.Subscribe(StockChannel.Candles, "2330"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest index market data #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Establish market-data stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'indices', 'symbol': 'IR0001' }) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); // Establish market-data var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); await stock.Subscribe(StockChannel.Indices, "IR0001"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest stock trade information #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------------- | ------- | -------------------------------------------------------------------------- | | `channel`\* | string | Channel:`trades`, `books`, `indices` | | `symbol`\* | string | Stock Number | | `intradayOddLot` | boolean | `intradayOddLot` true: intradayOddLot, false: Common Stock, default: false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | ------- | ----------------------------------------------- | | `symbol`\* | string | Stock NUmber | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `time`\* | number | Time | | `serial`\* | number | Serial Number | | `bid` | number | Bid Price | | `ask` | number | Ask Price | | `price` | number | Trading Price | | `size` | number | Trading Volume | | `volume` | number | Total Trading Volume | | `isLimitDownPrice` | boolean | Last Matched is Fall Stop Price:`true` | | `isLimitUpPrice` | boolean | Last Matched is Rise Stop Price:`true` | | `isLimitDownBid` | boolean | Optimal position purchase Fall remarks:`true` | | `isLimitUpBid` | boolean | Optimal position purchase Rise remarks:`true` | | `isLimitDownAsk` | boolean | Optimal position sale Fall remarks:`true` | | `isLimitUpAsk` | boolean | Optimal position sale Fall remarks`true` | | `isLimitDownHalt` | boolean | Held Match And Instantaneous Fall Trend:`true` | | `isLimitUpHalt` | boolean | Held Match And Instantaneous Rise Trend:`true` | | `isTrial` | boolean | Trial:`true` | | `isDelayedOpen` | boolean | Delayed Open:`true` | | `isDelayedClose` | boolean | Delayed Close:`true` | | `isContinuous` | boolean | Last Matched is Continuous Market:`true` | | `isOpen` | boolean | Open Mark:`true` | | `isClose` | boolean | Close Mark:`true` | | `time` | number | Trading Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK def handle_message(message): print(message) sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # 需登入後,才能取得行情權限 sdk.init_realtime() # Establish market-data stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() stock.subscribe({ 'channel': 'trades', 'symbol': '2330' }) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); // Establish market-data var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await stock.Connect(); await stock.Subscribe(StockChannel.Trades, "2330"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data/websocket-api/getting-started.md#subscribe-channel) ##### 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" } ``` --- ### Mode Switching **Applies to versions >= 1.0.4** #### Marketdata WebScoket Mode Switching[​](#marketdata-webscoket-mode-switching "Direct link to Marketdata WebScoket Mode Switching") The new versions provide switching between Low Latency Market Data and Multi-Information Socket Market Data. ##### Import function (Required for Python and NodeJs.)[​](#import-function-required-for-python-and-nodejs "Direct link to Import function (Required for Python and NodeJs.)") * Python * Node.js ```py # Import Mode function from fubon_neo.sdk import FubonSDK, Mode ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); ``` Specify the mode when obtaining market data permissions. * Python * Node.js * C# ```python sdk.init_realtime(Mode.Speed) # Provide Speed / Normal (default : Speed) # sdk.init_realtime(Mode.Speed) or sdk.init_realtime(Mode.Normal) stock = sdk.marketdata.websocket_client.stock stock.on('message', handle_message) stock.connect() ``` ```js sdk.initRealtime(Mode.Speed); // Provide Speed / Normal (default : Speed) //sdk.initRealtime(Mode.Speed); or sdk.initRealtime(Mode.Normal); const stock = sdk.marketdata.webSocketClient.stock; stock.connect() stock.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; // Adding "Mode" sdk.InitRealtime(Mode.Speed); // Provide Speed / Normal (default : Speed) // sdk.InitRealtime(Mode.Speed); or sdk.InitRealtime(Mode.Normal); var stock = sdk.MarketData.WebSocketClient.Stock; stock.OnMessage += (msg) => Console.WriteLine($"receive: {msg}"); await stock.Connect(); ``` --- ### Quick Start Key takeaways * Fubon Futures Market Data Web API provides intraday futures/options data for Taiwan. * Exceeding limits returns status code `429`. * SDK examples are available for Python, Node.js, and C#. | Item | Details | | ---------- | ------------------------ | | Interface | Web API | | Market | Taiwan futures / options | | Data types | Intraday | | Rate limit | `429` on exceed | | SDK | Python / Node.js / C# | Fubon Futures Market Data Web API provides developer-friendly services for Taiwan futures and options. #### Rate Limit[​](#rate-limit "Direct link to Rate Limit") If your API requests exceed the limit, you will receive a response with a status code 429 ( For detailed limitations, please refer to [Rate Limit](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/rate-limit.md) ) #### API Category[​](#api-category "Direct link to API Category") Web API are categorized based on data types: * `/intraday/products` - [Futures and Options Contract List(Query by conditions)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/products.md) * `/intraday/tickers` - [Futures and Options product list(Query by condition)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/tickers.md) * `/intraday/quote/{symbol}` - [Real-time quotes (query by symbol)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/quote.md) * `/intraday/candles/{symbol}` - [Contract K Line(Query by symbol)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/candles.md) * `/intraday/trades/{symbol}` - [Contract trade details (query by symbol)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/trades.md) * `/intraday/volumes/{symbol}` - [Futures and Options price-volume data(query by symbol)](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/intraday/volumes.md) #### Using SDK[​](#using-sdk "Direct link to Using SDK") Fubon Futures Market Data Web API offers Python, Node.js, and C# SDKs. You can access the API through the following methods: * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order # Since version 2.2.4, add the following import: # from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() restfutopt = sdk.marketdata.rest_client.futopt ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient const futopt = client.futopt; ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; ``` --- ### Intraday Candles Contract K Line(Query by symbol) ```text intraday/candles/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ----------- | ------ | ------------------------------------------------------------ | | `symbol`\* | string | Contract Symbol | | `session` | string | Session Type,valid in `afterhours` | | `timeframe` | string | K Line Timeframe ,valid in `1`;`5`;`10`;`15`;`30`;`60` | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | --------- | ---------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange Type | | `market` | string | Market Type | | `symbol`\* | string | Contract Symbol | | `timeframe`\* | number | K Line Timeframe | | `data`\* | object\[] | K Line Data | | >> `time` | number | K Line Time | | >> `open`\* | number | Opening Price | | >> `high`\* | number | Highest Price | | >> `low`\* | number | Lowest Price | | >> `close`\* | number | Close Price | | >> `volume` | number | Volume | | >> `average` | number | Average Price | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") sdk.init_realtime() restfut = sdk.marketdata.rest_client.futopt # restfut.intraday.candles(symbol='TXFA4') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfut.intraday.candles(symbol='TXFA4') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.candles({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var candles = await rest.Intraday.Candles("TXFA4"); // var candles = await rest.Intraday.Candles("TXFA4", new(){TimeFrame=FugleMarketData.QueryModels.FuOpt.Intraday.CandlesTimeFrame.FifteenMin}); // 15min timeframe var candle_cont = candles.Content.ReadAsStringAsync().Result; Console.WriteLine(candle_cont); ``` 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 Futures and Options Contract List(Query Based on Conditions) ```text intraday/products/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | -------------------------------------------------------------------------------------------------- | | `type`\* | string | Type,valid in `FUTURE` ; `OPTION` | | `exchange` | string | Exchange Type,valid in `TAIFEX` | | `session` | string | Tradeing Session,valid in `REGULAR` 、 `AFTERHOURS` | | `contractType` | string | Contract Type,valid in `I` index;`R` rate;`B` bond;`C` commodity;`S` stock;`E` exchange rate | | `status` | string | Contract Status,valid in `N` normal;`P` pause;`U` upcoming | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | ------------------------------------------------- | | `type`\* | string | Type | | `exchange` | string | Exchange Tyep | | `session` | string | Trading Session | | `contractType` | string | Contract Type | | `status` | string | Contract Status | | `data` | object\[] | Contract List | | >> `symbol` | string | Contract Symbol | | >> `type` | string | Contract type | | >> `name` | string | Symbol name | | >> `underlyingSymbol` | string | Unerlying Symbol | | >> `contractType` | string | Contract Type | | >> `contractSize` | string | Contract Size | | >> `statusCode` | string | Status Code | | >> `tradingCurrency` | string | Trading Currency | | >> `quoteAcceptable` | boolean | Provide Quote Flag | | >> `startDate` | string | Beginning Date | | >> `canBlockTrade` | boolean | Support Block Trade Flag | | >> `expiryType` | string | Expiry Type,`S` standard;`W` week | | >> `underlyingType` | string | Underlying Type,`E` ETF;`S` stock | | >> `marketCloseGroup` | string | Closing Time Group | | >> `endSession` | string | Last Trading Deadline `0` regular;`1` afterhours | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") sdk.init_realtime() restfut = sdk.marketdata.rest_client.futopt # restfut.intraday.products(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfut.intraday.products(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.products({ type: 'FUTURE', exchange:'TAIFEX', session:'REGULAR', contractType:'E'}) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var contracts = await rest.Intraday.Products(FutOptType.Future, new(){ Exchange=FutOptExchangeType.TaiFex, Session=SessionType.AfterHours, ContractType=ContractType.E }); var contracts_cont = contracts.Content.ReadAsStringAsync().Result; Console.WriteLine(contracts_cont); ``` 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 Real-time quotes (query by contract symbol) ```text intraday/quote/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------- | | `symbol`\* | string | Contract Symbol | | `session` | string | Trading Session,valid in `afterhours` overnight market | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | ------ | --------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Type | | `exchange` | string | Exchange | | `symbol` | string | Contract Code | | `name` | string | Contract Name | | `previousClose` | number | The closing price of the previous trading day | | `openPrice` | number | Opening Price | | `openTime` | number | Opening price transaction time | | `highPrice` | number | Highest Trading Price | | `highTime` | number | Highest Trading Price transaction time | | `lowPrice` | number | Lowest Trading Price | | `lowTime` | number | Lowest Trading Price transaction time | | `closePrice` | number | Close Price | | `closeTime` | number | Close Price transaction time | | `avgPrice` | number | Trading Average Price Today | | `change` | number | Last Trading Price Change | | `changePercent` | number | Last Trading price Change Percentage | | `amplitude` | number | Price Range Today | | `lastPrice` | number | Last Price(include trial) | | `lastSize` | number | Last Trading Volume(include trial) | | `total` | object | List | | >> `tradeVolume` | number | Accumulative Trading Volume | | >> `totalBidMatch` | number | Total Bid Order Count | | >> `totalAskMatch` | number | Total Ask Order Count | | `lastTrade` | object | List | | >> `bid` | number | Last Trading Bid | | >> `ask` | number | Last Trading Ask | | >> `price` | number | Last Trading Price | | >> `size` | number | Last Trading Volume | | >> `time` | number | Last Trading Time | | >> `serial` | number | Last Trading Serial Number | | `serial` | number | Serial Number | | `lastUpdated` | number | Last Updated Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") sdk.init_realtime() restfut = sdk.marketdata.rest_client.futopt # restfut.intraday.quote(symbol='TXFA4') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfut.intraday.quote(symbol='TXFA4') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.quote({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var quote = await rest.Intraday.Quote("TXFA4"); // var quote = await rest.Intraday.Quote("TXFA4", new(){Session=FugleMarketData.QueryModels.FuOpt.TradeSession.AfterHours}); // After hours var quote_cont = quote.Content.ReadAsStringAsync().Result; Console.WriteLine(quote_cont); ``` 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": { "bid": 17459, "ask": 17460, "price": 17460, "size": 1, "time": 1702359886936000, "serial": "00165753" }, "serial": 165753, "lastUpdated": 1702359886936000 } ``` --- ### Intraday Ticker Futures and Options product information(Query base on symbol) ```text intraday/ticker/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ------------------------------------------------------- | | `symbol`\* | string | Contract Symbol | | `session` | string | Trading Session,valid in `afterhours` overnight market | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------- | ------ | ------------------ | | `date`\* | string | Date | | `type`\* | string | Type | | `exchange` | string | Exchange | | `symbol` | string | Contract Code | | `name` | string | Contract Name | | `referencePrice` | string | Reference Price | | `settlementDate` | string | Settlement Date | | `startDate` | string | Start Trading Date | | `endDate` | string | Last Trading Date | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") sdk.init_realtime() restfut = sdk.marketdata.rest_client.futopt # restfut.intraday.ticker(symbol='TXFI4') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfut.intraday.ticker(symbol='TXFI4') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.tickers({ symbol:'TXFI4'}) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var contracts = await rest.Intraday.Ticker("TXFI4", new(){ Session=TradeSession.AfterHours }); var contracts_cont = contracts.Content.ReadAsStringAsync().Result; Console.WriteLine(contracts_cont); ``` 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 Futures and Options product list(Query base on condition) ```text intraday/tickers/ ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | -------------------------------------------------------------------------------------------------- | | `type`\* | string | Type,valid in `FUTURE` ; `OPTION` | | `exchange` | string | Exchange,valid in `TAIFEX` | | `session` | string | Trading Session,valid in `REGULAR` or `AFTERHOURS` | | `product` | string | Contract Code | | `contractType` | string | Contract Type,valid in `I` index;`R` rate;`B` bond;`C` commodity;`S` stock;`E` exchange rate | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | --------- | --------------------- | | `date`\* | string | Date | | `type`\* | string | Type | | `exchange` | string | Exchange | | `session` | string | Trading Session | | `contractType` | string | Contract Type | | `data` | object\[] | Data List | | >> `type` | string | Type | | >> `symbol` | string | Contract Code | | >> `name` | string | Contract Name | | >> `referencePrice` | string | Reference Price | | >> `contractType` | string | Contract Type | | >> `startDate` | string | Start Trading Date | | >> `endDate` | string | Last Trading Date | | >> `flowGroup` | string | Contract Flow Group | | >> `settlementDate` | string | Settlement Date | | >> `isDynamicBanding` | boolean | Dynamic Price Banding | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" , "Your cert path", "Your cert password") sdk.init_realtime() restfut = sdk.marketdata.rest_client.futopt # restfut.intraday.tickers(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfut.intraday.tickers(type='FUTURE', exchange='TAIFEX',session='REGULAR', contractType='E') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.tickers({ type: 'FUTURE', exchange:'TAIFEX', session:'REGULAR', contractType:'E'}) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var contracts = await rest.Intraday.Tickers(FutOptType.Future, new(){ Exchange=FutOptExchangeType.TaiFex, Session=SessionType.AfterHours, ContractType=ContractType.E }); var contracts_cont = contracts.Content.ReadAsStringAsync().Result; Console.WriteLine(contracts_cont); ``` 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 Contract trade details (query by contract code). ```text intraday/trades/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ----------------------------------- | | `symbol`\* | string | Contract Symbol | | `session` | string | Session Type,valid in `afterhours` | | `offset` | number | Offset | | `limit` | number | Limit | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | -------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Contract Code | | `data`\* | object\[] | list | | >> `bid` | number | Trading Bid Price | | >> `ask` | number | Trading Ask Price | | >> `price` | number | Trading Price | | >> `size` | number | Trading Volume | | >> `volume` | number | Trading Total Volume | | >> `time` | number | Trading Time | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") # sdk.init_realtime() restfutopt = sdk.marketdata.rest_client.futopt # restfutopt.intraday.trades(symbol='TXFA4') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfutopt.intraday.trades(symbol='TXFA4') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.trades({ symbol: 'TXFA4' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var trade = await rest.Intraday.Trades("TXFA4"); // var trade = await rest.Intraday.Trades("TXFA4", new(){Session=FugleMarketData.QueryModels.FuOpt.TradeSession.AfterHours}); // After hours var trade_cont = trade.Content.ReadAsStringAsync().Result; Console.WriteLine(trade_cont); ``` 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 Futures and Options price-volume data(query by symbol) ```text intraday/volumes/{symbol} ``` #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | ---------- | ------ | ---------------------------------------------- | | `symbol`\* | string | Contract Symbol | | `session` | string | Trading Sessiom,valid in `afterhours` odd-lot | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ---------------- | --------- | --------------------------------- | | `date`\* | string | Date | | `type`\* | string | Ticker type | | `exchange`\* | string | Exahange | | `market` | string | Market Type | | `symbol`\* | string | Stock Number | | `data` | object\[] | list | | >> `price` | number | Trading Price | | >> `volume` | number | Accumulative Volume on this Price | | >> `volumeAtBid` | number | Accumulative Bid Volume | | >> `volumeAtAsk` | number | Accumulative Ask Volume | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() restfutopt = sdk.marketdata.rest_client.futopt # restfutopt.intraday.volumes(symbol='TXFC4') # Version 2.2.3 and before ## Aftrer version 2.2.4 (use Exception for exception handling) from fubon_neo.fugle_marketdata.rest.base_rest import FugleAPIError try: restfutopt.intraday.volumes(symbol='TXFC4') except FugleAPIError as e: print(f"Error: {e}") print("------------") print(f"Status Code: {e.status_code}") # Ex: 429 print(f"Response Text: {e.response_text}") # Ex: {"statusCode":429,"message":"Rate limit exceeded"} ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.initRealtime(); const client = sdk.marketdata.restClient client.futopt.intraday.volumes({ symbol: 'TXFC4' }) .then(data => console.log(data)); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.QueryModels.FuOpt; using FugleMarketData.QueryModels.FuOpt.Intraday; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); sdk.InitRealtime(); var rest = sdk.MarketData.RestClient.FutureOption; var volume = await rest.Intraday.Volumes("TXFC4"); // var volume = await rest.Intraday.Volumes("TXFA4", new(){Session=FugleMarketData.QueryModels.FuOpt.TradeSession.AfterHours}); // After hours var volume_cont = volume.Content.ReadAsStringAsync().Result; Console.WriteLine(volume_cont); ``` Response Body: ```json { "date": "2024-01-18", "type": "FUTURE", "exchange": "TAIFEX", "symbol": "TXFC4", "data": [ { "price": 17316, "volume": 12 }, { "price": 17315, "volume": 12 }, { "price": 17314, "volume": 12 }, { "price": 17313, "volume": 8 }, { "price": 17312, "volume": 4 }, { "price": 17311, "volume": 4 }, { "price": 17310, "volume": 16 }, { "price": 17309, "volume": 4 }, { "price": 17307, "volume": 12 }, { "price": 17306, "volume": 4 }, { "price": 17305, "volume": 20 }, { "price": 17304, "volume": 20 }, { "price": 17303, "volume": 12 }, ...... ] } ``` --- ### Fubon Neo API Futures Market Data Key takeaways * Fubon Neo API Futures Market Data provides real-time futures data for Taiwan. * Interfaces include Web API and WebSocket API. * Data sources are official exchanges and vendors; please follow usage regulations. * Next step: [Web API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/getting-started.md) or [WebSocket API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md). | Item | Details | | ------------ | ------------------------ | | Service | Futures Market Data | | Markets | Taiwan futures / options | | Interfaces | Web API / WebSocket API | | Data sources | TWSE, TPEx, TAIFEX | The real-time market data source includes the Taiwan Stock Exchange (TWSE), and the Taiwan Futures Exchange.
Please refer to the relevant [regulations and statements](#statement) for more information. #### Web API[​](#web-api "Direct link to Web API") Fubon Futures Market Data [Web API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/http-api/getting-started.md) provides developer-friendly services. You can access intraday futures data for Taiwan. Data sources are Infotimes and Fugle. #### WebSocket API[​](#websocket-api "Direct link to WebSocket API") Fubon Futures Market Data [WebSocket API](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md) provides real-time futures market data for Taiwan. Use the WebSocket API to receive real-time data. #### Usage regulations and statements[​](#statement "Direct link to Usage regulations and statements") * The market data obtained through this service is for reference only. It does not include odd-lot or block trades in the transaction value and volume. Users are responsible for any trading losses incurred based on this data。 * Fubon is not responsible for data content errors, delays in updates, or transmission interruptions. You are solely responsible for any financial or investment decisions you make。 * Users are required to follow the [Regulations on the Use of Trading Information of Taiwan Stock Exchange Corporation](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10809760\&releaseDate=2021-12-24&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQSkUGuPSgl5XdBmvh4pfksZDSCPO97cowzuq2kozOK-jcEsrQLo0zV7piJ2v-0_Iu0T59qkMYtXhtWTHqd_tx99cczJ-iz2jNYx0wjaCIZTYDYTsJtarx1wUtmCH2y7hZs)、[Regulations on the Use of Trading Information of Taiwan Futures Exchange Corporation](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10815483\&releaseDate=2020-02-13&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQRBdJkoAtEZZLAng4diPK7D2b226xLMNWc93GlTy5KWHc25EhHhnPDU9iJRdDvbu7cldj7dJMTv9vZoFF4brLW6KY3MFCc-KIzRZueu2MFWP01PaDehsVdaM0YPBB_ZJGI)、[Regulations on the Use of Trading Information of the Taiwan Securities Association](https://www.selaw.com.tw/English/LawArticle?sysNumber=LW10813063\&releaseDate=2024-01-23&__RequestVerificationToken=CfDJ8AGrSuSD6ZtEvZ_SapDxtQQis8j2jnRvWRu6TJnh7JHmOGCfonv9gz0Q6ez38d3M_-Em3KcMbA7v6qUbziRLV83yyombkIWengQFc1Bgtz23kCC-y2GvB5YVrS2h4b1v5c8JSKvjZsEkwSQKCPI3SmQ)、Users are required to comply with the information usage regulations established by each information source provider, as well as relevant intellectual property laws. All information is subject to the data officially announced by each information source provider. Any unauthorized interception, retransmission of trading information, or any other form of selling, renting, transferring, or re-authorizing trading information, or resampling trading information to create indices, other derivative products, or transmitting it to third parties may result in legal consequences, including civil and criminal liability for breach of contract and infringement。 * Fubon Neo API Futures Market Data is developed and provided by the [Fugle](https://www.fugle.tw/) technology team。 --- ### Establish Connections ##### Establish Market Data Connections[​](#establish-market-data-connections "Direct link to Establish Market Data Connections") The following example demonstrates how to establish five WebSocket connections for market data simultaneously. info Typically, multiple simultaneous connections are only needed when using WebSocket. For Web API, it is recommended to use a single connection for easier management. Web API rate limits are shared across all connections; each WebSocket connection can subscribe to up to 200 targets. * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password" ,"Your cert path" ,"Your cert password") # Login is required to obtain market data permissions websockets = [] # List of WebSocket interfaces for different connections for _ in range(5): # Create 5 connections sdk.init_realtime() # Start a market data connection #ws = sdk.marketdata.websocket_client.stock # WebSocket interface (Stocks) ws = sdk.marketdata.websocket_client.futopt # WebSocket interface (Futures/Options) # Add the interface to the available list websockets.append(ws) # Set WebSocket callbacks and open connections for ws in websockets: ## Callback functions need to be defined separately ## ws.on('message', handle_message) # Register market data callback ws.on("connect", handle_connect) # Register connection event callback ws.on("disconnect", handle_disconnect) # Register disconnection event callback ws.on("error", handle_error) # Register error event callback ws.connect() # Activate the connection # Disconnect connections # for ws in websockets: # we.disconnect() ``` ```js const { FubonSDK } = require('fubon-neo'); // Login is required to obtain market data permissions const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); const websockets = []; // List of WebSocket interfaces for different connections // Create 5 market data connections for (let i = 0; i < 5; i++) { // Start a market data connection sdk.initRealtime(); // Get WebSocket interface //const ws = sdk.marketdata.webSocketClient.stock; // (Stocks) const ws = sdk.marketdata.webSocketClient.futopt; // (Futures/Options) // Add the interface to the available list websockets.push(ws); } // Set WebSocket callbacks and open connections for (const ws of websockets) { /* -- Callback functions need to be defined separately -- */ ws.on('message', handle_message); // Register market data callback ws.on('connect', handle_connect); // Register connection event callback ws.on('disconnect', handle_disconnect); // Register disconnection event callback ws.on('error', handle_error); // Register error event callback // Activate the connection (async () => { await ws.connect(); })() } // Disconnect connections //for (const ws of websockets) { // (async () => { // await ws.disconnect(); // })() //} ``` ```cs using FubonNeo.Sdk; // Login is required to obtain market data permissions var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password", "Your Cert Path", "Your Cert Password"); // List of WebSocket interfaces for different connections //var websockets = new List(); // (Stocks) var websockets = new List(); // (Futures/Options) // Create 5 market data connections for (int i = 0; i < 5; i++) { sdk.InitRealtime(); // Start a market data connection // Get WebSocket interface //var ws = sdk.MarketData.WebSocketClient.Stock; // (Stocks) var ws = sdk.MarketData.WebSocketClient.FutureOption; // (Futures/Options) // Add the interface to the available list websockets.Add(ws); } // Set WebSocket callbacks and open connections foreach (var ws in websockets) { ws.OnMessage = (msg) => Console.WriteLine($"OnMessage receive: {msg}"); // Register market data callback ws.OnError = (msg) => Console.WriteLine($"OnError receive: {msg}"); // Register error event callback ws.OnConnected = (msg) => Console.WriteLine($"OnConnected receive: {msg}"); // Register connection event callback ws.OnDisconnected = (msg) => Console.WriteLine($"OnDisconnected receive: {msg}"); // Register disconnection event callback // Activate the connection await ws.Connect(); } // Disconnect connections // foreach (var ws in websockets) // { // await ws.Disconnect(); // } ``` --- ### Rate Limit ##### Rate Limit[​](#rate-limit "Direct link to Rate Limit") Key takeaways * This page lists Web API and WebSocket rate limits for Fubon Neo API Futures Market Data. * Exceeding limits returns `429` or WebSocket subscription errors. * Rapid connection bursts may be blocked. | Item | Limit | | ---------- | -------------------------------- | | Intraday | 300 / min | | Snapshot | 300 / min | | Historical | 60 / min | | WebSocket | 200 subscriptions; 5 connections | Fubon Neo API Futures Market Data provides Web API and WebSocket with the following access restrictions. * Intraday : 300 / min * WebSocket : 200 Subscription;5 Connection * Snapshot : 300 / min * Historical : 60 / min If your API requests exceed the limit, you will receive a response with status code `429`. Please wait for 1 minute before making additional requests. ```json {"statusCode":429,"message":"Rate limit exceeded"} ``` If your WebSocket subscriptions exceed the upper limit, you will receive the following message:" ```json { "event": "error", "data": { "code": 1001, "message": "Maximum number of connections reached" } } ``` caution If a large number of Socket connections are established within a short period, the system will consider it a malicious attack and block your connection requests (404 Not Found error). If you encounter this situation, please contact . --- ### Quick Start Key takeaways * Fubon Futures Market Data WebSocket API provides real-time futures subscriptions. * Supports `Speed` and `Normal` modes. * Login is required before subscribing to channels. | Item | Details | | ------------ | ---------------------------------- | | Interface | WebSocket API | | Market | Taiwan futures / options | | Modes | Speed / Normal | | SDK | Python / Node.js / C# | | Subscription | Connect then subscribe to channels | Fubon Futures Market Data WebSocket API provides real-time futures market data for Taiwan. #### Using SDK[​](#using-sdk "Direct link to Using SDK") Fubon Futures Market Data WebSocket API provides Python, Node.js, and C# SDKs. You can access the WebSocket API through the following methods: And subscribe webSocket callback method to receive the callback messages below. info WebSocket api provides Low Latency `Speed` Mode and Multi-Information `Normal` Mode. * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Mode def handle_message(message): print(message) sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() # Offer MarketData Mode , Default : Speed # sdk.init_realtime(Mode.Speed) or sdk.init_realtime(Mode.Normal) futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); // Offer MarketData Mode , Default : Speed // sdk.initRealtime(Mode.Speed) or sdk.initRealtime(Mode.Normal) const futopt = sdk.marketdata.webSocketClient.futopt; futopt.connect() futopt.on("message", (message) => { const data = JSON.parse(message); console.log(data); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); // Offer MarketData Mode , Default : Speed // sdk.InitRealtime(Mode.Speed) or sdk.InitRealtime(Mode.Normal) var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: {msg}"); await futopt.Connect(); ``` #### Authenticated[​](#authenticated "Direct link to Authenticated") When the verification is successful, you will receive the following message: ```json { "event": "authenticated", "data": { "message": "Authenticated successfully" } } ``` When the verification is failed, you will receive the following message: ```json { "event": "error", "data": { "message": "Invalid authentication credentials" } } ``` #### Heartbeat[​](#heartbeat "Direct link to Heartbeat") Every 30 seconds, the WebSocket server will send out a heartbeat message: ```json { "event": "heartbeat", "data": { "time": "" } } ``` #### Ping/Pong[​](#pingpong "Direct link to Ping/Pong") Every 30 seconds, sdk will send the following JSON-formatted message to the WebSocket Server, or follow the below example (where state is optional): * Python * Node.js * C# ```python futopt.ping({ 'state' : '' }) ``` ```js futopt.ping({state:''}); ``` ```cs futopt.ping(""); ``` The WebSocket Server will respond with the following message (if ping was sent, the state field will not be present): ```json { "event": "pong", "data": { "time": "", "state": "" } } ``` #### Channels[​](#channels "Direct link to Channels") The Fubon Futures Market Data WebSocket API currently provides the following subscribable channels: * `trades` - [Subscribe to the latest future trade information](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/market-data-channels/trades.md) * `books` - [Subscribe to the latest top five bid and ask information for stocks](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/market-data-channels/books.md) ##### Subscribe Channel[​](#subscribe-channel "Direct link to Subscribe Channel") Subscribe to a channel, send following example to the WebSocket Server: * Python * Node.js * C# ```python futopt.subscribe({ "channel" : "", "symbol" : "" #"afterHours" : True Subscribe after-hours }) ``` ```js futopt.subscribe({ channel: '', symbol: '', //afterHours : true Subscribe after-hours }); ``` ```cs futopt.Subscribe(FutureOptionChannel.,""); //futopt.Subscribe(FutureOptionChannel.Trades,new FutureOptionParams{Symbol="", AfterHours = true}); Subscribe after-hours ``` After a successful subscription, you will receive the following event response: ```json { "event": "subscribed", "data": { "id": "", "channel": "", "symbol": "" } } ``` Supports the subscription of multiple stocks within the same channel: * Python * Node.js * C# ```python futopt.subscribe({ "channel" : "", "symbols" : ["",""] #"afterHours" : True Subscribe after-hours }) ``` ```js futopt.subscribe({ channel: '', symbols: ['',''] //afterHours : true Subscribe after-hours }); ``` ```cs futopt.Subscribe(FutureOptionChannel.,"",""); //futopt.Subscribe(FutureOptionChannel.Trades, new FutureOptionParams{Symbols = new List{"", ""}, AfterHours = true}); Subscribe after-hours ``` After a successful subscription, you will receive the following event response: ```json { "event": "subscribed", "data": [ { "id": "", "channel": "", "symbol": "" }, { "id": "", "channel": "", "symbol": "" } ] } ``` ##### Unsubscribe[​](#unsubscribe "Direct link to Unsubscribe") Unsubscribe from a subscribed channel, please send the following example to WebSocket Server: * Python * Node.js * C# ```python futopt.unsubscribe({ 'id':'' }) ``` ```js futopt.unsubscribe({ id : '' }); ``` ```cs futopt.Unsubscribe(""); ``` After a successful unsubscription, you will receive the following event response: ```json { "event": "unsubscribed", "data": { "id": "", "channel" : "", "symbol" : "" } } ``` Supports the unsubscription from multiple channels: * Python * Node.js * C# ```python futopt.unsubscribe({ 'ids':['',''] }) ``` ```js futopt.unsubscribe({ ids : ['',''] }); ``` ```cs futopt.Unsubscribe("",""); ``` After a successful unsubscription, you will receive the following event response: ```json { "event": "unsubscribed", "data": [ { "id": "", "channel" : "", "symbol" : "" }, { "id": "", "channel" : "", "symbol" : "" } ] } ``` #### Error Handle[​](#error-handle "Direct link to Error Handle") When there is an anomaly in the WebSocket callback you subscribed to or processed, you can handle error messages as follows: * Python * Node.js * C# ```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); }); ``` ```cs futopt.OnError += (errmsg) => Console.WriteLine($"handle error: {errmsg}"); futopt.OnConnected += (connmsg) => Console.WriteLine($"Connect: {connmsg}"); futopt.OnDisconnected += (disconmsg) => Console.WriteLine($"Disconnect: {disconmsg}"); ``` ##### Reconnection[​](#reconnection "Direct link to Reconnection") The following is a simple demonstration that automatically reconnects the websocket when a disconnection event is detected using a callback: * Python * Node.js * C# ```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 }); ``` ```cs futopt.OnDisconnected += async (msg) => { Console.WriteLine($"disconnected at {DateTime.Now}"); await Task.Delay(10); Console.WriteLine("Try Reconnected"); await futopt.Connect(); Console.WriteLine("Reconnected Success"); Console.WriteLine("Resubscribe..."); await futopt.Subscribe(FutureOptionChannel., ""); //重新訂閱您已訂閱過的Channel與Symbol Console.WriteLine("Resubscribe Success"); }; ``` --- ### Aggregates Subscribe to aggregated market data for futures or options #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------- | | `channel`\* | string | Subscribe Channel:`trades`, `candles`, `books`, `aggregates` | | `symbol`\* | string | Contract Code | | `afterHours`\* | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | --------------------- | ------ | --------------------------------------------- | | `date`\* | string | Date | | `type`\* | string | Type | | `exchange` | string | Exchange | | `symbol` | string | Contract Code | | `name` | string | Contract Name | | `previousClose` | number | The closing price of the previous trading day | | `openPrice` | number | Opening Price | | `openTime` | number | Opening price transaction time | | `highPrice` | number | Highest Trading Price | | `highTime` | number | Highest Trading Price transaction time | | `lowPrice` | number | Lowest Trading Price | | `lowTime` | number | Lowest Trading Price transaction time | | `closePrice` | number | Close Price | | `closeTime` | number | Close Price transaction time | | `avgPrice` | number | Trading Average Price Today | | `change` | number | Last Trading Price Change | | `changePercent` | number | Last Trading price Change Percentage | | `amplitude` | number | Price Range Today | | `lastPrice` | number | Last Price(include trial) | | `lastSize` | number | Last Trading Volume(include trial) | | `total` | object | List | | >> `tradeVolume` | number | Accumulative Trading Volume | | >> `tradeVolumeAtBid` | number | Total Bid Order Count | | >> `tradeVolumeAtAsk` | number | Total Ask Order Count | | `lastTrade` | object | List | | >> `price` | number | Last Trading Price | | >> `size` | number | Last Trading Volume | | >> `time` | number | Last Trading Time | | >> `serial` | number | Last Trading Serial Number | | `serial` | number | Serial Number | | `lastUpdated` | number | Last Updated Time | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order, Mode def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime(Mode.Normal) # Establish market-data futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'aggregates', 'symbol': 'TXFA4' }) ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(Mode.Normal); // Establish market-data 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(Mode.Normal); // Establish market-data var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await futopt.Connect(); await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Aggregates, "TXFA4"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest top five bid and ask information for contract #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------- | | `channel`\* | string | Channel : `trades`, `books` | | `symbol`\* | string | Contract Code | | `afterHours`\* | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------ | --------- | ---------------- | | `symbol`\* | string | Contract Code | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Typ | | `time`\* | number | Time | | `bids` | object\[] | Top 5 bid | | >> `price` | number | Top 5 bid price | | >> `size` | number | Top 5 bid volume | | `asks` | object\[] | Top 5 ask | | >> `price` | number | Top 5 ask price | | >> `size` | number | Top 5 ask volume | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'books', 'symbol': 'TXFA4 #'afterHours' : True }) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); 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); }); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await futopt.Connect(); await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Books, "TXFA4"); // await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Books, new FutureOptionParams { Symbol = "TXFC4", AfterHours = true }); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest minute K-line data for contract #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------- | | `channel`\* | string | Channel:`trades`, `candles`, `books`, `aggregates` | | `symbol`\* | string | Contract code | | `afterHours`\* | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------- | ------ | --------------- | | `date`\* | string | Date | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `symbol`\* | string | Contract Code | | `timeframe`\* | number | KLine Timeframe | | `open`\* | number | Open Price | | `high`\* | number | Highest Price | | `low`\* | number | Lowest Price | | `close`\* | number | Close Price | | `volume`\* | number | Volume | | `average`\* | number | Average Price | #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order, Mode def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime(Mode.Normal) futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'candles', 'symbol': 'TXFA4' }) ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path","Your cert password"); sdk.initRealtime(Mode.Normal); // 建立行情連線 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(Mode.Normal); // 建立行情連線 var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await futopt.Connect(); await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Candles, "TXFA4"); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md#subscribe-channel) ##### 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 Subscribe to the latest contract trade information #### Parameters[​](#parameters "Direct link to Parameters") | Name | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------- | | `channel`\* | string | Channel:`trades`, `books` | | `symbol`\* | string | Contract code | | `afterHours`\* | bool | Subscription AfterHours Session true : AfterHours false : Regular default : false | #### Response[​](#response "Direct link to Response") | Name | Type | Description | | ------------------ | ------ | --------------------- | | `symbol`\* | string | Contract code | | `type`\* | string | Ticker Type | | `exchange`\* | string | Exchange | | `market` | string | Market Type | | `trades` | object | List | | >> `price` | number | Trading Price | | >> `size` | number | Trading Volume | | >> `bid` | number | Bid Price | | >> `ask` | number | Ask Price | | `total` | object | List | | >> `tradeVolume` | number | Total Trading Volume | | >> `totalBidMatch` | number | Total Bid Order Count | | >> `totalAskMatch` | number | Total Ask Order Count | | `time`\* | number | Time | | `serial`\* | number | Serial Number | info '\*' Indicates mandatory disclosure fields. #### Example[​](#example "Direct link to Example") ##### Subscribe channel[​](#subscribe-channel "Direct link to Subscribe channel") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order def handle_message(message): print(f'market data message: {message}') sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password") sdk.init_realtime() futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() futopt.subscribe({ 'channel': 'trades', 'symbol': 'TXFA4' #'afterHours' : True }) ``` ```js const { FubonSDK } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.initRealtime(); 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); }); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your password", "Your cert path", "Your cert password"); sdk.InitRealtime(); var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await futopt.Connect(); await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Trades, "TXFA4"); // await futopt.Subscribe(FugleMarketData.WebsocketModels.FutureOptionChannel.Trades, new FutureOptionParams { Symbol = "TXFC4", AfterHours = true }); ``` Multiple Products The command to subscribe multiple products at once, please refer to [Subscribe Channel](https://www.fbs.com.tw/TradeAPI/en/docs/market-data-future/websocket-api/getting-started.md#subscribe-channel) ##### 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" } ``` --- ### Mode Switching **Applies to versions >= 1.3.1** #### Marketdata WebScoket Mode Switching[​](#marketdata-webscoket-mode-switching "Direct link to Marketdata WebScoket Mode Switching") The new versions provide switching between Low Latency Market Data and Multi-Information Socket Market Data. ##### Import function (Required for Python and NodeJs.)[​](#import-function-required-for-python-and-nodejs "Direct link to Import function (Required for Python and NodeJs.)") * Python * Node.js ```py # Import Mode function from fubon_neo.sdk import FubonSDK, Mode ``` ```js const { FubonSDK, Mode } = require('fubon-neo'); ``` Specify the mode when obtaining market data permissions. * Python * Node.js * C# ```python sdk.init_realtime(Mode.Speed) # Provide Speed / Normal (default : Speed) # sdk.init_realtime(Mode.Speed) or sdk.init_realtime(Mode.Normal) futopt = sdk.marketdata.websocket_client.futopt futopt.on('message', handle_message) futopt.connect() ``` ```js sdk.initRealtime(Mode.Speed); // Provide Speed / Normal (default : Speed) //sdk.initRealtime(Mode.Speed); or sdk.initRealtime(Mode.Normal); 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); }); ``` ```cs using FubonNeo.Sdk; using FugleMarketData.WebsocketModels; // Adding "Mode" sdk.InitRealtime(Mode.Speed); // Provide Speed / Normal (default : Speed) // sdk.InitRealtime(Mode.Speed); or sdk.InitRealtime(Mode.Normal); var futopt = sdk.MarketData.WebSocketClient.FutureOption; futopt.OnMessage += (msg) => Console.WriteLine($"receive: { msg }"); await futopt.Connect(); ``` --- ### TP & SL Condition Fubon Neo API supports TP & SL orders. Take-Profit and Stop-Loss Mechanism: Once a triggered condition order is executed, the stop-loss and take-profit monitoring mechanism will be activated. When the take-profit condition is met, the stop-loss will be deactivated; conversely, if the stop-loss condition is met, the take-profit will be deactivated (similar to the commonly known OCO mechanism). ![TPSL](/TradeAPI/en/assets/images/TPSL-c929bfde158264f3327c48f316c32bde.png) #### Request Example[​](#request-example "Direct link to Request Example") * Python * Node.js * C# ```py # 設計條件內容 condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "66", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock, ) # 停損停利若為Market , price 則填空值"" tp = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="85", price="85", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) sl = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="60", price="60", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) tpsl = TPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517", # optional field intraday =False # optional field ) sdk.stock.single_condition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` ```js // 設計條件內容 const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; // 停損停利若為Market , price 則填空值"" const tp = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, targetPrice: "85", price: "85", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const sl = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, targetPrice: "60", price: "60", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517", // optional field intraday: false // optional field } sdk.stock.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` ```cs // 設計條件內容 var condition = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); // 停損停利若為Market , price 則填空值"" var tp = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "85", "85", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var sl = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "60", "60", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var tpsl = new TpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.Stock.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` --- ### Trail Profit Condition Fubon Neo API supports trail profit orders. Trailing Profit Mechanism: After the initial condition is triggered, the order will not be activated if the set pullback range is not reached. As the stock price continues to rise, the new price will be used as the benchmark. If the pullback range reaches the set value at this point, the order will be submitted. ![trailProfit](/TradeAPI/en/assets/images/TrailProfit-57d72c840dd40176b183a22ef955bfdc.png) ##### Request Example[​](#request-example "Direct link to Request Example") * Python * Node.js * C# ```py # 設計條件內容 trail = TrailOrder( symbol = "2330", price = "1000", direction = Direction.Down , percentage = 5, # 漲跌 % 數 buy_sell = BSAction.Sell, quantity = 2000, price_type = ConditionPriceType.MatchedPrice, diff = 1, # 向上 or 向下追買 tick數 (向下為負值) time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) sdk.stock.trail_profit(target_account, "20240427","20240516", StopSign.Full, trail) ``` ```js // 設計條件內容 const trail = { symbol: "2330", price: "1000", direction: Direction.Down, percentage: 5, buySell: BSAction.Sell, quantity: 2000, priceType: ConditionPriceType.MatchedPrice, diff: 1, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; sdk.stock.trailProfit(target_account, "20240427","20240516", StopSign.Full, trail) ``` ```cs // 設計條件內容 var trail = new TrailOrder( "2330", "1000", Direction.Down , 5, // 漲跌 % 數 BsAction.Sell, 2000, ConditionPriceType.MatchedPrice, 1, // 向上 or 向下追買 tick數 (向下為負值) TimeInForce.Rod, ConditionOrderType.Stock ); sdk.Stock.TrailProfit(target_account, "20240427","20240516", StopSign.Full, trail); ``` --- ### 條件單使用說明 本公司為服務投資人,提供網路下單客戶得預先設定下單條件之條件下單功能服務(以下簡稱本功能或本服務)。本服務不收取任何費用,但本公司保留得隨時調整、修正、暫停或終止此項服務之權利;為確保使用者權益及網路交易安全秩序,請投資人於啟用本功能前,詳細閱讀以下條款,以保障投資人的權利,在投資人點選本使用同意書下方之同意鈕,即視為已經詳閱並接受本同意書之內容。
一、條件下單功能服務具有以下(但不限於此)之風險,投資人應自承以下風險所衍生之損害或損失:
1 網際網路之傳輸通訊,可能因不可抗力或不可歸責於本公司之事由,包括(但不在此限)斷電、斷線、網路壅塞等因素,導致資料傳輸延遲、停滯、無法發出或無法接收。
2 本功能或服務有可能因病毒、系統或機件發生故障、錯誤、執行障礙,駭客入侵等因素,導致資料或資訊傳送發生遺漏、錯誤、或遭竄改。
3 其他網路交易之風險。
二、條件下單功能服務,係依據投資人設定之個股或期貨商品種類及下單條件,提供即時有效之資訊,並結合既有之網路下單功能,允許投資人在同一網頁操作證券或期貨下單之委託指示。本公司目前所提供之條件下單功能服務包括觸價下單、觸量下單、定時下單、長效停損/停利下單及多條件下單共五種(簡稱為條件下單),不同種類的條件下單,其設定方式、效力有可能不同,或受有特別限制,投資人於設定每一筆條件下單前應詳細閱讀注意事項,審慎為之。
三、經觸發條件下單功能服務「直接下單」功能鍵後,具有與口頭、電話、傳真、網路下單相同之效力,如經成交即不得取消,投資人負有交割義務,以及證券、期貨相關法令所規定之各項責任。
四、投資人得於成交前以網路或電話方式變更或取消委託,投資人於下單前應充分瞭解有關變更或取消委託之操作。因不可抗力或不可歸責於本公司之事由,包括(但不在此限)斷電、斷線、網路壅塞、傳輸干擾等因素,致變更或取消意思表示無法即時送達之風險,由投資人自行負擔。
五、基於網路維運、符合資訊法規及網路規範、確保網路交易安全,或服從主管機關之命令等因素,對於有礙系統正常運作、或可能造成系統資訊不穩定、或其他異常狀況之條件下單,本公司保留刪除之權利。如經決定刪除,本公司將另以電子平台公告、行動簡訊或電子郵件通知投資人,並請投資人至富邦證券網站、HTS快易點、HTS2多易點及Online查詢條件下單訊息公告。
六、經公告於本公司網站上之其他有關電子下單、客戶資料使用、網站管理、保密措施等規範,於條件下單功能服務均有其適用。如有未盡事宜,悉照中華民國相關法令以及經公告之網際網路交易規範為準據。
七、請投資人依本公司條件下單之下單規則,於完成有效期間條件下單之設定後, 請於該條件下單之有效期間內之每一營業日當日查詢該條件下單狀態;條件下單之詳細狀態僅保留至當日,若投資人對條件下單狀態有疑慮,請於該筆交易當日洽詢所屬分公司營業同仁。如交易當日條件下單有故障或因不可抗力因素導致系統無法送單情形,則該交易視為未下單處理。
注意事項: 1. 如使用條件單訂閱功能,請務必確認各項訂閱條件內容,避免產生錯誤。另提醒投資人,此為訂閱功能,待條件符合,才會觸發下單,如欲查詢訂閱狀況可至富邦Online/HTS2多易點/HTS快易點。 2. 就前述訂閱功能,投資人可設定條件單觸發後,系統以e-mail發送觸發通知給投資人,或直接下單。如不熟悉條件單操作流程,建議設定觸發通知,待熟悉後再選擇直接下單。 3. 如使用定時單下最後一盤,建議設定停盤丟單,因條件單主機與交易所主機不同,雖然固定每3分鐘進行1次網路校時,但難免出現秒差(如設定13:25下單,可能會下在13:24:59),請留意。 4. 條件單接受比對A商品下B商品,設定A商品時會自動帶委託A商品,要委託B商品請手動調整。 5. 當投資人設定之行情條件觸發且本系統送出投資人設定之委託單後,本公司會將該委託單送至交易所,該委託單將會轉為一般委託,此時無法取消訂閱該筆條件單,請直接使用下單查詢功能,查找觸發後的一般委託進行改單調整。 6. 條件單訂閱冷門商品,有可能會碰到開盤沒報價或價格穩定措施3分鐘無行情,這時條件單會進入等價狀況,待有行情才會開始繼續洗價比對。 7. 請留意,使用條件單訂閱功能時,待觸發送單後才會與本公司後台風控進行比對。 8. 請留意,證期權多條件長效單、移動鎖利條件單、庫存停損利條件單之效期最長為3個月,定時定額條件單效期最長為6個月。 9. 其餘未盡事宜請參閱各條件單介面下方注意事項,確認閱讀內容完畢後始得訂閱條件單。 --- ### Fubon Neo API Condition Order *** Key takeaways * Overview of Fubon Neo API condition orders. * Supports multiple order types for automated strategies and risk control. * Next step: [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/prepare.md). | Item | Details | | ------------ | ------------------------------------------------------------------------------------------------------- | | Product | Fubon Neo API Condition Orders | | Functions | Trigger, TP/SL, time-slice | | Platforms | Windows / macOS / Linux | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Prerequisite | Agreement signature required | #### Overview[​](#overview "Direct link to Overview") Fubon Neo API provides comprehensive trading and market APIs for your programmatic trading needs, catering to every developer's quantitative and automated trading requirements. Our API allows users to freely choose from mainstream programming languages (Python, C#, JavaScript) and easily access the API during the process of creating programmatic trades, utilizing trading and market services. #### Features[​](#features "Direct link to Features") Cross-platform support: Fubon Neo API supports Windows, MacOS, and Linux.
It also supports mainstream languages like Python, C#, and JavaScript. Stable technical architecture for direct connectivity to exchanges. Customizable market data solutions. #### Key Functions[​](#key-functions "Direct link to Key Functions") Direct trade management: Create MIT (market-if-touched) orders , TP (Take Profit)/SL (Stop Loss) order, and Time-Slice order ... etc. #### Version Support[​](#version-support "Direct link to Version Support") Python support: 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported).
Node.js Support : 16 and above.
C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. --- ### Cancel Condition Order cancel\_condition\_orders #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | guid | string | Condition Order GUID | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info CancelResult Fields[​](#order-info-cancelresult-fields "Direct link to Order Info CancelResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | ----------------------- | | advisory | string | Response Status Content | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto cancel_condition = sdk->stock->cancel_condition_orders(target_account, "564b7ad6-a332-470c-93ea-cf3fea00d7fa"); if (!cancel_condition.is_success) { std::cout << "cancel condition result failed reason: " << (cancel_condition.message.has_value() ? cancel_condition.message.value() : "No message") << std::endl; } else { if (cancel_condition.data.has_value()) { for (const auto& result : cancel_condition.data.value()) { std::cout << result << std::endl; } } else { std::cout << "cancel condition success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp Result { isSuccess = true, message = None, data = CancelResult { advisory = Success count:1, Failed count:0! } } ``` --- ### Get Day Trade Condition Order get\_condition\_daytrade\_by\_id #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | guid | string | Condition Order GUID | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | List | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_daytrade_conditionid = sdk->stock->get_condition_daytrade_by_id(target_account, "564b7ad6-a332-470c-93ea-cf3fea00d7fa"); if (!get_daytrade_conditionid.is_success) { std::cout << "get condition result failed reason: " << (get_daytrade_conditionid.message.has_value() ? get_daytrade_conditionid.message.value() : "No message") << std::endl; } else { if (get_daytrade_conditionid.data.has_value()) { for (const auto& result : get_daytrade_conditionid.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Condition result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = } } ``` --- ### Multi Condition Day Trade Order multi\_conditions\_day\_trade TPSL Notes * TPSL triggers order placement only, it does not guarantee execution. Please adjust based on market conditions. * Please ensure TPSL **Order Type** settings comply with Day Trade rules (e.g. Margin Trading offset). Day Trade Condition Order Query * Use guid to query day trade condition orders, please use ***Get Day Trade Condition Order*** function. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Monitoring Start Time | | end\_date | string | Condition Monitoring End Time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop Sign :`FULL` Until Full Execution, `PARTIAL` Until Partial Execution, `UNTIL_END` Until Expiry | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order Content | | ConditionDayTrade Object | [ConditionDayTrade Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditiondaytrade-object) | Day Trade Order Content | | TPSLObject | [TpslWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#tpslwrapper-object) | TPSL Condition | | FixSession | bool | Day Trade Cover | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionOrderResult Fields[​](#order-info-conditionorderresult-fields "Direct link to Order Info ConditionOrderResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | -------------------- | | guid | string | Condition Order GUID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Design Condition Content Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; Condition condition2 = Condition{ TradingType::REFERENCE, "2881", TriggerContent::TOTAL_QUANTITY, "1000", Operator::GREATER_THAN, }; std::vector conditions; conditions.push_back(condition); conditions.push_back(condition2); ConditionOrder order = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; ConditionDayTrade day_order = ConditionDayTrade{ "131500", // Day Trade Close Time, range 130100 ~ 132000 true, "", ConditionPriceType::MARKET }; TpslOrder tp = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "85", "85", }; TpslOrder sl = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "60", "60", }; TPSLWrapper tpsl = TPSLWrapper{ StopSign::FULL, tp, sl, "20250816", true // ** Set true to enable Day Trade wash price }; auto daytrade_condition_order = sdk->stock->multi_condition_day_trade(target_account, StopSign::FULL, "130000", conditions , order, day_order, tpsl, true); if (!daytrade_condition_order.is_success) { std::cout << "get order result failed reason: " << (daytrade_condition_order.message.has_value() ? daytrade_condition_order.message.value() : "No message") << std::endl; } else { if (daytrade_condition_order.data.has_value()) { const auto& send = daytrade_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition Day Trade Order single\_condition\_day\_trade TPSL Notes * TPSL triggers order placement only, it does not guarantee execution. Please adjust based on market conditions. * Please ensure TPSL **Order Type** settings comply with Day Trade rules (e.g. Margin Trading offset). Day Trade Condition Order Query * Use guid to query day trade condition orders, please use ***Get Day Trade Condition Order*** function. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Monitoring Start Time | | end\_date | string | Condition Monitoring End Time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop Sign :`FULL` Until Full Execution, `PARTIAL` Until Partial Execution, `UNTIL_END` Until Expiry | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order Content | | ConditionDayTrade Object | [ConditionDayTrade Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditiondaytrade-object) | Day Trade Order Content | | TPSLObject | [TpslWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#tpslwrapper-object) | TPSL Condition | | FixSession | bool | Day Trade Cover | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionOrderResult Fields[​](#order-info-conditionorderresult-fields "Direct link to Order Info ConditionOrderResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | -------------------- | | guid | string | Condition Order GUID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Design Condition Content Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; ConditionOrder order = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; ConditionDayTrade day_order = ConditionDayTrade{ "131500", // Day Trade Close Time, range 130100 ~ 132000 true, "", ConditionPriceType::MARKET }; TpslOrder tp = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "85", "85", }; TpslOrder sl = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "60", "60", }; TPSLWrapper tpsl = TPSLWrapper{ StopSign::FULL, tp, sl, "20250816", true // ** Set true to enable Day Trade wash price }; auto daytrade_condition_order = sdk->stock->single_condition_day_trade(target_account, StopSign::FULL, "130000", condition , order, day_order, tpsl, true); if (!daytrade_condition_order.is_success) { std::cout << "get order result failed reason: " << (daytrade_condition_order.message.has_value() ? daytrade_condition_order.message.value() : "No message") << std::endl; } else { if (daytrade_condition_order.data.has_value()) { const auto& send = daytrade_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | marketType | TradingType | [Monitoring Type](#tradingtype) Optional: `REFERENCE` Auto Reference Object, `SCHEDULED` Time | | symbol | string | Stock Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Optional: `BID_PRICE` Bid Price, `ASK_PRICE` Ask Price, `MATCHED_PRICE` Matched Price, `TOTAL_QUANTITY` Total Quantity, `TIME` Time | | triggerValue | string | Monitoring Condition Value (If Time, use format HHMMSS) | | comparison | Operator | [Comparison Operator](#operator) Optional: `GREATER_THAN_OR_EQUAL`, `LESS_THAN_OR_EQUAL`, `GREATER_THAN`, `LESS_THAN` | info 1. When selecting `REFERENCE`, trigger can be combined with `BID_PRICE`, `ASK_PRICE`, `MATCHED_PRICE`, `TOTAL_QUANTITY`, `TIME`. If trigger uses `TIME`, it triggers when the time condition is met AND there is a transaction for the commodity within the time range. 2. When selecting `SCHEDULED`, symbol must be empty "", trigger must be `TIME`. It will use system time and trigger when time condition is met. ##### ConditionOrder Object[​](#conditionorder-object "Direct link to ConditionOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | buySell | BsAction | [Buy/Sell Action](#bsaction) | | symbol | string | Stock Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | marketType | ConditionMarketType | [Market Type](#conditionmarkettype) Optional: `COMMON` Round Lot, `FIXING` Fixed Price, `INTRADAY_ODD` Intraday Odd Lot, `ODD` After-hours Odd Lot | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) : Optional: `BID_PRICE` Bid Price, `ASK_PRICE` Ask Price, `MATCHED_PRICE` Matched Price, `LIMIT` Limit Price, `LIMIT_UP` Limit Up, `LIMIT_DOWN` Limit Down, `MARKET` Market Price, `REFERENCE` Reference Price (Flat Price) | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Optional: `ROD`, `FOK`, `IOC` | | orderType | ConditionOrderType | [Order Type](#conditionordertype) : Optional: `STOCK` Stock, `MARGIN` Margin Trading, `SHORT` Short Selling | ##### ConditionDayTrade Object[​](#conditiondaytrade-object "Direct link to ConditionDayTrade Object") | Parameter | Type | Meaning | | --------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | dayTradeEndTime | string | Day Trade Closing Time, format "HHMMSS" (e.g. "130000"); range 130100 ~ 132000 | | autoCancel | bool | Whether to delete triggered orders after washing prices | | price | string | Order Price (If no specific price, e.g., Market Order, leave blank "") | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) : Optional: `BID_PRICE` Bid Price, `ASK_PRICE` Ask Price, `MATCHED_PRICE` Matched Price, `LIMIT` Limit Price, `LIMIT_UP` Limit Up, `LIMIT_DOWN` Limit Down, `MARKET` Market Price, `REFERENCE` Reference Price (Flat Price) | About Day Trade Closing Time Range can be set 130100 ~ 132000 ##### TpslOrder Object[​](#tpslorder-object "Direct link to TpslOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | timeInForce | TimeInforce | [Time In Force](#timeinforce) : Optional: `ROD`, `IOC`, `FOK` | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) : Optional: `BID_PRICE` Bid Price, `ASK_PRICE` Ask Price, `MATCHED_PRICE` Matched Price, `LIMIT` Limit Price, `LIMIT_UP` Limit Up, `LIMIT_DOWN` Limit Down, `MARKET` Market Price, `REFERENCE` Reference Price (Flat Price) | | orderType | ConditionOrderType | [Order Type](#conditionordertype) : Optional: `STOCK` Stock, `MARGIN` Margin Trading, `SHORT` Short Selling | | targetPrice | string | TPSL Trigger Price | | price | string | TPSL Order Price | | trigger | TriggerContent | TPSL [Trigger Condition](#triggercontent) (See details at end of table) | info If `priceType` is `LIMIT`, `price` must be filled; otherwise set price to std::nullopt TPSL Trigger Condition New in version 2.2.0 (***Not available in 2.1.1 and earlier***), TPSL trigger price type can be set to 1. MATCHED\_PRICE 2. Best Bid (BID\_PRICE); 3. Best Ask (ASK\_PRICE) If not set, fill this field with ***null***, defaults to Matched Price (MATCHED\_PRICE) ##### TpslWrapper Object[​](#tpslwrapper-object "Direct link to TpslWrapper Object") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | stopSign | StopSign | [Stop Sign](#stopsign) : Optional: `FULL` Until Full Execution, `PARTIAL` Until Partial Execution, `UNTIL_END` Until Expiry | | tp | TpslOrder Object (Optional) | Take Profit Condition | | sl | TpslOrder Object (Optional) | Stop Loss Condition | | endDate | string (Optional : Same as parent StartDate if empty) | Condition End Date | | intraday | bool (Optional) | Intraday Day Trade after Full Execution (\* Must be set to `true` when used with Day Trade Condition Order) | Intraday Day Trade When using Day Trade Condition Order, `intraday` must be set to `true` ##### TrailOrder[​](#trailorder "Direct link to TrailOrder") | Parameter | Type | Meaning | | ----------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | Stock Symbol | | price | string | Base Price (Note: Max 2 decimal places, system wash price will fail if exceeded) | | direction | Direction | [Direction](#direction) : Optional: `UP`, `DOWN` | | percentage | int | Up / Down % | | buysell | BsAction | Buy/Sell : Optional: `BUY`, `SELL` | | quantity | int | Order Quantity | | PriceType | ConditionPriceType | [Price Type](#conditionpricetype) : Optional `BID_PRICE` Bid Price, `ASK_PRICE` Ask Price, `MATCHED_PRICE` Matched Price, `MARKET` Market Price, `LIMIT_UP` Limit Up, `LIMIT_DOWN` Limit Down, `REFERENCE` Reference Price (Flat Price) | | diff | int | Order Price Ticks (Add/Subtract ticks based on priceType), positive adds ticks upwards, negative adds ticks downwards | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Optional: `ROD`, `FOK`, `IOC` | | orderType | ConditionOrderType | [Order Type](#conditionordertype) Optional: `STOCK` Stock, `MARGIN` Margin Trading, `SHORT` Short Selling | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | -------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Optional:
`TYPE1` From `startTime`, send one order every few seconds, total `totalQuantity`, each order `singleQuantity`
`TYPE2` From `startTime` to `endTime`, send one order every `interval` seconds, total `totalQuantity`, remaining quantity added to the last order
`TYPE3` From `startTime` to `endTime`, send one order every `interval` seconds, total `totalQuantity`, remaining quantity distributed from the last order backwards.

| | interval | int | Order Interval (Seconds) | | singleQuantity | int | Single Order Quantity (Shares) | | totalQuantity | int (Optional) | Total Order Quantity (Shares) | | startTime | string | Start Time | | endTime | string (Optional) | End Time | caution Note: Total order quantity must be greater than single order quantity. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | -------------------- | | guid | string | Condition Order GUID | #### Constants (Field Value Mapping)[​](#constants-field-value-mapping "Direct link to Constants (Field Value Mapping)") ##### BsAction[​](#bsaction "Direct link to BsAction") Buy/Sell Action | Name | Value | Meaning | | ------------- | ----- | ---------------- | | BUY | 1 | Buy | | SELL | 2 | Sell | | UN\_SUPPORTED | 3 | Unsupported Type | | UN\_DEFINED | 4 | Undefined Type | ##### ConditionMarketType[​](#conditionmarkettype "Direct link to ConditionMarketType") Market Type | Name | Value | Meaning | | ------------- | ----- | ------------ | | COMMON | 1 | Common | | FIXING | 2 | Fixing | | INTRADAY\_ODD | 3 | Intraday Odd | | ODD | 4 | Odd Lot | ##### TradingType[​](#tradingtype "Direct link to TradingType") Monitoring Type | Name | Value | Meaning | | --------- | ----- | --------------------- | | REFERENCE | 1 | Auto Reference Object | | SCHEDULED | 3 | Time | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") Trigger Condition | Name | Value | Meaning | | --------------- | ----- | -------------- | | BID\_PRICE | 1 | Bid Price | | ASK\_PRICE | 2 | Ask Price | | MATCHED\_PRICE | 3 | Matched Price | | TOTAL\_QUANTITY | 4 | Total Quantity | | TIME | 5 | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Value | Meaning | | ------------------------ | ----- | --------------------- | | GREATER\_THAN\_OR\_EQUAL | 1 | Greater Than or Equal | | LESS\_THAN\_OR\_EQUAL | 2 | Less Than or Equal | | GREATER\_THAN | 3 | Greater Than | | LESS\_THAN | 4 | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Value | Meaning | | ---------- | ----- | ----------------------- | | FULL | 1 | Until Full Execution | | PARTIAL | 2 | Until Partial Execution | | UNTIL\_END | 3 | Until Expiry | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force (TimeInForce) | Name | Value | Meaning | | ------------- | ----- | ------------------------- | | ROD | 1 | Rest of Day (ROD) | | FOK | 2 | Fill-or-Kill (FOK) | | IOC | 3 | Immediate-or-Cancel (IOC) | | UN\_SUPPORTED | 4 | Unsupported Type | | UN\_DEFINED | 5 | Undefined Type | ##### ConditionPriceType[​](#conditionpricetype "Direct link to ConditionPriceType") Price Type (ConditionPriceType) | Name | Value | Meaning | | -------------- | ----- | --------------- | | LINIT | 1 | Limit | | BID\_PRICE | 2 | Bid Price | | ASK\_PRICE | 3 | Ask Price | | MARKET | 4 | Market | | MATCHED\_PRICE | 5 | Matched Price | | LIMIT\_UP | 6 | Limit Up | | LIMIT\_DOWN | 7 | Limit Down | | REFERENCE | 8 | Reference Price | ##### ConditionOrderType[​](#conditionordertype "Direct link to ConditionOrderType") Order Type (orderType) | Name | Value | Meaning | | ---------- | ----- | ------------- | | STOCK | 1 | Stock | | MARGIN | 2 | Margin | | SHORT | 3 | Short Selling | | DAY\_TRADE | 4 | Day Trade | ##### Direction[​](#direction "Direct link to Direction") Trailing Stop Up/Down (direction) | Name | Value | Meaning | | ---- | ----- | ------- | | Up | 1 | Up | | Down | 2 | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") Slice Type (SliceType) | Name | Meaning | | ----- | ------------------------------------------------------------------------------------------------------------------- | | Type1 | From Start Time, send one order every few seconds, total N orders, M shares each | | Type2 | From Start to End, send one order every X seconds, total N shares, remaining shares added to last order | | Type3 | From Start to End, send one order every X seconds, total N shares, remaining shares distributed from last backwards | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") Condition Status (ConditionStatus) | Name | Meaning | | ------ | -------------------- | | Type1 | Today's Query | | Type2 | Valid Orders | | Type3 | Comparing Conditions | | Type4 | Order Processing | | Type5 | Order Success | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Has Match | | Type9 | Delete Success | | Type10 | Abnormal | | Type11 | Invalid | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") History Status (HistoryStatus) | Name | Meaning | | ----- | ------------------------------------------------- | | Type1 | All Condition Orders (Excluding Deleted, Invalid) | | Type2 | Full Match Orders in Period | | Type3 | Partial Match Orders in Period | | Type4 | Deleted Orders in Period | | Type5 | Invalid Orders in Period | | Type6 | Triggered Records in Period | --- ### Get Condition Order By ID get\_condition\_order\_by\_id #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | guid | string | Condition Order GUID | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | List | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_conditionid = sdk->stock->get_condition_order_by_id(target_account, "564b7ad6-a332-470c-93ea-cf3fea00d7fa"); if (!get_conditionid.is_success) { std::cout << "get condition result failed reason: " << (get_conditionid.message.has_value() ? get_conditionid.message.value() : "No message") << std::endl; } else { if (get_conditionid.data.has_value()) { for (const auto& result : get_conditionid.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Condition result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = } } ``` --- ### Get Condition History GetConditionHistory #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | startDate | string | Condition Order Create Date | | endDate | string | Query End Date | | conditionHistoryStatus | [History Status](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#historystatus) (Optional) | History Condition Status `Type1` All Condition Orders (Excluding Deleted, Invalid), `Type2` Full Match Orders in Period, `Type3` Partial Match Orders in Period, `Type4` Deleted Orders in Period, `Type5` Invalid Orders in Period, `Type6` Triggered Records in Period | info History data date is based on condition order creation date. #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------- | ------------------------------------ | | isSuccess | bool | Is Success | | data | list | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs auto get_conditionid = sdk->stock->get_condition_history(target_account, "20250604","20250605", std::nullopt); if (!get_conditionid.is_success) { std::cout << "get order result failed reason: " << (get_conditionid.message.has_value() ? get_conditionid.message.value() : "No message") << std::endl; } else { if (get_conditionid.data.has_value()) { for (const auto& result : get_conditionid.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = True, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price <= 570 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = Market(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = Multi-Condition, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 575, AND TSMC total qty >= 1001, AND Time >= 10:30:00 from 2024/03/14 to 2024/07/04, until partial execution, action = Order (Day Trade), conditionBuySell = Stock Buy, conditionSymbol = TSMC Stock Buy, conditionPrice = 576(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = Triggered-OrderFailed(X), errorMessage = Price Error[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, startDate = 2024/03/14, status = Pending(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = When TSMC price <= 570 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = Market(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, startDate = 2024/03/14, status = Pending(W), errorMessage = } ] } ] } ``` --- ### Get Condition Order get\_condition\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | conditionStatus | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionstatus) (Optional) | Condition Order Status: `Type1` Today's Query, `Type2` Valid Orders, `Type3` Comparing Conditions, `Type4` Order Processing, `Type5` Order Success, `Type6` Notified, `Type7` Order Failed, `Type8` Has Match, `Type9` Delete Success, `Type10` Abnormal, `Type11` Invalid | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------- | ------------------------------------ | | isSuccess | bool | Is Success | | data | List | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_conditionid = sdk->stock->get_condition_order(target_account, std::nullopt); if (!get_conditionid.is_success) { std::cout << "get order result failed reason: " << (get_conditionid.message.has_value() ? get_conditionid.message.value() : "No message") << std::endl; } else { if (get_conditionid.data.has_value()) { for (const auto& result : get_conditionid.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = Multi-Condition, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price <= 570 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = Market(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = Pending(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = Multi-Condition, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = When TSMC price >= 575, AND TSMC total qty >= 1001, AND Time >= 10:30:00 from 2024/03/14 to 2024/07/04, until partial execution, action = Order (Day Trade), conditionBuySell = Stock Buy, conditionSymbol = TSMC Stock Buy, conditionPrice = 576(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = Triggered-OrderFailed(X), errorMessage = Price Error[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = When TSMC price >= 580 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = 580(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, startDate = 2024/03/14, status = Pending(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = When TSMC price <= 570 from 2024/03/14 to 2024/07/04, until full execution, action = Order (Next Day Cover), conditionBuySell = Stock Sell, conditionSymbol = TSMC Stock Sell, conditionPrice = Market(ROD), conditionVolume = 5 lots, conditionFilledVolume = 0 lots, startDate = 2024/03/14, status = Pending(W), errorMessage = } ] } ] } ``` --- ### Multi Condition Order multi\_condition #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Monitoring Start Time | | end\_date | string | Condition Monitoring End Time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop Sign :`FULL` Until Full Execution, `PARTIAL` Until Partial Execution, `UNTIL_END` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order Content | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionOrderResult Fields[​](#order-info-conditionorderresult-fields "Direct link to Order Info ConditionOrderResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | -------------------- | | guid | string | Condition Order GUID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Design Condition Content Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; Condition condition2 = Condition{ TradingType::REFERENCE, "2881", TriggerContent::TOTAL_QUANTITY, "1000", Operator::GREATER_THAN, }; std::vector conditions; conditions.push_back(condition); conditions.push_back(condition2); ConditionOrder order = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; auto send_condition_order = sdk->stock->multi_condition(target_account, "20250605", "20250605", StopSign::FULL, conditions, order); if (!send_condition_order.is_success) { std::cout << "get order result failed reason: " << (send_condition_order.message.has_value() ? send_condition_order.message.value() : "No message") << std::endl; } else { if (send_condition_order.data.has_value()) { const auto& send = send_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX, } } ``` --- ### Multi-Condition Order with TP/SL multi\_condition TP/SL Notes * TP/SL settings only **trigger** order placement and do not guarantee execution. Please adjust based on market conditions. * Make sure the TP/SL **order type** is compatible with the applicable trading rules (e.g., margin trading, margin buy/sell, etc.). info TP/SL will only start after the parent order is fully filled. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Trading account | | start\_date | string | Condition monitoring start time | | end\_date | string | Condition monitoring end time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop condition: `FULL` = until fully filled, `PARTIAL` = until partially filled, `UNTIL_END` = until validity ends | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger condition(s) | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order request payload | | TPSLObject | [TpslWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#tpslwrapper-object) | TP/SL configuration | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | ----------- | ------------------- | -------------------------------------------- | | is\_success | bool | Whether the request succeeded | | data | Object | Returned information for the condition order | | message | string ? (optional) | Error message when `isSuccess = false` | ##### ConditionOrderResult Fields (Order Info)[​](#conditionorderresult-fields-order-info "Direct link to ConditionOrderResult Fields (Order Info)") Return type: Object | Parameter | Type | Description | | --------- | ------ | ------------------ | | guid | string | Condition order ID | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Define the conditions Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; Condition condition2 = Condition{ TradingType::REFERENCE, "2881", TriggerContent::TOTAL_QUANTITY, "1000", Operator::GREATER_THAN, }; std::vector conditions; conditions.push_back(condition); conditions.push_back(condition2); ConditionOrder order = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; TpslOrder tp = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "85", "85", }; TpslOrder sl = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "60", "60", }; TPSLWrapper tpsl = TPSLWrapper{ StopSign::FULL, tp, sl, "20250605", false }; auto send_condition_order = sdk->stock->multi_condition(target_account, "20250605", "20250605", StopSign::FULL, conditions, order, tpsl); if (!send_condition_order.is_success) { std::cout << "get order result failed reason: " << (send_condition_order.message.has_value() ? send_condition_order.message.value() : "No message") << std::endl; } else { if (send_condition_order.data.has_value()) { const auto& send = send_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition Order single\_condition #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Trading account | | start\_date | string | Condition monitoring start time | | end\_date | string | Condition monitoring end time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop condition: `FULL` = until fully filled, `PARTIAL` = until partially filled, `UNTIL_END` = until validity ends | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order request payload | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | ----------- | ------------------- | -------------------------------------------- | | is\_success | bool | Whether the request succeeded | | data | Object | Returned information for the condition order | | message | string ? (optional) | Error message when `isSuccess = false` | ##### ConditionOrderResult Fields (Order Info)[​](#conditionorderresult-fields-order-info "Direct link to ConditionOrderResult Fields (Order Info)") Return type: Object | Parameter | Type | Description | | --------- | ------ | ------------------ | | guid | string | Condition order ID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Define the condition Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; ConditionOrder order = ConditionOrder{ BsAction::BUY, "2881", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; auto send_condition_order = sdk->stock->single_condition(target_account,"20250605","20250605", StopSign::FULL, condition, order, std::nullopt); if (!send_condition_order.is_success) { std::cout << "get order result failed reason: " << (send_condition_order.message.has_value() ? send_condition_order.message.value() : "No message") << std::endl; } else { if (send_condition_order.data.has_value()) { const auto& send = send_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition Order with TP/SL single\_condition TP/SL Notes * TP/SL settings only **trigger** order placement and do not guarantee execution. Please adjust based on market conditions. * Make sure the TP/SL **order type** is compatible with the applicable trading rules (e.g., margin trading, margin buy/sell, etc.). info TP/SL will only start after the parent order is fully filled. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Trading account | | start\_date | string | Condition monitoring start time | | end\_date | string | Condition monitoring end time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop condition: `FULL` = until fully filled, `PARTIAL` = until partially filled, `UNTIL_END` = until validity ends | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#condition-object) | Trigger condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order request payload | | TPSLObject | [TpslWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#tpslwrapper-object) | TP/SL configuration | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | ----------- | ------------------- | -------------------------------------------- | | is\_success | bool | Whether the request succeeded | | data | Object | Returned information for the condition order | | message | string ? (optional) | Error message when `isSuccess = false` | ##### ConditionOrderResult Fields (Order Info)[​](#conditionorderresult-fields-order-info "Direct link to ConditionOrderResult Fields (Order Info)") Return type: Object | Parameter | Type | Description | | --------- | ------ | ------------------ | | guid | string | Condition order ID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Define the condition Condition condition = Condition{ TradingType::REFERENCE, "2881", TriggerContent::MATCHED_PRICE, "66", Operator::LESS_THAN, }; ConditionOrder order = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; TpslOrder tp = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "85", "85", }; TpslOrder sl = TpslOrder{ TimeInForce::ROD, ConditionPriceType::LIMIT, ConditionOrderType::STOCK, "60", "60", }; TPSLWrapper tpsl = TPSLWrapper{ StopSign::FULL, tp, sl, "20250605", false }; auto send_condition_order = sdk->stock->single_condition(target_account, "20250605", "20250605", StopSign::FULL, condition, order, tpsl); if (!send_condition_order.is_success) { std::cout << "get order result failed reason: " << (send_condition_order.message.has_value() ? send_condition_order.message.value() : "No message") << std::endl; } else { if (send_condition_order.data.has_value()) { const auto& send = send_condition_order.data.value(); std::cout << send << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX, } } ``` --- ### Get Time Slice Order get\_time\_slice\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | batchNo | string | Time Slice Batch No | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | List | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_timeslice = sdk->stock->get_time_slice_order(target_account, "25060500000002"); if (!get_timeslice.is_success) { std::cout << "get order result failed reason: " << (get_timeslice.message.has_value() ? get_timeslice.message.value() : "No message") << std::endl; } else { if (get_timeslice.data.has_value()) { for (const auto& result : get_timeslice.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = [ ConditionDetail{ Guid = c4dc90c1-4277-42ea-b585-085dc347eac0, BatchNo = , OrderLevel = 0, LastTime = 2024-07-23 17:30:01, ConditionType = Time Slice, ParentGuid = , Symbol = 2881, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = At 2024/07/23, Time Slice Time >= 08:40:00, Until Full Execution, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = Fubon Financial Stock Buy, ConditionPrice = 66(ROD), ConditionVolume = 1 lot, ConditionFilledVolume = 0 lot, CreateTime = 2024-07-22 17:30:03, StartDate = 2024/07/23, Status = Condition Stop(I), ErrorMessage = , DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = 2975702e-f36f-4da4-bab6-1310344ec05d, BatchNo = , OrderLevel = 0, LastTime = 2024-07-23 17:30:01, ConditionType = Time Slice, ParentGuid = , Symbol = 2881, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = At 2024/07/23, Time Slice Time >= 09:10:00, Until Full Execution, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = Fubon Financial Stock Buy, ConditionPrice = 66(ROD), ConditionVolume = 1 lot, ConditionFilledVolume = 0 lot, CreateTime = 2024-07-22 17:30:03, StartDate = 2024/07/23, Status = Condition Stop(I), ErrorMessage = , DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Time Slice Order time\_slice\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Monitoring Start Time | | end\_date | string | Condition Monitoring End Time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Full Execution, `Partial` Until Partial Execution, `UntilEnd` Until Expiry | | splitDescription | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#splitdescription) | Split Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#conditionorder-object) | Order Content | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionOrderResult Fields[​](#order-info-conditionorderresult-fields "Direct link to Order Info ConditionOrderResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | ------------------- | | batchId | string | Time Slice Batch No | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Design Condition Content SplitDescription split = SplitDescription{ TimeSliceOrderType::TYPE1, 30, 1000, 10000, "083000", std::nullopt }; ConditionOrder sliceorder = ConditionOrder{ BsAction::BUY, "2330", "1000", 1000, ConditionMarketType::COMMON, ConditionPriceType::LIMIT, TimeInForce::ROD, ConditionOrderType::STOCK, }; auto timeslice = sdk->stock->time_slice_order(target_account, "20250605","20250605", StopSign::FULL, split, sliceorder); if (!timeslice.is_success) { std::cout << "send timeslice result failed reason: " << (timeslice.message.has_value() ? timeslice.message.value() : "No message") << std::endl; } else { if (timeslice.data.has_value()) { const auto& send = timeslice.data.value(); std::cout << send << std::endl; } else { std::cout << "send timeslice success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = ConditionOrderResult { guid = 24080500000002, } } ``` --- ### Get Historical Trail Profit Order get\_trail\_history #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | -------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | list | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_trail_his = sdk->stock->get_trail_history(target_account, "20250601", "20250606"); if (!get_trail_his.is_success) { std::cout << "get order result failed reason: " << (get_trail_his.message.has_value() ? get_trail_his.message.value() : "No message") << std::endl; } else { if (get_trail_his.data.has_value()) { for (const auto& result : get_trail_his.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = True, message = , data = [ ConditionDetail { Guid = 5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e, BatchNo = , OrderLevel = 0, LastTime = 2024-08-02 16:45:01, ConditionType = , ParentGuid = , Symbol = 2889, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = When Waterland Financial Holdings falls by 10% from 1000 (initial base price) between 2024/08/02 and 2024/08/02, until full execution or expiry, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = Waterland Financial Holdings (2889), ConditionPrice = Matched Price(1) Tick(ROD), ConditionVolume = 1 lot, ConditionFilledVolume = 0 lot, CreateTime = 2024-08-02 10:07:31, StartDate = 2024/08/02, Status = Condition Stop(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = c71117c8-aa70-4477-9f04-ff4c73a4fad0, BatchNo = "", OrderLevel = 0, LastTime = 2024-07-29 17:30:00, ConditionType = , ParentGuid = , Symbol = 2330, OrderAmount = 0, ChildBatchNo = "", Account = 1307515, ConditionContent = When TSMC rises by 5% from 860 (initial base price) between 2024/07/29 and 2024/07/29, until full execution or expiry, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = TSMC (2330), ConditionPrice = Matched Price(5) Tick(ROD), ConditionVolume = 2 lots, ConditionFilledVolume = 0 lot, CreateTime = 2024-07-29 11:01:49, StartDate = 2024/07/29, Status = Condition Stop(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Get Trail Profit Order get\_trail\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------- | ------------------------------------ | | isSuccess | bool | Is Success | | data | List | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionDetail Fields[​](#order-info-conditiondetail-fields "Direct link to Order Info ConditionDetail Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ------ | ------------------------ | | guid | string | Condition Order GUID | | batch\_no | string | Batch No | | order\_level | string | Order Level | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Order GUID | | symbol | string | Stock Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Child Batch No | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Action | | condition\_buy\_sell | string | Condition Buy/Sell | | condition\_symbol | string | Condition Symbol | | condition\_price | string | Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Create Time | | start\_date | string | Scheduled Start Time | | status | string | Current Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Records Count | | detail\_records | List | Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | | tpsl\_count | string | TPSL Count | | tpsl\_record | List | TPSL Detail Records Data | | >> guid | string | Condition Order GUID | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Action | | >> condition\_buy\_sell | string | Condition Buy/Sell | | >> condition\_symbol | string | Condition Symbol | | >> condition\_price | string | Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Scheduled Start Time | | >> status | string | Current Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto get_trail = sdk->stock->get_trail_order(target_account); if (!get_trail.is_success) { std::cout << "get order result failed reason: " << (get_trail.message.has_value() ? get_trail.message.value() : "No message") << std::endl; } else { if (get_trail.data.has_value()) { for (const auto& result : get_trail.data.value()) { std::cout << result << std::endl; } } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = [ ConditionDetail { Guid = 5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e, BatchNo = , OrderLevel = 0, LastTime = 2024-08-02 16:45:01, ConditionType = , ParentGuid = , Symbol = 2889, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = When Waterland Financial Holdings falls by 10% from 1000 (initial base price) between 2024/08/02 and 2024/08/02, until full execution or expiry, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = Waterland Financial Holdings (2889), ConditionPrice = Matched Price(1) Tick(ROD), ConditionVolume = 1 lot, ConditionFilledVolume = 0 lot, CreateTime = 2024-08-02 10:07:31, StartDate = 2024/08/02, Status = Condition Stop(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = c71117c8-aa70-4477-9f04-ff4c73a4fad0, BatchNo = "", OrderLevel = 0, LastTime = 2024-07-29 17:30:00, ConditionType = , ParentGuid = , Symbol = 2330, OrderAmount = 0, ChildBatchNo = "", Account = 1307515, ConditionContent = When TSMC rises by 5% from 860 (initial base price) between 2024/07/29 and 2024/07/29, until full execution or expiry, Action = Order, ConditionBuySell = Stock Buy, ConditionSymbol = TSMC (2330), ConditionPrice = Matched Price(5) Tick(ROD), ConditionVolume = 2 lots, ConditionFilledVolume = 0 lot, CreateTime = 2024-07-29 11:01:49, StartDate = 2024/07/29, Status = Condition Stop(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Trail Profit Order trail\_profit #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Monitoring Start Time | | end\_date | string | Condition Monitoring End Time | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#stopsign) | Stop Sign : `Full` Until Full Execution, `Partial` Until Partial Execution, `UntilEnd` Until Expiry | | TrailOrder | [TrailOrder](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/cpp/EnumMatrix.md#trailorder) | Split Condition | caution The base price (price) in TrailOrder can only be input up to two decimal places. Exceeding this will cause system wash price failure. info When the current stock price touches the trigger price (calculated by percentage rise/fall from base price), the order is placed. **Example:** If initial base price is 100, trailing stop/profit 5% down. Initial trigger price is 95. If price does not rise above 100 (i.e. base price not adjusted), then when market price hits 95, the condition order is triggered. #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | ----------- | ------------------- | ------------------------------------ | | is\_success | bool | Is Success | | data | Object | Condition Order Return Info | | message | string ? (optional) | Error message when isSuccess = false | ##### Order Info ConditionOrderResult Fields[​](#order-info-conditionorderresult-fields "Direct link to Order Info ConditionOrderResult Fields") Return type : Object | Parameter | Type | Description | | --------- | ------ | -------------------- | | guid | string | Condition Order GUID | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Design Condition Content TrailOrder trail = TrailOrder{ "2330", "1000", Direction::UP, 5, BsAction::BUY, 2000, ConditionPriceType::MATCHED_PRICE, 5, TimeInForce::ROD, ConditionOrderType::STOCK }; auto trail_order = sdk->stock->trail_profit(target_account, "20250606","20250606", StopSign::FULL, trail); if (!trail_order.is_success) { std::cout << "send trail_order result failed reason: " << (trail_order.message.has_value() ? trail_order.message.value() : "No message") << std::endl; } else { if (trail_order.data.has_value()) { const auto& send = trail_order.data.value(); std::cout << send << std::endl; } else { std::cout << "send trail_order success but no data returned." << std::endl; } } ``` #### Return Example[​](#return-example "Direct link to Return Example") ```cpp { isSuccess = true, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX, } } ``` --- ### Cancel Condition Order CancelConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | CancelResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### CancelResult Parameter[​](#cancelresult-parameter "Direct link to CancelResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.CancelConditionOrders(account, "c9df498a-3b28-4b50-a6f2-f7bd524e96df"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs Result { isSuccess = True, message = , data = CancelResult { advisory = "成功筆數:1,失敗筆數:0!" } } ``` --- ### Get Condition Daytrade GetConditionDaytradeById #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetConditionDaytradeById(account,"8ff3472b-185a-488c-be5a-b478deda080c"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = 多條件, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止, action = 下單(當沖), conditionBuySell = 現股買, conditionSymbol = 台積電 現股買, conditionPrice = 576元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = 觸發-委託失敗(X), errorMessage = 單價輸入錯誤[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = } ] } ] } ``` --- ### Multi-Condition with DayTrade MultiConditionDayTrade Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | endTime | string | End time of parent order | | multicondition [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | | orderObject | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fixSession | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var condition1 = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var condition2 = new Condition( TradingType.Reference, "2881", TriggerContent.TotalQuantity, "8000", Operator.LessThan ); List conditions = new List(); conditions.Add(condition1); conditions.Add(condition2); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); var daytrade_obj = new ConditionDayTrade( "131000", // Position covering time, valid range between 130100 ~ 132000 true, "", ConditionPriceType.Market ); var tp = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "85", "85", null ); var sl = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "60", "60", null ); var tpsl = new TpslWrapper( StopSign.Full, tp, sl, "20240517", true // ** Must set true to enable daytrade ); sdk.Stock.MultiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, true); // Not Setting TPSL //sdk.Stock.MultiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, true); // Not Setting Fix Session Covering //sdk.Stock.MultiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, false); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition with DayTrade SingleCondition Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | endTime | string | End time of parent order | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | Condition Content | | orderObject | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fixSession | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // 設計條件內容 var condition = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); var daytrade_obj = new ConditionDayTrade( "131000", // Position covering time, valid range between 130100 ~ 132000 true, "", ConditionPriceType.Market ); var tp = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "85", "85", null ); var sl = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "60", "60", null ); var tpsl = new TpslWrapper( StopSign.Full, tp, sl, "20240517", true // ** Must set true to enable daytrade ); sdk.Stock.SingleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, true); // Not Setting TPSL //sdk.Stock.SingleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, true); // Not Setting Fix Session Covering //sdk.Stock.SingleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, false); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | -------------- | -------------- | ------------------------------------------------------------------------------------------------------------------- | | market\_type | TradingType | [Trading Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 、`Time` | | trigger\_value | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When using `Reference`, trigger can be `BidPrice` 、 `AskPrice` 、 `MatchedPrice` 、 `TotalQuantity` or `Time`. If the trigger is `Time`, then the order would be triggered if the time condition is true and the reference product has actully trade happened with in the time range. 2. When selecting `Scheduled`, symbol should be empty "", and the trigger must be `Time`. It would use the system time to determine if the order to be triggered when the time condition is true. ##### ConditionOrder Object[​](#conditionorder-object "Direct link to ConditionOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | buySell | BsAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | marketType | ConditionMarketType | [Trading Session](#conditionmarkettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd` | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | orderType | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | ##### TpslOrder Object[​](#tpslorder-object "Direct link to TpslOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | timeInForce | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Flat Price、`MatchedPrice` current market price | | orderType | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | | targetPrice | string | Take Profit / Stop Loss Trigger Price Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger | TriggerContent | Take Profit / Stop Loss [TriggerContent](#triggercontent) (details below) | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` **OR** `null` (>= ver. 2.2.4) TP/SL Trigger Content New parameter added since v2.2.0 (***v2.1.1 and earlier version do not have this parameter***). This can be used to set the trigger price type for take-profit/stop-loss order. The price type can be one of the follows: 1. MatchedPrice, 2. BidPrice, 3. AskPrice To use the default value, set it to ***null***. The default value is MatchedPrice. ##### TpslWrapper Object[​](#tpslwrapper-object "Direct link to TpslWrapper Object") | Parameter | Type | Meaning | | --------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stopSign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | TpslOrder Object (Optional) | TP Object | | sl | TpslOrder Object (Optional) | SL Object | | endDate | string (Optional : null equals Condition startDate) | TP / SL EndDate | | intraday | bool (Optional) | When Fully Filled Then Execuate DayTrade | Day trade `intraday` must set to `true` when using with daytrade condition order ##### TrailOrder[​](#trailorder "Direct link to TrailOrder") | Parameter | Type | Meaning | | ----------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | symbol | string | symbol | | price | string | Activate Price (Note. Can only take up to two decimal places, otherwise it will fail to be activated.) | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | percentage | int | Up / down percentage | | buysell | BsAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | quantity | int | Order Quantity | | priceType | ConditionPriceType | [PriceType](#conditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Reference Price (Flat Price) | | diff | int | Buy / Sell Ticker ( Base on priceType up / down) | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | orderType | ConditionOrderType | [OrderType](#conditionordertype) Valid `Stock` Common Stock、`Margin` 、`Short` Short Sale | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | -------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order
`Type2` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders (seconds) | | singleQuantity | int | Single Order Shares | | totalQuantity | int (Optional) | Total Order Shares | | startTime | string | Start Time | | endTime | string (Optional) | End Time | caution `totalQuantity` must be greater than `singleQuantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | ##### ConditionDayTrade Object[​](#conditiondaytrade-object "Direct link to ConditionDayTrade Object") | Parameter | Type | Meaning | | --------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------- | | dayTradeEndTime | string | The time to start covering the open position. Format: "HHMMSS" (e.g., "131000") | | autoCancel | bool | Cancel the triggered entry order when the end time of the parent order is reached | | price | string | The order price (for price types that do not require the input, please use the empty string "") | | priceType | [ConditionPriceType](#conditionpricetype) | The price type | About day Trade End Time Valid time range is 130100 ~ 132000 #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### ConditionMarketType[​](#conditionmarkettype "Direct link to ConditionMarketType") Trading Session Type | Name | Meaning | | ----------- | ---------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Scheduled | Time | | Index | Index | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | ------------- | -------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down/ (direction) | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Type1 | Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order | | Type2 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### ConditionPriceType[​](#conditionpricetype "Direct link to ConditionPriceType") PriceType (ConditionPriceType) | Name | Meaning | | ------------ | ---------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | ##### ConditionOrderType[​](#conditionordertype "Direct link to ConditionOrderType") OrderType (ConditionOrderType) | Name | Meaning | | ------ | ------------ | | Stock | Common Stock | | Margin | Margin | | Short | Short Sale | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid GetConditionOrderById #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetConditionOrderById(account,"8ff3472b-185a-488c-be5a-b478deda080c"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = 多條件, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止, action = 下單(當沖), conditionBuySell = 現股買, conditionSymbol = 台積電 現股買, conditionPrice = 576元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = 觸發-委託失敗(X), errorMessage = 單價輸入錯誤[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = } ] } ] } ``` --- ### Query Condition History GetConditionHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | | condition\_history\_status | [History Status](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#historystatus) (Optional) | Status of History COndition | info The date is based on the creation date of the condition order #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetConditionHistory(account,"20240301","20240601"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = 多條件, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止, action = 下單(當沖), conditionBuySell = 現股買, conditionSymbol = 台積電 現股買, conditionPrice = 576元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = 觸發-委託失敗(X), errorMessage = 單價輸入錯誤[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = } ] } ] } ``` --- ### Get Condition Order GetConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | conditionStatus | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetConditionOrder(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords = , tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = 8ff3472b-185a-488c-be5a-b478deda080c, batchNo = , orderLevel = 1, lastTime = 2024-03-14 12:39:02, conditionType = 多條件, parentGuid = 58e7a51e-9701-4d26-bc16-18a392a840bd, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:39:22, startDate = 2024/03/14, status = 未生效(W), errorMessage = null, detailRecordsCount = 0, detailRecords =, tPSLCount = 0, tPSLRecord = }, ConditionDetail { guid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, batchNo = , orderLevel = 0, lastTime = 2024-05-21 10:30:00, conditionType = 多條件, parentGuid = ec757279-bcb3-46f4-80ac-fccfc786bc8d, symbol = 2330, orderAmount = 0, childBatchNo = , account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止, action = 下單(當沖), conditionBuySell = 現股買, conditionSymbol = 台積電 現股買, conditionPrice = 576元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, createTime = 2024-03-14 12:30:02, startDate = 2024/03/14, status = 觸發-委託失敗(X), errorMessage = 單價輸入錯誤[4385715], detailRecordsCount = 0, detailRecords = [], tPSLCount = 2, tPSLRecord = [ ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 580元(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = }, ParentChildRecord { guid = c94b552a-22da-43e4-be44-f27a9c2026e1, account = 1307515, conditionContent = 當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止, action = 下單(次日回補), conditionBuySell = 現股賣, conditionSymbol = 台積電 現股賣, conditionPrice = 市價(ROD), conditionVolume = 5張, conditionFilledVolume = 0張, startDate = 2024/03/14, status = 未生效(W), errorMessage = } ] } ] } ``` --- ### Multi-Condition MultiCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var condition1 = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var condition2 = new Condition( TradingType.Reference, "2881", TriggerContent.TotalQuantity, "8000", Operator.LessThan ); List conditions = new List(); conditions.Add(condition1); conditions.Add(condition2); var order = new Order( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); sdk.Stock.MultiCondition(account, "20240426", "20240430", StopSign.Full, conditions, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Multi-Condition with TP & SL MultiCondition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. info TP & SL will be activated after the master order has been fully filled. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ----------------------- | | guid | string | Condition Serial Number | | reply\_code | string | Status Code | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var condition1 = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var condition2 = new Condition( TradingType.Reference, "2881", TriggerContent.TotalQuantity, "8000", Operator.LessThan ); List conditions = new List(); conditions.Add(condition1); conditions.Add(condition2); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); var tp = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "85", "85", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var sl = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "60", "60", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var tpsl = new TpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.Stock.MultiCondition(account, "20240426", "20240430", StopSign.Full, conditions, order, tpsl); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition SingleCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var condition = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); sdk.Stock.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition with TP & SL SingleCondition info TP & SL will be activated after the master order has been fully filled. Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // 設計條件內容 var condition = new Condition( TradingType.Reference, "2881", TriggerContent.MatchedPrice, "66", Operator.LessThan ); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); var tp = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "85", "85", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var sl = new TpslOrder( TimeInForce.Rod, ConditionPriceType.Limit, ConditionOrderType.Stock, "60", "60", null // For version >= 2.2.0, detail refer to [List of Enumerations] -> [TpslOrder Object] ); var tpsl = new TpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.Stock.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Get Time Slice Order GetTimeSliceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | BatchNo | string | Time Slice Order Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetTimeSliceOrder(account,"1234567"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail{ Guid = c4dc90c1-4277-42ea-b585-085dc347eac0, BatchNo = , OrderLevel = 0, LastTime = 2024-07-23 17:30:01, ConditionType = 分時分量, ParentGuid = , Symbol = 2881, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = 當於2024/07/23 定時單時間大於等於08:40:00 全部成交為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 富邦金 現股買, ConditionPrice = 66元(ROD), ConditionVolume = "1張, ConditionFilledVolume = 0張, CreateTime = 2024-07-22 17:30:03, StartDate = 2024/07/23, Status = 條件單中止(I), ErrorMessage = , DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = 2975702e-f36f-4da4-bab6-1310344ec05d, BatchNo = , OrderLevel = 0, LastTime = 2024-07-23 17:30:01, ConditionType = 分時分量, ParentGuid = , Symbol = 2881, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = 當於2024/07/23 定時單時間大於等於09:10:00 全部成交為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 富邦金 現股買, ConditionPrice = 66元(ROD), ConditionVolume = 1張, ConditionFilledVolume = 0張, CreateTime = 2024-07-22 17:30:03, StartDate = 2024/07/23, Status = 條件單中止(I), ErrorMessage = , DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Time Slice ConditionOrder TimesliceCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var split = new SplitDescription( TimeSliceOrderType.Type1, 300, 1000, 10000, "083000", null ); var order = new ConditionOrder( BsAction.Buy, "2881", "66", 2000, ConditionMarketType.Common, ConditionPriceType.Limit, TimeInForce.Rod, ConditionOrderType.Stock ); sdk.Stock.TimeSliceOrder(target_account, "20240427","20240516", StopSign.Full, split, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 24080500000002 } } ``` --- ### Query Trail History GetTrailHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetConditionHistory(account,"20240301","20240601"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { Guid = 5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e, BatchNo = , OrderLevel = 0, LastTime = 2024-08-02 16:45:01, ConditionType = , ParentGuid = , Symbol = 2889, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = 從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 國票金 (2889), ConditionPrice = 成交價(1) 檔(ROD), ConditionVolume = 1張, ConditionFilledVolume = 0張, CreateTime = 2024-08-02 10:07:31, StartDate = 2024/08/02, Status = 條件單中止(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = c71117c8-aa70-4477-9f04-ff4c73a4fad0, BatchNo = "", OrderLevel = 0, LastTime = 2024-07-29 17:30:00, ConditionType = , ParentGuid = , Symbol = 2330, OrderAmount = 0, ChildBatchNo = "", Account = 1307515, ConditionContent = 從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 台積電 (2330), ConditionPrice = 成交價(5) 檔(ROD), ConditionVolume = 2張, ConditionFilledVolume = 0張, CreateTime = 2024-07-29 11:01:49, StartDate = 2024/07/29, Status = 條件單中止(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Get Trail Order GetTrailOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.GetTrailOrder(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail { Guid = 5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e, BatchNo = , OrderLevel = 0, LastTime = 2024-08-02 16:45:01, ConditionType = , ParentGuid = , Symbol = 2889, OrderAmount = 0, ChildBatchNo = , Account = 1307515, ConditionContent = 從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 國票金 (2889), ConditionPrice = 成交價(1) 檔(ROD), ConditionVolume = 1張, ConditionFilledVolume = 0張, CreateTime = 2024-08-02 10:07:31, StartDate = 2024/08/02, Status = 條件單中止(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] }, ConditionDetail { Guid = c71117c8-aa70-4477-9f04-ff4c73a4fad0, BatchNo = "", OrderLevel = 0, LastTime = 2024-07-29 17:30:00, ConditionType = , ParentGuid = , Symbol = 2330, OrderAmount = 0, ChildBatchNo = "", Account = 1307515, ConditionContent = 從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止, Action = 下單, ConditionBuySell = 現股買, ConditionSymbol = 台積電 (2330), ConditionPrice = 成交價(5) 檔(ROD), ConditionVolume = 2張, ConditionFilledVolume = 0張, CreateTime = 2024-07-29 11:01:49, StartDate = 2024/07/29, Status = 條件單中止(I), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 0, TpslRecord = [] } ] } ``` --- ### Trail Profit Condition TrailProfit #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [Trail Order](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#trailorder) | Trail Order Condition | caution The activate price in TrailOrder can only take up to two decimal places, otherwise it will fail to be activated. info The order will be placed when the current price hit the trigger price (the activate price up/down to the setting percentage) **Example.** If the activate price is set to 100, and the stop loss/gain condiition is set as 5% down, so the initial trigger price is 95. Assuming that the price never go above 100 (so that the activate price does not move upward), then the stop loss/gain order will be placed when the market price hit 95. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var trail = new TrailOrder( "2330", "860", Direction.Up, 5, // Up or Down Percent BsAction.Buy, 2000, ConditionPriceType.MatchedPrice, 5, // order price ticker (negative represent down) TimeInForce.Rod, ConditionOrderType.Stock, ); sdk.Stock.TrailProfit(target_account, "20240427","20240516", StopSign.Full, trail); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Cancel Condition Order cancelConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | CancelResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### CancelResult Parameter[​](#cancelresult-parameter "Direct link to CancelResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.cancelConditionOrders(account, "c9df498a-3b28-4b50-a6f2-f7bd524e96df") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, data: { { advisory = "成功筆數:1,失敗筆數:0!" } } } ``` --- ### Get Condition Daytrade getConditionDaytradeById #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getConditionDaytradeById(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: { guid : "8ff3472b-185a-488c-be5a-b478deda080c", orderLevel : "1", lastTime : "2024-03-14 12:39:02", conditionType : "多條件", parentGuid : "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:39:22", startDate : "2024/03/14", status : "未生效(W)", detailRecordsCount : "0", tpslCount : "0", } } ``` --- ### Multi-Condition with DayTrade multiConditionDayTrade Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | endTime | string | End time of parent order | | multi-condition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | orderObject | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fixSession | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Requst Example[​](#requst-example "Direct link to Requst Example") ```js // Condition Content const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const condition2 = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.TotalQuantity, triggerValue: "8000", comparison: Operator.GreaterThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock } const daytrade_obj = { dayTradeEndTime : "131000", // Position covering time, valid range between 130100 ~ 132000 autoCancel : true, price : "", priceType : ConditionPriceType.Market } const tp = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, targetPrice: "85", price: "85", } const sl = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, target_price: "60", price: "60", } const tpsl = { stopSign: StopSign.Full, endDate: "20240517", tp: tp, sl: sl, intraday: true // ** Must set true to enable daytrade } sdk.stock.multiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, true) // Not Setting TPSL // sdk.stock.multiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, true) // Not Setting Fix Session Covering // sdk.stock.multiConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, false) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition with DayTrade singleConditionDayTrade Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | endTime | string | End time of parent order | | condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | Condition Content | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | orderObject | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditiondaytrade-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fixSession | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Requst Example[​](#requst-example "Direct link to Requst Example") ```js // Condition Content const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock } const daytrade_obj = { dayTradeEndTime : "131000", // Position covering time, valid range between 130100 ~ 132000 autoCancel : true, price : "", priceType : ConditionPriceType.Market } const tp = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, targetPrice: "85", price: "85", } const sl = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, target_price: "60", price: "60", } const tpsl = { stopSign: StopSign.Full, endDate: "20240517", tp: tp, sl: sl, intraday: true // ** Must set true to enable daytrade } sdk.stock.singleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, true) // Not Setting TPSL // sdk.stock.singleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, true) // Not Setting Fix Session Covering // sdk.stock.singleConditionDayTrade(account, StopSign.Full, "130000", condition, order, daytrade_obj, null, false) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------- | | marketType | TradingType | [Trading Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 、`Time` | | triggerValue | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When using `Reference`, trigger can be `BidPrice` 、 `AskPrice` 、 `MatchedPrice` 、 `TotalQuantity` or `Time`. If the trigger is `Time`, then the order would be triggered if the time condition is true and the reference product has actully trade happened with in the time range. 2. When selecting `Scheduled`, symbol should be empty "", and the trigger must be `Time`. It would use the system time to determine if the order to be triggered when the time condition is true. ##### ConditionOrder Object[​](#conditionorder-object "Direct link to ConditionOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | buySell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | marketType | ConditionMarketType | [Trading Session](#conditionmarkettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd` | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Reference Price (Flat Price))、`MatchedPrice` current market price | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | orderType | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | ##### TPSLOrder Object[​](#tpslorder-object "Direct link to TPSLOrder Object") | Parameter | Type | Meaning | | ------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | timeInForce | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | priceType | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Flat Price、`MatchedPrice` current market price | | orderType | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | | targetPrice | string | Take Profit / Stop Loss Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger (optional) | TriggerContent | Take Profit / Stop Loss [TriggerContent](#triggercontent) (details below) | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` **OR** Ommit the price field (>= ver. 2.2.4) TP/SL Trigger Content New parameter added since v2.2.0 (***v2.1.1 and earlier version do not have this parameter***). This can be used to set the trigger price type for take-profit/stop-loss order. The price type can be one of the follows: 1. MatchedPrice, 2. BidPrice, 3. AskPrice If the parameter is not set manually, the function use the default value MatchedPrice. ##### TPSLWrapper Object[​](#tpslwrapper-object "Direct link to TPSLWrapper Object") | Parameter | Type | Meaning | | --------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stopSign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | TPSLOrder Object (Optional) | TP Object | | sl | TPSLOrder Object (Optional) | SL Object | | endDate | string (Optional : null equals Condition startDate) | TP / SL EndDate | | intraday | bool (Optional) | When Fully Filled Then Execuate DayTrade | Day trade `intraday` must set to `true` when using with daytrade condition order ##### TrailOrder[​](#trailorder "Direct link to TrailOrder") | Parameter | Type | Meaning | | ----------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | symbol | string | symbol | | price | string | Activate Price (Note. Can only take up to two decimal places, otherwise it will fail to be activated.) | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | percentage | int | Up / down percentage | | buysell | BSAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | quantity | int | Order Quantity | | priceType | ConditionPriceType | [PriceType](#conditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Reference Price (Flat Price) | | diff | int | Buy / Sell Ticker ( Base on priceType up / down) | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | orderType | ConditionOrderType | [OrderType](#conditionordertype) Valid `Stock` Common Stock、`Margin` 、`Short` Short Sale | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | -------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order
`Type2` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders (seconds) | | singleQuantity | int | Single Order Shares | | totalQuantity | int (Optional) | Total Order Shares | | startTime | string | Start Time | | endTime | string (Optional) | End Time | caution `totalQuantity` must be greater than `singleQuantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | ##### ConditionDayTrade Object[​](#conditiondaytrade-object "Direct link to ConditionDayTrade Object") | Parameter | Type | Meaning | | --------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------- | | dayTradeEndTime | string | The time to start covering the open position. Format: "HHMMSS" (e.g., "131000") | | autoCancel | bool | Cancel the triggered entry order when the end time of the parent order is reached | | price | string | The order price (for price types that do not require the input, please use the empty string "") | | priceType | [ConditionPriceType](#conditionpricetype) | The price type | About day Trade End Time Valid time range is 130100 ~ 132000 #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BsAction[​](#bsaction "Direct link to BsAction") | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### ConditionMarketType[​](#conditionmarkettype "Direct link to ConditionMarketType") Trading Session Type | Name | Meaning | | ----------- | ---------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Scheduled | Time | | Index | Index | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | ------------- | -------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down/ (direction) | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Type1 | Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order | | Type2 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### ConditionPriceType[​](#conditionpricetype "Direct link to ConditionPriceType") PriceType (ConditionPriceType) | Name | Meaning | | ------------ | ---------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | ##### ConditionOrderType[​](#conditionordertype "Direct link to ConditionOrderType") OrderType (ConditionOrderType) | Name | Meaning | | ------ | ------------ | | Stock | Common Stock | | Margin | Margin | | Short | Short Sale | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid getConditionOrderById #### Request[​](#request "Direct link to Request") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getConditionOrderById(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: { guid : "8ff3472b-185a-488c-be5a-b478deda080c", orderLevel : "1", lastTime : "2024-03-14 12:39:02", conditionType : "多條件", parentGuid : "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:39:22", startDate : "2024/03/14", status : "未生效(W)", detailRecordsCount : "0", tpslCount : "0", } } ``` --- ### Query Condition History getConditionHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | | condition\_history\_status | [History Status](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#historystatus) (Optional) | Status of History Condition | info The date is based on the creation date of the condition order #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess : false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getConditionHistory(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: [ { guid : "8ff3472b-185a-488c-be5a-b478deda080c", orderLevel : "1", lastTime : "2024-03-14 12:39:02", conditionType : "多條件", parentGuid : "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:39:22", startDate : "2024/03/14", status : "未生效(W)", detailRecordsCount : "0", tpslCount : "0", }, { guid : "ec757279-bcb3-46f4-80ac-fccfc786bc8d", orderLevel : "0", lastTime : "2024-05-21 10:30:00", conditionType : "多條件", parentGuid : "ec757279-bcb3-46f4-80ac-fccfc786bc8d", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止", action : "下單(當沖)", conditionBuySell : "現股買", conditionSymbol : "台積電 現股買", conditionPrice : "576元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:30:02", startDate : "2024/03/14", status : "觸發-委託失敗(X)", errorMessage : "單價輸入錯誤[4385715]", detailRecordsCount : "0", tpslCount : "2", tpslRecord : [ { guid : "c94b552a-22da-43e4-be44-f27a9c2026e1", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", startDate : "2024/03/14", status : "未生效(W)", }, { guid : "c94b552a-22da-43e4-be44-f27a9c2026e1", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "市價(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", startDate : "2024/03/14", status : "未生效(W)", }, ] } ] } ``` --- ### Get Condition Order getConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | conditionStatus | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getConditionOrder(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: [ { guid : "8ff3472b-185a-488c-be5a-b478deda080c", orderLevel : "1", lastTime : "2024-03-14 12:39:02", conditionType : "多條件", parentGuid : "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:39:22", startDate : "2024/03/14", status : "未生效(W)", detailRecordsCount : "0", tpslCount : "0", }, { guid : "ec757279-bcb3-46f4-80ac-fccfc786bc8d", orderLevel : "0", lastTime : "2024-05-21 10:30:00", conditionType : "多條件", parentGuid : "ec757279-bcb3-46f4-80ac-fccfc786bc8d", symbol : "2330", orderAmount : "0", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止", action : "下單(當沖)", conditionBuySell : "現股買", conditionSymbol : "台積電 現股買", conditionPrice : "576元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", createTime : "2024-03-14 12:30:02", startDate : "2024/03/14", status : "觸發-委託失敗(X)", errorMessage : "單價輸入錯誤[4385715]", detailRecordsCount : "0", tpslCount : "2", tpslRecord : [ { guid : "c94b552a-22da-43e4-be44-f27a9c2026e1", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "580元(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", startDate : "2024/03/14", status : "未生效(W)", }, { guid : "c94b552a-22da-43e4-be44-f27a9c2026e1", account : "1307515", conditionContent : "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action : "下單(次日回補)", conditionBuySell : "現股賣", conditionSymbol : "台積電 現股賣", conditionPrice : "市價(ROD)", conditionVolume : "5張", conditionFilledVolume : "0張", startDate : "2024/03/14", status : "未生效(W)", }, ] } ] } ``` --- ### Multi-Condition multiCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // 設計條件內容 const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const condition2 = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.TotalQuantity, triggerValue: "8000", comparison: Operator.GreaterThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; sdk.stock.multiCondition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Multi-Condition with TP & SL multiCondition info TP & SL will be activated after the master order has been fully filled. Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const condition2 = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.TotalQuantity, triggerValue: "8000", comparison: Operator.GreaterThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; const tp = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Close, targetPrice: "120", price: "120", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const sl = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Close, targetPrice: "60", price: "60", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517", // optional field intraday: false // optional field } sdk.stock.multiCondition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order, tpsl) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition singleCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // 設計條件內容 const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; sdk.stock.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition with TP & SL singleCondition info TP & SL will be activated after the master order has been fully filled. Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Condition Start Date | | endDate | string | Condition End Date | | stopSign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | condition object | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | orderObject | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Requst Example[​](#requst-example "Direct link to Requst Example") ```js // Condition Content const condition = { marketType: TradingType.Reference, symbol: "2881", trigger: TriggerContent.MatchedPrice, triggerValue: "80", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; const tp = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, targetPrice: "85", price: "85", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const sl = { timeInForce: TimeInForce.ROD, priceType: ConditionPriceType.Limit, orderType: ConditionOrderType.Stock, target_price: "60", price: "60", // trigger: TriggerContent.MatchPrice // Added since v2.2.0 } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517", // optional field intraday: false // optional field } sdk.stock.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Get Time Slice Order getTimeSliceOrder #### Request[​](#request "Direct link to Request") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | batchNo | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getTimeSliceOrder(account,"1234567") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: { guid: "c4dc90c1-4277-42ea-b585-085dc347eac0", batchNo: "", orderLevel: "0", lastTime: "2024-07-23 17:30:01", conditionType: "分時分量", parentGuid: "", symbol: "2881", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "當於2024/07/23 定時單時間大於等於08:40:00 全部成交為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "富邦金 現股買", conditionPrice: "66元(ROD)", conditionVolume: "1張", conditionFilledVolume: "0張", createTime: "2024-07-22 17:30:03", startDate: "2024/07/23", status: "條件單中止(I)", errorMessage: null, detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], }, { guid: "2975702e-f36f-4da4-bab6-1310344ec05d", batchNo: "", orderLevel: "0", lastTime: "2024-07-23 17:30:01", conditionType: "分時分量", parentGuid: "", symbol: "2881", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "當於2024/07/23 定時單時間大於等於09:10:00 全部成交為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "富邦金 現股買", conditionPrice: "66元(ROD)", conditionVolume: "1張", conditionFilledVolume: "0張", createTime: "2024-07-22 17:30:03", startDate: "2024/07/23", status: "條件單中止(I)", errorMessage: null, detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], } } ``` --- ### Time Slice COndition timesliceCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | splitDescription | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#splitdescription) | Split Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Condition Content const split = { method: TimeSliceOrderType.Type1, interval: 300, singleQuantity: 1000, totalQuantity: 10000, startTime: '083000' }; const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: ConditionMarketType.Common, priceType: ConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; sdk.stock.timeSliceOrder(target_account, "20240427","20240516", StopSign.Full, split, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "24080500000002" } } ``` --- ### Query Trail HIstory getTrailHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess : false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getTrailHistory(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: [ { guid: "5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e", batchNo: "", orderLevel: "0", lastTime: "2024-08-02 16:45:01", symbol: "2889", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "國票金 (2889)", conditionPrice: "成交價(1) 檔(ROD)", conditionVolume: "1張", conditionFilledVolume: "0張", createTime: "2024-08-02 10:07:31", startDate: "2024/08/02", status: "條件單中止(I)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], }, { guid: "c71117c8-aa70-4477-9f04-ff4c73a4fad0", batchNo: "", orderLevel: "0", lastTime: "2024-07-29 17:30:00", symbol: "2330", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "台積電 (2330)", conditionPrice: "成交價(5) 檔(ROD)", conditionVolume: "2張", conditionFilledVolume: "0張", createTime: "2024-07-29 11:01:49", startDate: "2024/07/29", status: "條件單中止(I)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], } ] } ``` --- ### Get Trail Order getTrailOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.getTrailOrder(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: [ { guid: "5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e", batchNo: "", orderLevel: "0", lastTime: "2024-08-02 16:45:01", symbol: "2889", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "國票金 (2889)", conditionPrice: "成交價(1) 檔(ROD)", conditionVolume: "1張", conditionFilledVolume: "0張", createTime: "2024-08-02 10:07:31", startDate: "2024/08/02", status: "條件單中止(I)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], }, { guid: "c71117c8-aa70-4477-9f04-ff4c73a4fad0", batchNo: "", orderLevel: "0", lastTime: "2024-07-29 17:30:00", symbol: "2330", orderAmount: "0", childBatchNo: "", account: "1307515", conditionContent: "從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止", action: "下單", conditionBuySell: "現股買", conditionSymbol: "台積電 (2330)", conditionPrice: "成交價(5) 檔(ROD)", conditionVolume: "2張", conditionFilledVolume: "0張", createTime: "2024-07-29 11:01:49", startDate: "2024/07/29", status: "條件單中止(I)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], } ] } ``` --- ### Trail Profit Condition TrailProfit #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [Trail Order](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#trailorder) | Trail Order Condition | caution The activate price in TrailOrder can only take up to two decimal places, otherwise it will fail to be activated. info The order will be placed when the current price hit the trigger price (the activate price up/down to the setting percentage) **Example.** If the activate price is set to 100, and the stop loss/gain condiition is set as 5% down, so the initial trigger price is 95. Assuming that the price never go above 100 (so that the activate price does not move upward), then the stop loss/gain order will be placed when the market price hit 95. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // condition content const trail = { symbol: "2330", price: "860", direction: Direction.Down, percentage: 5, buysell: BSAction.Sell, quantity: 2000, priceType: ConditionPriceType.MatchedPrice, diff: 5, timeInForce: TimeInForce.ROD, orderType: ConditionOrderType.Stock }; ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, data :{ guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Cancel Condition cancel\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.cancel_condition(target_account, "44150047-8977-40b1-953c-ce270f0000") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { advisory : "成功筆數:1,失敗筆數:0!" } } ``` --- ### Get Condition Daytrade get\_condition\_daytrade\_by\_id #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_condition_daytrade_by_id(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], } } ``` --- ### Multi-Condition with DayTrade multi\_condition\_day\_trade Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | end\_time | string | End time of parent order | | multi\_condition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fix\_session | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py #from fubon_neo.sdk import ConditionDayTrade # Condition Content condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "66", comparison = Operator.LessThan ) condition2 = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.TotalQuantity, trigger_value = "8000", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock, ) daytrade_obj = ConditionDayTrade( day_trade_end_time = "131500", # Position covering time, valid range between 130100 ~ 132000 auto_cancel= True, price = "", price_type=ConditionPriceType.Market ) tp = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="85", price="85", ) sl = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="60", price="60", ) tpsl = TPSLWrapper( stop_sign= StopSign.Full, end_date="20240517", tp=tp, sl=sl, intraday=True # ** Must set true to enable daytrade ) sdk.stock.multi_condition_day_trade(account, StopSign.Full, "130000", [condition, condition2], order, daytrade_obj, tpsl, True) # Not Setting TPSL # sdk.stock.multi_condition_day_trade(account, StopSign.Full, "130000", [condition, condition2], order, daytrade_obj, None, True) # Not Setting Fix Session Covering # sdk.stock.multi_condition_day_trade(account, StopSign.Full, "130000", [condition, condition2], order, daytrade_obj, tpsl, False) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition with DayTrade single\_condition\_day\_trade Stop-loss Take Precautions * The stop-loss take pre-order setting is only a trigger for the order and does not guarantee a successful cover. It must be adjusted based on market conditions. * Please ensure that the stop-loss take pre-order **order type** setting complies with day trading rules. Day Trading Order Query * To query day trading orders using a GUID, please use the ***Day Trading Order Query*** function. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | end\_time | string | End time of parent order | | Condition Object | [Condition Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | ConditionDayTrade Object | [ConditionDayTrade](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditiondaytrade-object) | DayTrade Content | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | | fix\_session | bool | Fix Session Covering | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py #from fubon_neo.sdk import ConditionDayTrade # Condition COntent condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "66", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) daytrade_obj = ConditionDayTrade( day_trade_end_time = "131500", # Position covering time, valid range between 130100 ~ 132000 auto_cancel= True, price = "", price_type=ConditionPriceType.Market ) tp = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="85", price="85", ) sl = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="60", price="60", ) tpsl = TPSLWrapper( stop_sign= StopSign.Full, end_date="20240517", tp=tp, sl=sl, intraday=True # ** Must set True to enable daytrade ) sdk.stock.single_condition_day_trade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, True) # Not Setting TPSL # sdk.stock.single_condition_day_trade(account, StopSign.Full, "130000", condition, order, daytrade_obj, None, True) # Not Setting Fix Session Covering # sdk.stock.single_condition_day_trade(account, StopSign.Full, "130000", condition, order, daytrade_obj, tpsl, False) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | -------------- | -------------- | ------------------------------------------------------------------------------------------------------------------- | | market\_type | TradingType | [Trading Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 、`Time` | | trigger\_value | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When using `Reference`, trigger can be `BidPrice` 、 `AskPrice` 、 `MatchedPrice` 、 `TotalQuantity` or `Time`. If the trigger is `Time`, then the order would be triggered if the time condition is true and the reference product has actully trade happened with in the time range. 2. When selecting `Scheduled`, symbol should be empty "", and the trigger must be `Time`. It would use the system time to determine if the order to be triggered when the time condition is true. ##### ConditionOrder Object[​](#conditionorder-object "Direct link to ConditionOrder Object") | Parameter | Type | Meaning | | --------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | buy\_sell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | market\_type | ConditionMarketType | [Trading Session](#conditionmarkettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd` | | price\_type | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | order\_type | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | ##### TPSLOrder Object[​](#tpslorder-object "Direct link to TPSLOrder Object") | Parameter | Type | Meaning | | ------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | time\_in\_force | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | price\_type | ConditionPriceType | [Price Type](#conditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price | | order\_type | ConditionOrderType | [Order Type](#conditionordertype) valid in : `Stock`、`Margin`、`Short` | | target\_price | string | Take Profit / Stop Loss Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger (optional) | TriggerContent | Take Profit / Stop Loss [TriggerContent](#triggercontent) (details below) | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` **OR** `None` (>= ver. 2.2.4) TP/SL Trigger Content New parameter added since v2.2.0 (***v2.1.1 and earlier version do not have this parameter***). This can be used to set the trigger price type for take-profit/stop-loss order. The price type can be one of the follows: 1. MatchedPrice, 2. BidPrice, 3. AskPrice If the parameter is not set manually, the function use the default value MatchedPrice. ##### TPSLWrapper Object[​](#tpslwrapper-object "Direct link to TPSLWrapper Object") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stop\_sign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | TPSLOrder Object (Optional) | TP Object | | sl | TPSLOrder Object (Optional) | SL Object | | end\_date | string (Optional : null equals Condition startDate) | TP / SL EndDate | | intraday | bool (Optional) | When Fully Filled Then Execuate Intraday DayTrade | Day trade `intraday` must set to `True` when using with daytrade condition order ##### TrailOrder[​](#trailorder "Direct link to TrailOrder") | Parameter | Type | Meaning | | --------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | symbol | string | symbol | | price | string | Activate Price (Note. Can only take up to two decimal places, otherwise it will fail to be activated.) | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | percentage | int | Up / down percentage | | buy\_sell | BSAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | quantity | int | Order Quantity | | price\_type | ConditionPriceType | [PriceType](#conditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Reference Price (Flat Price) | | diff | int | Buy / Sell Ticker ( Base on priceType up / down) | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | order\_type | ConditionOrderType | [OrderType](#conditionordertype) Valid `Stock` Common Stock、`Margin` 、`Short` Short Sale | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `single_quantity` shares per order
`Type2` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders (seconds) | | single\_quantity | int | Single Order Shares | | total\_quantity | int (Optional) | Total Order Shares | | start\_time | string | Start Time | | end\_time | string (Optional) | End Time | caution `totalQuantity` must be greater than `single_quantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | ##### ConditionDayTrade Object[​](#conditiondaytrade-object "Direct link to ConditionDayTrade Object") | Parameter | Type | Meaning | | --------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------- | | dayTradeEndTime | string | The time to start covering the open position. Format: "HHMMSS" (e.g., "131000") | | autoCancel | bool | Cancel the triggered entry order when the end time of the parent order is reached | | price | string | The order price (for price types that do not require the input, please use the empty string "") | | price\_type | [ConditionPriceType](#conditionpricetype) | The price type | About day Trade End Time Valid time range is 130100 ~ 132000 #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BsAction[​](#bsaction "Direct link to BsAction") | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### ConditionMarketType[​](#conditionmarkettype "Direct link to ConditionMarketType") Trading Session Type | Name | Meaning | | ----------- | ---------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Scheduled | Time | | Index | Index | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | ------------- | -------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down/ (direction) | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Type1 | Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `single_quantity` shares per order | | Type2 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### ConditionPriceType[​](#conditionpricetype "Direct link to ConditionPriceType") PriceType (ConditionPriceType) | Name | Meaning | | ------------ | ---------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | ##### ConditionOrderType[​](#conditionordertype "Direct link to ConditionOrderType") OrderType (ConditionOrderType) | Name | Meaning | | ------ | ------------ | | Stock | Common Stock | | Margin | Margin | | Short | Short Sale | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid get\_condition\_order\_by\_id #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | guid | string | Condition Sequence Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_condition_order_by_id(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], } } ``` --- ### Get Condition History get\_condition\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | | condition\_history\_status | [History Status](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#historystatus) (Optional) | Status of Condition History | info The date is based on the creation date of the condition order #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_condition_history(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], }, ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "市價(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], }, ConditionDetail { guid: "ec757279-bcb3-46f4-80ac-fccfc786bc8d", batch_no: "", order_level: "0", last_time: "2024-05-21 10:30:00", condition_type: "多條件", parent_guid: "ec757279-bcb3-46f4-80ac-fccfc786bc8d", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止", action: "下單(當沖) ", condition_buy_sell: "現股買", condition_symbol: "台積電 現股買", condition_price: "576元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:30:02", start_date: "2024/03/14", status: "觸發-委託失敗(X)", error_message: "單價輸入錯誤[4385715]", detail_records_count: "0", detail_records: [], tpslCount: "2", tpslRecord: [ ParentChildRecord { guid: "c94b552a-22da-43e4-be44-f27a9c2026e1", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", start_date: "2024/03/14", status: "未生效(W)", error_message: "", }, ParentChildRecord { guid: "c94b552a-22da-43e4-be44-f27a9c2026e1", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "市價(ROD)", condition_volume: "5張", condition_filled_volume: "0張", start_date: "2024/03/14", status: "未生效(W)", error_message: "", }, ], } ] } ``` --- ### Get Condition Order get\_condition\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | condition\_status | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_condition_order(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], }, ConditionDetail { guid: "8ff3472b-185a-488c-be5a-b478deda080c", batch_no: "", order_level: "1", last_time: "2024-03-14 12:39:02", condition_type: "多條件", parent_guid: "58e7a51e-9701-4d26-bc16-18a392a840bd", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "市價(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:39:22", start_date: "2024/03/14", status: "未生效(W)", error_message: None, detail_records_count: "0", detail_records: [], tpslCount: "0", tpslRecord: [], }, ConditionDetail { guid: "ec757279-bcb3-46f4-80ac-fccfc786bc8d", batch_no: "", order_level: "0", last_time: "2024-05-21 10:30:00", condition_type: "多條件", parent_guid: "ec757279-bcb3-46f4-80ac-fccfc786bc8d", symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於575元,且 台積電成交總量大於等於1001張,且 台積電時間大於等於10:30:00 部份成交為止", action: "下單(當沖) ", condition_buy_sell: "現股買", condition_symbol: "台積電 現股買", condition_price: "576元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", creat_time: "2024-03-14 12:30:02", start_date: "2024/03/14", status: "觸發-委託失敗(X)", error_message: "單價輸入錯誤[4385715]", detail_records_count: "0", detail_records: [], tpslCount: "2", tpslRecord: [ ParentChildRecord { guid: "c94b552a-22da-43e4-be44-f27a9c2026e1", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價大於等於580元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "580元(ROD)", condition_volume: "5張", condition_filled_volume: "0張", start_date: "2024/03/14", status: "未生效(W)", error_message: "", }, ParentChildRecord { guid: "c94b552a-22da-43e4-be44-f27a9c2026e1", account: "1307515", condition_content: "當自2024/03/14至2024/07/04內台積電成交價小於等於570元 全部成交為止", action: "下單(次日回補) ", condition_buy_sell: "現股賣", condition_symbol: "台積電 現股賣", condition_price: "市價(ROD)", condition_volume: "5張", condition_filled_volume: "0張", start_date: "2024/03/14", status: "未生效(W)", error_message: "", }, ], } ] } ``` --- ### Multi-Condition multi\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "80", comparison = Operator.LessThan ) condition2 = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.TotalQuantity, trigger_value = "8000", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) sdk.stock.multi_condition(account, "20240426", "20240430", StopSign.Full, [condition, condition2], order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f0000" } } ``` --- ### Multi-Condition with TP & SL multi\_condition info TP & SL will be activated after the master order has been fully filled. Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition :`Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | List of Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # 設計條件內容 condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "66", comparison = Operator.LessThan ) condition2 = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.TotalQuantity, trigger_value = "8000", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) tp = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="85", price="85", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) sl = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="60", price="60", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) tpsl = TPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517", # optional field intraday=False # optional field ) sdk.stock.multi_condition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f0000" } } ``` --- ### Single Condition single\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition Object | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Resquest Example[​](#resquest-example "Direct link to Resquest Example") ```py # Condition Content condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "80", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell= BSAction.Sell, symbol = "2881", quantity = 1000, price = "60", market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) res = sdk.stock.single_condition(account, "2024/04/27","2024/05/16", StopSign.Full , condition, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f36150", } } ``` --- ### Single Condition with TP & SL single\_condition info TP & SL will be activated after the master order has been fully filled. Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition Object | [Condition Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | Condition Content | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | | TPSL | [TPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#tpslwrapper-object) | TPSL ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition COntent condition = Condition( market_type = TradingType.Reference, symbol = "2881", trigger = TriggerContent.MatchedPrice, trigger_value = "66", comparison = Operator.LessThan ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) tp = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="85", price="85", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) sl = TPSLOrder( time_in_force=TimeInForce.ROD, price_type=ConditionPriceType.Limit, order_type=ConditionOrderType.Stock, target_price="60", price="60", # trigger=TriggerContent.MatchedPrice # Added since v2.2.0 ) tpsl = TPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517", # optional field intraday=False # optional field ) sdk.stock.single_condition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Get Time Slice Order get\_time\_slice\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ---------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | batch\_no | string | Condition Order Number | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_time_slice_order(account,"1234567") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionDetail { guid: "c4dc90c1-4277-42ea-b585-085dc347eac0", batch_no: "", order_level: "0", last_time: "2024-07-23 17:30:01", condition_type: "分時分量", parent_guid: "", symbol: "2881", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當於2024/07/23 定時單時間大於等於08:40:00 全部成交為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "富邦金 現股買", condition_price: "66元(ROD)", condition_volume: "1張", condition_filled_volume: "0張", create_time: "2024-07-22 17:30:03", start_date: "2024/07/23", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], }, ConditionDetail { guid: "2975702e-f36f-4da4-bab6-1310344ec05d", batch_no: "", order_level: "0", last_time: "2024-07-23 17:30:01", condition_type: "分時分量", parent_guid: "", symbol: "2881", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "當於2024/07/23 定時單時間大於等於09:10:00 全部成交為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "富邦金 現股買", condition_price: "66元(ROD)", condition_volume: "1張", condition_filled_volume: "0張", create_time: "2024-07-22 17:30:03", start_date: "2024/07/23", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } } ``` --- ### Time Slice Condition timeslice\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | split\_description | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#condition-object) | Split Condition | | ConditionOrder Object | [ConditionOrder Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionorder-object) | ConditionOrder Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content split = SplitDescription( method=TimeSliceOrderType.Type1, interval=300, single_quantity=1000, total_quantity=10000, start_time='083000' ) order = ConditionOrder( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = ConditionMarketType.Common, price_type = ConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock ) sdk.stock.time_slice_order(target_account, "20240427","20240516", StopSign.Full, split, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "24080500000002" } } ``` --- ### Get Trail History get\_trail\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_trail_order(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e", batch_no: "", order_level: "0", last_time: "2024-08-02 16:45:01", condition_type: None, parent_guid: None, symbol: "2889", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "國票金 (2889)", condition_price: "成交價(1) 檔(ROD)", condition_volume: "1張", condition_filled_volume: "0張", create_time: "2024-08-02 10:07:31", start_date: "2024/08/02", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], }, ConditionDetail { guid: "c71117c8-aa70-4477-9f04-ff4c73a4fad0", batch_no: "", order_level: "0", last_time: "2024-07-29 17:30:00", condition_type: None, parent_guid: None, symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "台積電 (2330)", condition_price: "成交價(5) 檔(ROD)", condition_volume: "2張", condition_filled_volume: "0張", create_time: "2024-07-29 11:01:49", start_date: "2024/07/29", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } ] } ``` --- ### Get Trail Order get\_trail\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_trail_order(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "5c154a76-e7ef-4b8f-94b5-80bf08fa4b8e", batch_no: "", order_level: "0", last_time: "2024-08-02 16:45:01", condition_type: None, parent_guid: None, symbol: "2889", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "從2024/08/02到2024/08/02內當國票金從1000(原始基準價),下跌達10%,持續至預定張數全部成交或期限到達為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "國票金 (2889)", condition_price: "成交價(1) 檔(ROD)", condition_volume: "1張", condition_filled_volume: "0張", create_time: "2024-08-02 10:07:31", start_date: "2024/08/02", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], }, ConditionDetail { guid: "c71117c8-aa70-4477-9f04-ff4c73a4fad0", batch_no: "", order_level: "0", last_time: "2024-07-29 17:30:00", condition_type: None, parent_guid: None, symbol: "2330", order_amount: "0", child_batch_no: "", account: "1307515", condition_content: "從2024/07/29到2024/07/29內當台積電從860(原始基準價),上漲達5%,持續至預定張數全部成交或期限到達為止", action: "下單", condition_buy_sell: "現股買", condition_symbol: "台積電 (2330)", condition_price: "成交價(5) 檔(ROD)", condition_volume: "2張", condition_filled_volume: "0張", create_time: "2024-07-29 11:01:49", start_date: "2024/07/29", status: "條件單中止(I)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } ] } ``` --- ### Trail Profit Condition trail\_profit #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [Trail Order](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#trailorder) | Trail Order Condition | caution The activate price in TrailOrder can only take up to two decimal places, otherwise it will fail to be activated. info The order will be placed when the current price hit the trigger price (the activate price up/down to the setting percentage) **Example.** If the activate price is set to 100, and the stop loss/gain condiition is set as 5% down, so the initial trigger price is 95. Assuming that the price never go above 100 (so that the activate price does not move upward), then the stop loss/gain order will be placed when the market price hit 95. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content trail = TrailOrder( symbol ="2330", baseprice = "860", direction = Direction.Up, percentage = 5, # Up or Down Percent buy_sell = BSAction.Buy, quantity = 2000, price_type = ConditionPriceType.MatchedPrice, diff = 5, # base price ticker (negative represent down) time_in_force = TimeInForce.ROD, order_type = ConditionOrderType.Stock, ) sdk.stock.trail_profit(target_account, "20240427","20240516", StopSign.Full, trail) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py { is_success : True, message : None, data : ConditionOrderResult { guid : 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Preparation Key takeaways * Read the usage guide and sign the agreement before using condition orders. * Upgrade SDK to v1.3 or later. * Import condition order packages for Python / Node.js. | Item | Details | | ------------- | --------------------------------------- | | Product | Fubon Neo API Condition Order | | Prerequisites | Read guide, Sign agreement, Upgrade SDK | | Languages | Python / C# / JavaScript (Node.js) | | Import | Extra import required for Python / JS | caution Before starting with the Fubon Neo Condition API, please read the [**user agreement**](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/Agreements.md) carefully and complete signing the agreements. #### Sign the agreement[​](#sign-the-agreement "Direct link to Sign the agreement") Sign the agreement 1. Open `富邦Online` APP and select more.
![線上簽署](/TradeAPI/en/assets/images/signagree1-344762a81c78861fa652f3bd8d11d735.png) 2. Click `M櫃台`
![線上簽署2](/TradeAPI/en/assets/images/signagree2-f228860054133c73f3f12e482545cc55.png) 3. Choice `條件單同意書` and sign agreements.
![線上簽署3](/TradeAPI/en/assets/images/signagree3-ea03b7b52731323e65fe28d393dd2432.png) #### Upgrade SDK, version should be above v1.3.1[​](#upgrade-sdk-version-should-be-above-v131 "Direct link to Upgrade SDK, version should be above v1.3.1") SDK lastest version : [下載連結](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md) #### Import Constant ( Only require for Python、NodeJs)[​](#import-constant--only-require-for-pythonnodejs "Direct link to Import Constant ( Only require for Python、NodeJs)") Add Condition Package * Python * Node.js ```py from fubon_neo.sdk import FubonSDK, Condition, ConditionDayTrade, ConditionOrder from fubon_neo.constant import ( TriggerContent, TradingType, Operator, TPSLOrder, TPSLWrapper, SplitDescription, StopSign, TimeSliceOrderType, ConditionMarketType, ConditionPriceType, ConditionOrderType, TrailOrder, Direction, ConditionStatus, HistoryStatus ) ``` ```js const { FubonSDK, TriggerContent, TradingType, Operator, TPSLOrder, TPSLWrapper, SplitDescription, StopSign, TimeSliceOrderType, ConditionMarketType, ConditionPriceType, ConditionOrderType, TrailOrder, Direction, ConditionStatus, HistoryStatus } = require('fubon-neo'); ``` info Condition orders currently do not support mixing future/options and spot products. --- ### Emergency contingency In the event of force majeure or system abnormalities that prevent order placement or confirmation of order execution, please use other platforms as a backup. Alternative platforms for condition orders: * HTS2 * Online APP * Sales representative For more information, please refer to the Fubon Securities official website under [Contingency Measures for Unavailability of Online Trading Systems](https://www.fbs.com.tw/Beginner/TradingNote) --- ### TP & SL Condition Fubon Neo API supports TP & SL orders. Take-Profit and Stop-Loss Mechanism: Once a triggered condition order is executed, the stop-loss and take-profit monitoring mechanism will be activated. When the take-profit condition is met, the stop-loss will be deactivated; conversely, if the stop-loss condition is met, the take-profit will be deactivated (similar to the commonly known OCO mechanism). ![TPSL](/TradeAPI/en/assets/images/TPSL-c929bfde158264f3327c48f316c32bde.png) #### 程式範例[​](#程式範例 "Direct link to 程式範例") * Python * Node.js * C# ```py # 設計條件內容 condition = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.MatchedPrice, trigger_value = "100", comparison = Operator.LessThan ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "100", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) tp = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="85", price="85" ) sl = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="60", price="60" ) tpsl = FutOptTPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517" ) sdk.futopt.single_condition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` ```js // 設計條件內容 const condition = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.MatchedPrice, triggerValue: "100", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "100", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; const tp = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "120", price: "120" } const sl = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "60", price: "60" } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517" } sdk.futopt.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` ```cs // 設計條件內容 var condition = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.MatchedPrice, "100", Operator.LessThan ); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); var tp = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "120", "120", null // For version >= 2.2.0, no actual function yet ); var sl = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "85", "85", null // For version >= 2.2.0, no actual function yet ); var tpsl = new FutOptTpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.FutOpt.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl); ``` --- ### Trail Profit Condition Fubon Neo API supports trail profit orders. Trailing Profit Mechanism: After the initial condition is triggered, the order will not be activated if the set pullback range is not reached. As the stock price continues to rise, the new price will be used as the benchmark. If the pullback range reaches the set value at this point, the order will be submitted. ![trailProfit](/TradeAPI/en/assets/images/TrailProfit-879410a639013d6d0bebcf9647e4d1fe.png) ##### 程式範例[​](#程式範例 "Direct link to 程式範例") * Python * Node.js * C# ```py # 設計條件內容 trail = FutOptTrailOrder( symbol = "TXFL4", price = "22000", direction = Direction.Up , tick_num = 5, # 漲跌 tick 數 buy_sell = BSAction.Sell, lot = 2, price_type = FutOptConditionPriceType.MatchedPrice, diff = 1, # 向上 or 向下追買 tick數 (向下為負值) time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.Close ) sdk.futopt.trail_profit(target_account, "20240427","20240516", StopSign.Full, trail) ``` ```js // 設計條件內容 const trail = { symbol: "TXO20000E4", price: "1050", direction: Direction.Down, tickNum: 5, buysell: BSAction.Sell, lot: 2, priceType: FutOptConditionPriceType.MatchedPrice, diff: 1, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.Close }; sdk.futopt.trailProfit(target_account, "20240427","20240516", StopSign.Full, trail) ``` ```cs // 設計條件內容 var trail = new FutOptTrailOrder( "TXO20000E4", "1050", Direction.Up , 5, // 漲跌 tick 數 BsAction.Buy, 2, FutOptConditionPriceType.MatchedPrice, 1, // 向上 or 向下追買 tick數 (向下為負值) TimeInForce.Rod, FutOptConditionOrderType.Close ); sdk.FutOpt.TrailProfit(target_account, "20240427","20240516", StopSign.Full, trail); ``` --- ### Condition Order Agreements 本公司為服務投資人,提供網路下單客戶得預先設定下單條件之條件下單功能服務(以下簡稱本功能或本服務)。本服務不收取任何費用,但本公司保留得隨時調整、修正、暫停或終止此項服務之權利;為確保使用者權益及網路交易安全秩序,請投資人於啟用本功能前,詳細閱讀以下條款,以保障投資人的權利,在投資人點選本使用同意書下方之同意鈕,即視為已經詳閱並接受本同意書之內容。
一、條件下單功能服務具有以下(但不限於此)之風險,投資人應自承以下風險所衍生之損害或損失: 1 網際網路之傳輸通訊,可能因不可抗力或不可歸責於本公司之事由,包括(但不在此限)斷電、斷線、網路壅塞等因素,導致資料傳輸延遲、停滯、無法發出或無法接收。
2 本功能或服務有可能因病毒、系統或機件發生故障、錯誤、執行障礙,駭客入侵等因素,導致資料或資訊傳送發生遺漏、錯誤、或遭竄改。
3 其他網路交易之風險。
二、條件下單功能服務,係依據投資人設定之個股或期貨商品種類及下單條件,提供即時有效之資訊,並結合既有之網路下單功能,允許投資人在同一網頁操作證券或期貨下單之委託指示。本公司目前所提供之條件下單功能服務包括觸價下單、觸量下單、定時下單、長效停損/停利下單及多條件下單共五種(簡稱為條件下單),不同種類的條件下單,其設定方式、效力有可能不同,或受有特別限制,投資人於設定每一筆條件下單前應詳細閱讀注意事項,審慎為之。
三、經觸發條件下單功能服務「直接下單」功能鍵後,具有與口頭、電話、傳真、網路下單相同之效力,如經成交即不得取消,投資人負有交割義務,以及證券、期貨相關法令所規定之各項責任。
四、投資人得於成交前以網路或電話方式變更或取消委託,投資人於下單前應充分瞭解有關變更或取消委託之操作。因不可抗力或不可歸責於本公司之事由,包括(但不在此限)斷電、斷線、網路壅塞、傳輸干擾等因素,致變更或取消意思表示無法即時送達之風險,由投資人自行負擔。
五、基於網路維運、符合資訊法規及網路規範、確保網路交易安全,或服從主管機關之命令等因素,對於有礙系統正常運作、或可能造成系統資訊不穩定、或其他異常狀況之條件下單,本公司保留刪除之權利。如經決定刪除,本公司將另以電子平台公告、行動簡訊或電子郵件通知投資人,並請投資人至富邦證券網站、HTS快易點、HTS2多易點及Online查詢條件下單訊息公告。
六、經公告於本公司網站上之其他有關電子下單、客戶資料使用、網站管理、保密措施等規範,於條件下單功能服務均有其適用。如有未盡事宜,悉照中華民國相關法令以及經公告之網際網路交易規範為準據。
七、請投資人依本公司條件下單之下單規則,於完成有效期間條件下單之設定後, 請於該條件下單之有效期間內之每一營業日當日查詢該條件下單狀態;條件下單之詳細狀態僅保留至當日,若投資人對條件下單狀態有疑慮,請於該筆交易當日洽詢所屬分公司營業同仁。如交易當日條件下單有故障或因不可抗力因素導致系統無法送單情形,則該交易視為未下單處理。
注意事項: 1. 如使用條件單訂閱功能,請務必確認各項訂閱條件內容,避免產生錯誤。另提醒投資人,此為訂閱功能,待條件符合,才會觸發下單,如欲查詢訂閱狀況可至富邦Online/HTS2多易點/HTS快易點。 2. 就前述訂閱功能,投資人可設定條件單觸發後,系統以e-mail發送觸發通知給投資人,或直接下單。如不熟悉條件單操作流程,建議設定觸發通知,待熟悉後再選擇直接下單。 3. 如使用定時單下最後一盤,建議設定停盤丟單,因條件單主機與交易所主機不同,雖然固定每3分鐘進行1次網路校時,但難免出現秒差(如設定13:25下單,可能會下在13:24:59),請留意。 4. 條件單接受比對A商品下B商品,設定A商品時會自動帶委託A商品,要委託B商品請手動調整。 5. 當投資人設定之行情條件觸發且本系統送出投資人設定之委託單後,本公司會將該委託單送至交易所,該委託單將會轉為一般委託,此時無法取消訂閱該筆條件單,請直接使用下單查詢功能,查找觸發後的一般委託進行改單調整。 6. 條件單訂閱冷門商品,有可能會碰到開盤沒報價或價格穩定措施3分鐘無行情,這時條件單會進入等價狀況,待有行情才會開始繼續洗價比對。 7. 請留意,使用條件單訂閱功能時,待觸發送單後才會與本公司後台風控進行比對。 8. 請留意,證期權多條件長效單、移動鎖利條件單、庫存停損利條件單之效期最長為3個月,定時定額條件單效期最長為6個月。 9. 其餘未盡事宜請參閱各條件單介面下方注意事項,確認閱讀內容完畢後始得訂閱條件單。 --- ### Fubon Neo API Condition Order *** Key takeaways * Overview of Fubon Neo API futures condition orders. * Supports multiple order types for automated strategies and risk control. * Next step: [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/prepare.md). | Item | Details | | ------------ | ------------------------------------------------------------------------------------------------------- | | Product | Fubon Neo API Futures Condition Orders | | Functions | Trigger, TP/SL, time-slice | | Platforms | Windows / macOS / Linux | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Prerequisite | Agreement signature required | #### Overview[​](#overview "Direct link to Overview") Fubon Neo API provides comprehensive trading and market APIs for your programmatic trading needs, catering to every developer's quantitative and automated trading requirements. Our API allows users to freely choose from mainstream programming languages (Python, C#, JavaScript) and easily access the API during the process of creating programmatic trades, utilizing trading and market services. #### Features[​](#features "Direct link to Features") Cross-platform support: Fubon Neo API supports Windows, MacOS, and Linux.
It also supports mainstream languages like Python, C#, and JavaScript. Stable technical architecture for direct connectivity to exchanges. Customizable market data solutions. #### Key Functions[​](#key-functions "Direct link to Key Functions") Direct trade management: Create MIT (market-if-touched) orders , TP (Take Profit)/SL (Stop Loss) order, and Time-Slice order ... etc. #### Version Support[​](#version-support "Direct link to Version Support") Python support: 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported).
Node.js Support : 16 and above.
C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. --- ### Cancel Condition Order CancelConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | CancelResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### CancelResult Parameter[​](#cancelresult-parameter "Direct link to CancelResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.CancelConditionOrders(account, "c9df498a-3b28-4b50-a6f2-f7bd524e96df"); ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```cs Result { isSuccess = True, message = , data = CancelResult { advisory = "成功筆數:1,失敗筆數:0!" } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------ | | marketType | TradingType | [Monitor Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol (If marketType = index, then symbol is `1000`) | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity`、`Time` | | triggerValue | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When `Reference`, trigger can match `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 2. When selecting `Scheduled`, symbol should filled the symbolId to be triggered, and trigger must be `Time`. ##### FutOptConditionOrder Object[​](#futoptconditionorder-object "Direct link to FutOptConditionOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | buySell | BsAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | marketType | FutOptConditionMarketType | [Trading Session](#futoptconditionmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` (**IMPORTANT:** The following condition order functions do not support after-hours session: 1. Time slice, 2. Trail profit, 3. Time triggered conditions) | | priceType | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | orderType | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | caution The following condition order functions do not support after-hours session: 1. Time slice 2. Trail profit 3. Time triggered conditions ##### FutOptTPSLOrder Object[​](#futopttpslorder-object "Direct link to FutOptTPSLOrder Object") | Parameter | Type | Meaning | | ---------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | timeInForce | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | priceType | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | orderType | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | | targetPrice | string | Take Profit / Stop Loss Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger (**reserved field**) | TriggerContent | Added since v2.2.0. No actual function yet. Please fill ***null*** for this parameter. | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` ##### FutOptTpslWrapper Object[​](#futopttpslwrapper-object "Direct link to FutOptTpslWrapper Object") | Parameter | Type | Meaning | | --------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stopSign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | FutOptTpslOrder Object (Optional) | TP Object | | sl | FutOptTpslOrder Object (Optional) | SL Object | | endDate | string (Optional : null equals Condition startDate) | TP / SL EndDate | | dayTrade | bool (Optional) | When Fully Filled Execuate DayTrade (Fixed to True for futures) | ##### FutOptTrailOrder[​](#futopttrailorder "Direct link to FutOptTrailOrder") | Parameter | Type | Meaning | | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | symbol | | price | string | Activate Price | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | tickNum | int | Up / down tick | | buySell | BsAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | lot | int | Order lot | | PriceType | FutOptConditionPriceType | [PriceType](#futoptconditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Flat Price、`RangeMarket` Market with Protection Orders | | diff | int | Buy / Sell Ticker Count (Base on PriceType ) ,Positive value indicates upward increments、Negative value indicates downward decrements | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | orderType | FutOptConditionOrderType | [OrderType](#futoptconditionordertype) Valid `New` Open Position、`Close` Close Position | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | --------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `singleQuantity` shares per order
`Type2` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders | | singleQuantity | int | Single Order Shares | | total\_quantity | int (Optional) | Total Order Shares | | start\_time | string | Start Time | | end\_time | string (Optional) | End Time | caution `totalQuantity` must be greater than `singleQuantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BsAction[​](#bsaction "Direct link to BsAction") | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Index | Index | | Scheduled | Time | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | ------------- | -------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Type1 | Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `singleQuantity` shares per order | | Type2 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### FutOptConditionMarketType[​](#futoptconditionmarkettype "Direct link to FutOptConditionMarketType") MarketType (FutOptConditionMarketType) | Name | Meaning | | ------ | -------------------- | | Future | Future (day session) | | Option | Option (day session) | ##### FutOptConditionPriceType[​](#futoptconditionpricetype "Direct link to FutOptConditionPriceType") PriceType (FutOptConditionPriceType) | Name | Meaning | | ------------ | ----------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | | RangeMarket | Market with Protection Orders | ##### FutOptConditionOrderType[​](#futoptconditionordertype "Direct link to FutOptConditionOrderType") OrderType (FutOptConditionOrderType) | Name | Meaning | | ----- | -------------- | | New | Open Position | | Close | Close Position | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid GetConditionOrderById #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetConditionOrderById(account," 8ff3472b-185a-488c-be5a-b478deda080c"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = { Guid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, BatchNo = , OrderLevel = 0, LastTime = 2024-11-15 10:38:48, ConditionType = 觸價, ParentGuid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, Symbol = FIMTX202411, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止, Action = 下單(新倉), ConditionBuySell = 賣, ConditionSymbol = 賣 小型台指202411, ConditionPrice = 範圍市價(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, CreateTime = 2024-11-15 10:38:48, StartDate = 2024/11/15, Status = 洗價中(Y), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 2, TpslRecord = [ { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22340(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = }, { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22280(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = } ] } } ``` --- ### Query Condition History GetConditionHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Quert Start Date | | endDate | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | historyStatus | [HistoryStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#historystatus) (Optional) | Status of Condition History | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetConditionHistory(account,"20240301","20240601"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [{ Guid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, BatchNo = , OrderLevel = 0, LastTime = 2024-11-15 10:38:48, ConditionType = 觸價, ParentGuid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, Symbol = FIMTX202411, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止, Action = 下單(新倉), ConditionBuySell = 賣, ConditionSymbol = 賣 小型台指202411, ConditionPrice = 範圍市價(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, CreateTime = 2024-11-15 10:38:48, StartDate = 2024/11/15, Status = 洗價中(Y), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 2, TpslRecord = [ { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22340(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = }, { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22280(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = } ] }, ... ] } ``` --- ### Get Condition Order GetConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | conditionStatus | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/csharp/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetConditionOrder(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = { Guid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, BatchNo = , OrderLevel = 0, LastTime = 2024-11-15 10:38:48, ConditionType = 觸價, ParentGuid = adada47e-dea3-4a5a-9eff-d36bd7a71e87, Symbol = FIMTX202411, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止, Action = 下單(新倉), ConditionBuySell = 賣, ConditionSymbol = 賣 小型台指202411, ConditionPrice = 範圍市價(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, CreateTime = 2024-11-15 10:38:48, StartDate = 2024/11/15, Status = 洗價中(Y), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = [], TpslCount = 2, TpslRecord = [ { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22340(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = }, { Guid = b79084fe-6fdf-461f-a264-0482072237eb, Account = 9974825, ConditionContent = 當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止, Action = 下單(平倉), ConditionBuySell = 買, ConditionSymbol = 買 小型台指202411, ConditionPrice = 22280(ROD), ConditionVolume = 2, ConditionFilledVolume = 0, StartDate = 2024/11/15, Status = 未生效(W), ErrorMessage = } ] } } ``` --- ### Multi-Condition MultiCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // 設計條件內容 var condition1 = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.MatchedPrice, "100", Operator.LessThan ); var condition2 = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.TotalQuantity, "30", Operator.LessThan ); List conditions = new List(); conditions.Add(condition1); conditions.Add(condition2); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); sdk.FutOpt.MultiCondition(account, "20240426", "20240430", StopSign.Full, conditions, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Multi-Condition with TP & SL MultiCondition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ----------------------- | | guid | string | Condition Serial Number | | reply\_code | string | Status Code | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // 設計條件內容 var condition1 = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.MatchedPrice, "100", Operator.LessThan ); var condition2 = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.TotalQuantity, "30", Operator.LessThan ); List conditions = new List(); conditions.Add(condition1); conditions.Add(condition2); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); var tp = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "120", "120", null // For version >= 2.2.0, no actual function yet ); var sl = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "85", "85", null // For version >= 2.2.0, no actual function yet ); var tpsl = new FutOptTpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.FutOpt.MultiCondition(account, "20240426", "20240430", StopSign.Full, conditions, order, tpsl); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition SingleCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var condition = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.MatchedPrice, "100", Operator.LessThan ); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); sdk.FutOpt.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Single Condition with TP & SL SingleCondition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // 設計條件內容 var condition = new Condition( TradingType.Reference, "TXO20000E4", TriggerContent.MatchedPrice, "100", Operator.LessThan ); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); var tp = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "120", "120", null // For version >= 2.2.0, no actual function yet ); var sl = new FutOptTpslOrder( TimeInForce.Rod, FutOptConditionPriceType.Limit, FutOptConditionOrderType.Close, "85", "85", null // For version >= 2.2.0, no actual function yet ); var tpsl = new FutOptTpslWrapper( StopSign.Full, tp, sl, "20240517", false ); sdk.FutOpt.SingleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Get Time Slice Order GetTimeSliceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | batchNo | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetTimeSliceOrder(account,"1234578"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ ConditionDetail{ Guid = f76c49ee-e955-41ac-8e11-02d6d2b78918, BatchNo = , OrderLevel = 0, LastTime = 2024-08-16 17:13:29, ConditionType = 定時, ParentGuid = , Symbol = TXO20000H4, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當於2024/08/16 定時單時間大於等於09:15:00 全部成交為止, Action = 下單(新倉), ConditionBuySell = 買, ConditionSymbol = 買 台指2024年8 月買權履約價:20000, ConditionPrice = 500(ROD), ConditionVolume = 1, ConditionFilledVolume = 0, CreateTime = 2024-08-16 17:13:28, StartDate = 2024/08/16, Status = 預約(N), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = new List(), TpslCount = 0, TpslRecord = new List() } ] } ``` --- ### Time Slice Order TimesliceCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | splitDescription | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#splitdescription) | Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var split = new SplitDescription( TimeSliceOrderType.Type1, 300, 1, 10, '083000' ); var order = new FutOptConditionOrder( BsAction.Buy, "TXO20000E4", "100", 1, FutOptConditionMarketType.Option, FutOptConditionPriceType.Limit, TimeInForce.Rod, FutOptConditionOrderType.New ); sdk.FutOpt.TimeSliceOrder(target_account, "20240427","20240516", StopSign.Full, split, order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 24081200000006 } } ``` --- ### Query Trail History GetTrailHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetConditionHistory(account,"20240301","20240601"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ { Guid = 1d97125b-9847-4b30-a066-2b490be17b2d, BatchNo = , OrderLevel = 0, LastTime = 2024-09-15 10:33:33, ConditionType = 移動鎖利, ParentGuid = , Symbol = FITX202411, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止, Action = 下單(新倉), ConditionBuySell = 買, ConditionSymbol = 台指期202411 買, ConditionPrice = 賣出價(3) 檔(ROD), ConditionVolume = 1, ConditionFilledVolume = 0, CreateTime = 2024-09-15 10:33:33, StartDate = 2024/09/15, Status = 洗價中(Y), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = new List(), TpslCount = 0, TpslRecord = new List() }, ... ] } ``` --- ### Get Trail Order GetTrailOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.FutOpt.GetTrailOrder(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ { Guid = 1d97125b-9847-4b30-a066-2b490be17b2d, BatchNo = , OrderLevel = 0, LastTime = 2024-09-15 10:33:33, ConditionType = 移動鎖利, ParentGuid = , Symbol = FITX202411, OrderAmount = 0, ChildBatchNo = , Account = 9974825, ConditionContent = 當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止, Action = 下單(新倉), ConditionBuySell = 買, ConditionSymbol = 台指期202411 買, ConditionPrice = 賣出價(3) 檔(ROD), ConditionVolume = 1, ConditionFilledVolume = 0, CreateTime = 2024-09-15 10:33:33, StartDate = 2024/09/15, Status = 洗價中(Y), ErrorMessage = null, DetailRecordsCount = 0, DetailRecords = new List(), TpslCount = 0, TpslRecord = new List() }, ... ] } ``` --- ### Trail Profit Condition TrailProfit caution Only Support Future Regular Sessions #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [FutOptTrailOrder](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/csharp/EnumMatrix.md#futopttrailorder) | Trail Order Condition | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Condition Content var trail = new FutOptTrailOrder( "TXFL4", "20000", Direction.Up, 5, // Up or Down Percent BsAction.Buy, 2, FutOptConditionPriceType.MatchedPrice, 5, // order price ticker (negative represent down) TimeInForce.Rod, FutOptConditionOrderType.New, ); sdk.FutOpt.TrailProfit(target_account, "20240427","20240516", StopSign.Full, trail); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = ConditionOrderResult { guid = 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Cancel Condition Order cancelConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | CancelResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### CancelResult Parameter[​](#cancelresult-parameter "Direct link to CancelResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.cancelConditionOrders(account, "c9df498a-3b28-4b50-a6f2-f7bd524e96df") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, data: { { advisory = "成功筆數:1,失敗筆數:0!" } } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------ | | marketType | TradingType | [Monitor Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity`、`Time` | | triggerValue | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When `Reference`, trigger can match `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 2. When selecting `Scheduled`, symbol should filled the symbolId to be triggered, and trigger must be `Time`. ##### FutOptConditionOrder Object[​](#futoptconditionorder-object "Direct link to FutOptConditionOrder Object") | Parameter | Type | Meaning | | ----------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | buySell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | marketType | FutOptConditionMarketType | [Trading Session](#futoptconditionmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` (**IMPORTANT:** TThe following condition order functions do not support after-hours session: 1. Time slice, 2. Trail profit, 3. Time triggered conditions) | | priceType | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | orderType | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | caution The following condition order functions do not support after-hours session: 1. Time slice 2. Trail profit 3. Time triggered conditions ##### FutOptTPSLOrder Object[​](#futopttpslorder-object "Direct link to FutOptTPSLOrder Object") | Parameter | Type | Meaning | | ---------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | timeInForce | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | priceType | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | orderType | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | | targetPrice | string | Take Profit / Stop Loss Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger (**reserved field**) | TriggerContent | Added since v2.2.0. No actual function yet. | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` ##### FutOptTPSLWrapper Object[​](#futopttpslwrapper-object "Direct link to FutOptTPSLWrapper Object") | Parameter | Type | Meaning | | --------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stopSign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | FutOptTPSLOrder Object (Optional) | TP Object | | sl | FutOptTPSLOrder Object (Optional) | SL Object | | endDate | string (Optional : null equals Condition startDate) | TP / SL EndDate | | dayTrade | bool (Optional) | When Fully Filled Execuate DayTrade (Fixed to true for futures) | ##### FutOptTrailOrder[​](#futopttrailorder "Direct link to FutOptTrailOrder") | Parameter | Type | Meaning | | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | symbol | | price | string | Activate Price | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | tickNum | int | Up / down tick | | buySell | BSAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | lot | int | Order lot | | PriceType | FutOptConditionPriceType | [PriceType](#futoptconditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Flat Price、`RangeMarket` Market with Protection Orders | | diff | int | Buy / Sell Ticker Count (Base on PriceType ) ,Positive value indicates upward increments、Negative value indicates downward decrements | | timeInForce | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | orderType | FutOptConditionOrderType | [OrderType](#futoptconditionordertype) Valid `New` Open Position、`Close` Close Position | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | -------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order
`Type2` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders | | singleQuantity | int | Single Order Shares | | totalQuantity | int (Optional) | Total Order Shares | | startTime | string | Start Time | | endTime | string (Optional) | End Time | caution `totalQuantity` must be greater than `singleQuantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BsAction[​](#bsaction "Direct link to BsAction") | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Index | Index | | Scheduled | Time | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | ------------- | -------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down/ (direction) | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Type1 | Starting from `startTime`, send one order every `interval` seconds, for `totalQuantity`, with `singleQuantity` shares per order | | Type2 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `startTime` , send one order every `interval` seconds, for `totalQuantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### FutOptConditionMarketType[​](#futoptconditionmarkettype "Direct link to FutOptConditionMarketType") MarketType (FutOptConditionMarketType) | Name | Meaning | | ------ | -------------------- | | Future | Future (day session) | | Option | Option (day session) | ##### FutOptConditionPriceType[​](#futoptconditionpricetype "Direct link to FutOptConditionPriceType") PriceType (FutOptConditionPriceType) | Name | Meaning | | ------------ | ----------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | | RangeMarket | Market with Protection Orders | ##### FutOptConditionOrderType[​](#futoptconditionordertype "Direct link to FutOptConditionOrderType") OrderType (FutOptConditionOrderType) | Name | Meaning | | ----- | -------------- | | New | Open Position | | Close | Close Position | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid getConditionOrderById #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getConditionOrderById(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batchNo: "", orderLevel: "0", lastTime: "2024-11-15 10:38:48", conditionType: "觸價", parentGuid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", conditionBuySell: "賣", conditionSymbol: "賣 小型台指202411", conditionPrice: "範圍市價(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", createTime: "2024-11-15 10:38:48", startDate: "2024/11/15", status: "洗價中(Y)", detailRecordsCount: "0", detailRecords: [], tpslCount: "2", tpslRecord: [ { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22340(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22280(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, ] } } ``` --- ### Query Condition HIstory getConditionHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Quert Start Date | | endDate | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | historyStatus | [HistoryStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#historystatus) (Optional) | Status of Condition History | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess : false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getConditionHistory(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batchNo: "", orderLevel: "0", lastTime: "2024-11-15 10:38:48", conditionType: "觸價", parentGuid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", conditionBuySell: "賣", conditionSymbol: "賣 小型台指202411", conditionPrice: "範圍市價(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", createTime: "2024-11-15 10:38:48", startDate: "2024/11/15", status: "洗價中(Y)", detailRecordsCount: "0", detailRecords: [], tpslCount: "2", tpslRecord: [ { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22340(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22280(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, ] } } ``` --- ### Get Condition Order getConditionOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | conditionStatus | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/nodejs/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getConditionOrder(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batchNo: "", orderLevel: "0", lastTime: "2024-11-15 10:38:48", conditionType: "觸價", parentGuid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", conditionBuySell: "賣", conditionSymbol: "賣 小型台指202411", conditionPrice: "範圍市價(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", createTime: "2024-11-15 10:38:48", startDate: "2024/11/15", status: "洗價中(Y)", detailRecordsCount: "0", detailRecords: [], tpslCount: "2", tpslRecord: [ { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22340(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", conditionContent: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", conditionBuySell: "買", conditionSymbol: "買 小型台指202411", conditionPrice: "22280(ROD)", conditionVolume: "2口", conditionFilledVolume: "0口", startDate: "2024/11/15", status: "未生效(W)", errorMessage: "", }, ] } } ``` --- ### Multi-Condition multiCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // 設計條件內容 const condition = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.MatchedPrice, triggerValue: "100", comparison: Operator.LessThan } const condition2 = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.TotalQuantity, triggerValue: "30", comparison: Operator.GreaterThan } const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "100", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; sdk.futopt.multiCondition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Multi-Condition with TP & SL multiCondition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionorder-object) | Order Object | | TPSL | [FutOptTPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futopttpslwrapper-object) | TPSL Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js const condition = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.MatchedPrice, triggerValue: "100", comparison: Operator.LessThan } const condition2 = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.TotalQuantity, triggerValue: "30", comparison: Operator.GreaterThan } const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "100", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; const tp = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "120", price: "120" } const sl = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "60", price: "60" } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517" // optional field } sdk.futopt.multiCondition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order, tpsl) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition singleCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // 設計條件內容 const condition = { market_type: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.MatchedPrice, trigger_value: "100", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "500", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; sdk.futopt.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Single Condition with TP & SL singleCondition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionorder-object) | Order Object | | TPSL | [FutOptTPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futopttpslwrapper-object) | TPSL Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Requst Example[​](#requst-example "Direct link to Requst Example") ```js // Condition Content const condition = { marketType: TradingType.Reference, symbol: "TXO20000E4", trigger: TriggerContent.MatchedPrice, triggerValue: "100", comparison: Operator.LessThan } const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "100", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; const tp = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "120", price: "120" } const sl = { timeInForce: TimeInForce.ROD, priceType: FutOptConditionPriceType.Limit, orderType: FutOptConditionOrderType.Close, targetPrice: "60", price: "60" } const tpsl = { stopSign: StopSign.Full, tp: tp, // optional field sl: sl, // optional field endDate: "20240517" // optional field } sdk.futopt.singleCondition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Get Time Slice Order getTimeSliceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | batchNo | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) (optional) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getTimeSliceOrder(account,"1234567") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: [ { guid: "f76c49ee-e955-41ac-8e11-02d6d2b78918", batchNo: "", orderLevel: "0", lastTime: "2024-08-16 17:13:29", conditionType: "定時", parentGuid: "", symbol: "TXO20000H4", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當於2024/08/16 定時單時間大於等於09:15:00 全部成交為止", action: "下單(新倉)", conditionBuySell: "買", conditionSymbol: "買 台指2024年8 月買權履約價:20000", conditionPrice: "500(ROD)", conditionVolume: "1口", conditionFilledVolume: "0口", createTime: "2024-08-16 17:13:28", startDate: "2024/08/16", status: "預約(N)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [] } ] } ``` --- ### Time Slice COndition timesliceCondition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | splitDescription | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#splitdescription) | Split Condition | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Condition Content const split = { method: TimeSliceOrderType.Type1, interval: 300, single_quantity: 1, total_quantity: 10, start_time: '083000' }; const order = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "500", lot: 1, marketType: FutOptConditionMarketType.Option, priceType: FutOptConditionPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.New }; sdk.futopt.timeSliceOrder(target_account, "20240427","20240516", StopSign.Full, split, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data : { guid : "24081200000006" } } ``` --- ### Query Trail HIstory getTrailHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Quert Start Date | | end\_date | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess : false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getTrailHistory(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data :[ { guid: "1d97125b-9847-4b30-a066-2b490be17b2d", batchNo: "", orderLevel: "0", lastTime: "2024-09-15 10:33:33", conditionType: "移動鎖利", parentGuid: "", symbol: "FITX202411", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止", action: "下單(新倉)", conditionBuySell: "買", conditionSymbol: "台指期202411 買", conditionPrice: "賣出價(3) 檔(ROD)", conditionVolume: "1口", conditionFilledVolume: "0口", createTime: "2024-09-15 10:33:33", startDate: "2024/09/15", status: "洗價中(Y)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], }, ... ] } ``` --- ### Get Trail Order getTrailOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail--parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------ | ------------------------- | | guid | string | Condition Serial Number | | batchNo | string | Condition Batch Number | | orderLevel | string | Condition Level | | lastTime | string | Last Modification Time | | parentGuid | string | Parent Serial Number | | symbol | string | Symbol | | orderAmount | string | Order Amount | | childBatchNo | string | Child Batch Number | | account | string | Account | | conditionContent | string | Condition Content | | action | string | COndition Action | | conditionBuySell | string | Condition Buy / Sell Type | | conditionSymbol | string | Symbol Name | | conditionPrice | string | Price | | conditionVolume | string | Volume | | conditionFilledVolume | string | Filled Volume | | createTime | string | Condition Creation Time | | startDate | string | Condition Start Date | | status | string | Status | | errorMessage | string | Error Message | | detailRecordsCount | string | Detail Number | | detailRecords | List | Detail Records | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | | tpslCount | string | TP / SL Count Number | | tpslRecord | List | TP / SL Record | | >> guid | string | Condition Serial Number | | >> account | string | Account | | >> conditionContent | string | Condition Content | | >> action | string | COndition Action | | >> conditionBuySell | string | Condition Buy / Sell Type | | >> conditionSymbol | string | Symbol Name | | >> conditionPrice | string | Price | | >> conditionVolume | string | Volume | | >> conditionFilledVolume | string | Filled Volume | | >> createTime | string | Condition Creation Time | | >> startDate | string | Condition Start Date | | >> status | string | Status | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.getTrailOrder(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data :[ { guid: "1d97125b-9847-4b30-a066-2b490be17b2d", batchNo: "", orderLevel: "0", lastTime: "2024-09-15 10:33:33", conditionType: "移動鎖利", parentGuid: "", symbol: "FITX202411", orderAmount: "0", childBatchNo: "", account: "9974825", conditionContent: "當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止", action: "下單(新倉)", conditionBuySell: "買", conditionSymbol: "台指期202411 買", conditionPrice: "賣出價(3) 檔(ROD)", conditionVolume: "1口", conditionFilledVolume: "0口", createTime: "2024-09-15 10:33:33", startDate: "2024/09/15", status: "洗價中(Y)", detailRecordsCount: "0", detailRecords: [], tpslCount: "0", tpslRecord: [], }, ... ] } ``` --- ### Trail Profit Condition TrailProfit caution Only Support Future Regular Sessions #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [FutOptTrailOrder](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/nodejs/EnumMatrix.md#futopttrailorder) | Trail Order Condition | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```js // condition content const trail = { symbol: "TXFL4", price: "20000", direction: Direction.Down, percent: 5, buySell: BSAction.Sell, lot: 1, priceType: FutOptConditionPriceType.MatchedPrice, diff: 5, timeInForce: TimeInForce.ROD, orderType: FutOptConditionOrderType.Close }; sdk.futopt.takeProfit(target_account, "20240427","20240516", StopSign.Full, trail) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, data :{ guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Cancel Condition cancel\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | guid | string | Condition Serial Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | -------------- | | advisory | string | Return Content | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.cancel_condition(target_account, "44150047-8977-40b1-953c-ce270f0000") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { advisory : "成功筆數:1,失敗筆數:0!" } } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Condition Object[​](#condition-object "Direct link to Condition Object") | Parameter | Type | Meaning | | -------------- | -------------- | ------------------------------------------------------------------------------------------------------------------- | | market\_type | TradingType | [Monitor Type](#tradingtype) Valid in : `Reference` Reference to order object、`Scheduled` Time | | symbol | string | Symbol | | trigger | TriggerContent | [Trigger Condition](#triggercontent) Valid in : `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 、`Time` | | trigger\_value | string | Trigger Value | | comparison | Operator | [Direction](#operator) Valid in : `GreaterThanOrEqual` 、`LessThanOrEqual` 、`GreaterThan` 、`LessThan` | info 1. When `Reference`, trigger can match `BidPrice` 、`AskPrice` 、`MatchedPrice` 、`TotalQuantity` 2. When selecting `Scheduled`, symbol should filled the symbolId to be triggered, and trigger must be `Time`. ##### FutOptConditionOrder Object[​](#futoptconditionorder-object "Direct link to FutOptConditionOrder Object") | Parameter | Type | Meaning | | --------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | buy\_sell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price | | quantity | int | Order Quantity | | market\_type | FutOptConditionMarketType | [Trading Session](#futoptconditionmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` (**IMPORTANT:** The following condition order functions do not support after-hours session: 1. Time slice, 2. Trail profit, 3. Time triggered conditions) | | price\_type | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | order\_type | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | caution The following condition order functions do not support after-hours session: 1. Time slice 2. Trail profit 3. Time triggered conditions ##### FutOptTPSLOrder Object[​](#futopttpslorder-object "Direct link to FutOptTPSLOrder Object") | Parameter | Type | Meaning | | ---------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | time\_in\_force | TimeInforce | [Time In Force](#timeinforce) valid in : `ROD`、`FOK`、 `IOC` | | price\_type | FutOptConditionPriceType | [Price Type](#futoptconditionpricetype) valid in : `Limit`、`LimitUp`、`LimitDown`、`Market`、 `BidPrice` Bid Price、`AskPrice` Ask Price、`Reference` Reference Price (Flat Price)、`MatchedPrice` current market price 、`RangeMarket` | | order\_type | FutOptConditionOrderType | [Order Type](#futoptconditionordertype) valid in : `New`、`Close` | | target\_price | string | Take Profit / Stop Loss Trigger Price | | price | string | Take Profit / Stop Loss Order Price | | trigger (**reserved field**) | TriggerContent | Added since v2.2.0. No actual function yet. | info When `priceType` equals `limit` , should fill in `price`; Otherwise, price equals empty string `""` ##### FutOptTPSLWrapper Object[​](#futopttpslwrapper-object "Direct link to FutOptTPSLWrapper Object") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | stop\_sign | StopSign | [Stop Condition](#stopsign) : Valid `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | tp | FutOptTPSLOrder Object (Optional) | TP Object | | sl | FutOptTPSLOrder Object (Optional) | SL Object | | end\_date | string (Optional : null equals Condition startDate) | TP / SL EndDate | | day\_trade | bool (Optional) | When Fully Filled Execuate DayTrade (Fixed to True for futures) | ##### FutOptTrailOrder[​](#futopttrailorder "Direct link to FutOptTrailOrder") | Parameter | Type | Meaning | | --------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | symbol | string | symbol | | price | string | Activate Price | | direction | Direction | [Direction](#direction) : Valid `Up` 、`Down` | | tick\_num | int | Up / down tick | | buy\_sell | BSAction | Buy / Sell Type : Valid `Buy` 、`Sell` | | lot | int | Order lot | | Price\_type | FutOptConditionPriceType | [PriceType](#futoptconditionpricetype) : Valid `BidPrice` Bid Price、`AskPrice` Ask Price、`MatchedPrice` Current Price、`Market` 、`LimitUp` 、`LimitDown` 、`Reference` Flat Price、`RangeMarket` Market with Protection Orders | | diff | int | Buy / Sell Ticker Count (Base on PriceType ) ,Positive value indicates upward increments、Negative value indicates downward decrements | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) Valid `ROD`、`FOK`、`IOC` | | order\_type | FutOptConditionOrderType | [OrderType](#futoptconditionordertype) Valid `New` Open Position、`Close` Close Position | ##### SplitDescription[​](#splitdescription "Direct link to SplitDescription") | Parameter | Type | Meaning | | ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | method | SliceType | [Slice Condition](#slicetype) : Valid in :
`Type1` Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `single_quantity` shares per order
`Type2` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order
`Type3` Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards.

| | interval | interval | The Interval Between Orders | | single\_quantity | int | Single Order Shares | | total\_quantity | int (Optional) | Total Order Shares | | start\_time | string | Start Time | | end\_time | string (Optional) | End Time | caution `totalQuantity` must be greater than `single_quantity`. ##### ConditionOrderResult[​](#conditionorderresult "Direct link to ConditionOrderResult") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------- | | guid | string | Condition Order Serial Number | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields-- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BsAction[​](#bsaction "Direct link to BsAction") | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### MarketType[​](#markettype "Direct link to MarketType") Trading Session Type | Name | Meaning | | ----------- | ----------------------------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | | Emg | Emerging Stock Market | | EmgOdd | Emerging Stock Market (share Unit ) | ##### TradingType[​](#tradingtype "Direct link to TradingType") | Name | Meaning | | --------- | ------------------------- | | Reference | Reference to order object | | Index | Index | | Scheduled | Time | ##### TriggerContent[​](#triggercontent "Direct link to TriggerContent") | Name | Meaning | | -------------- | --------------- | | BidPrice | Bid Price | | AskPrice | Sell Price | | MatchedPrice | Matched Price | | TotalQuantity | Total Quantity | | Time | Time | | LimitUp | Limit Up | | LimitDown | Limit Down | | ReferencePrice | Reference Price | ##### Operator[​](#operator "Direct link to Operator") | Name | Meaning | | ------------------ | --------------------- | | GreaterThanOrEqual | Greater Than or Equal | | LessThanOrEqual | Less Than or Equal | | GreaterThan | Greater Than | | LessThan | Less Than | ##### StopSign[​](#stopsign "Direct link to StopSign") | Name | Meaning | | -------- | ------------------ | | Full | Until Fully Filled | | Partial | Once Filled Happen | | UntilEnd | Until Expiry | ##### Direction[​](#direction "Direct link to Direction") Take Profit trace up / down/ (direction) | Name | Meaning | | ---- | ------- | | Up | Up | | Down | Down | ##### SliceType[​](#slicetype "Direct link to SliceType") | Name | Meaning | | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Type1 | Starting from `start_time`, send one order every `interval` seconds, for `total_quantity`, with `single_quantity` shares per order | | Type2 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. The remaining shares will be aggregated and included in the last order | | Type3 | Starting from `start_time` , send one order every `interval` seconds, for `total_quantity`. Distribute the remaining shares starting from the last order backwards | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### FutOptConditionMarketType[​](#futoptconditionmarkettype "Direct link to FutOptConditionMarketType") MarketType (FutOptConditionMarketType) | Name | Meaning | | ------ | -------------------- | | Future | Future (day session) | | Option | Option (day session) | ##### FutOptConditionPriceType[​](#futoptconditionpricetype "Direct link to FutOptConditionPriceType") PriceType (FutOptConditionPriceType) | Name | Meaning | | ------------ | ----------------------------- | | Limit | Limit | | BidPrice | Bid Price | | AskPrice | Ask Price | | Market | Market Price | | MatchedPrice | Current Price | | LimitUp | Limit Up | | LimitDown | Limit Down | | Reference | Reference Price (Flat Price) | | RangeMarket | Market with Protection Orders | ##### FutOptConditionOrderType[​](#futoptconditionordertype "Direct link to FutOptConditionOrderType") OrderType (FutOptConditionOrderType) | Name | Meaning | | ----- | -------------- | | New | Open Position | | Close | Close Position | ##### ConditionStatus[​](#conditionstatus "Direct link to ConditionStatus") | Name | Meaning | | ------ | ------------------------------------- | | Type1 | Query Today's Working Condition Order | | Type2 | Valid Orders Remaining | | Type3 | Condition Matching | | Type4 | Order Processing | | Type5 | Order Successful | | Type6 | Notified | | Type7 | Order Failed | | Type8 | Filled | | Type9 | Delete Successful | | Type10 | Exception | | Type11 | Expired | ##### HistoryStatus[​](#historystatus "Direct link to HistoryStatus") | Name | Meaning | | ----- | ---------------------------------------------------- | | Type1 | All condition orders (excluding deleted and expired) | | Type2 | Fully filled within the selected period | | Type3 | Partial filled within the selected period | | Type4 | Canceled within the selected period | | Type5 | Expired within the selected period | | Type6 | Triggered records within the selected period | --- ### Get Condition Order By Guid get\_condition\_order\_by\_id #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | guid | string | Condition Sequence Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_condition_order_by_id(account,"8ff3472b-185a-488c-be5a-b478deda080c") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batch_no: "", order_level: "0", last_time: "2024-11-15 10:38:48", condition_type: "觸價", parent_guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", condition_buy_sell: "賣", condition_symbol: "賣 小型台指202411", condition_price: "範圍市價(ROD)", condition_volume: "2口", condition_filled_volume: "0口", create_time: "2024-11-15 10:38:48", start_date: "2024/11/15", status: "洗價中(Y)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "2", TPSLRecord: [ ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22340(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22280(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ], } ] } ``` --- ### Get Condition History get\_condition\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | history\_status | [HistoryStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#historystatus) (Optional) | Status of Condition History | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_condition_history(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batch_no: "", order_level: "0", last_time: "2024-11-15 10:38:48", condition_type: "觸價", parent_guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", condition_buy_sell: "賣", condition_symbol: "賣 小型台指202411", condition_price: "範圍市價(ROD)", condition_volume: "2口", condition_filled_volume: "0口", create_time: "2024-11-15 10:38:48", start_date: "2024/11/15", status: "洗價中(Y)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "2", TPSLRecord: [ ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22340(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22280(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ], } ] } ``` --- ### Get Condition Order get\_condition\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | | condition\_status | [ConditionStatus](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition/library/python/EnumMatrix.md#conditionstatus) (Optional) | Condition Status | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_condition_order(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", batch_no: "", order_level: "0", last_time: "2024-11-15 10:38:48", condition_type: "觸價", parent_guid: "adada47e-dea3-4a5a-9eff-d36bd7a71e87", symbol: "FIMTX202411", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內台指期202412成交價大於21000點 全部成交為止", action: "下單(新倉)", condition_buy_sell: "賣", condition_symbol: "賣 小型台指202411", condition_price: "範圍市價(ROD)", condition_volume: "2口", condition_filled_volume: "0口", create_time: "2024-11-15 10:38:48", start_date: "2024/11/15", status: "洗價中(Y)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "2", TPSLRecord: [ ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價大於等於22340元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22340(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ParentChildRecord { guid: "b79084fe-6fdf-461f-a264-0482072237eb", account: "9974825", condition_content: "當自2024/11/15至2024/11/20內小型台指202411買進價小於等於22280元 全部成交為止", action: "下單(平倉)", condition_buy_sell: "買", condition_symbol: "買 小型台指202411", condition_price: "22280(ROD)", condition_volume: "2口", condition_filled_volume: "0口", start_date: "2024/11/15", status: "未生效(W)", error_message: "", }, ], } ] } ``` --- ### Multi-Condition multi\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content condition = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.MatchedPrice, trigger_value = "100", comparison = Operator.LessThan ) condition2 = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.TotalQuantity, trigger_value = "30", comparison = Operator.LessThan ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "500", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) sdk.futopt.multi_condition(account, "20240426", "20240430", StopSign.Full, [condition, condition2], order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f0000" } } ``` --- ### Multi-Condition with TP & SL multi\_condition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#stopsign) | Stop Condition :`Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | MultiCondition | [Condition List](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#condition-object) | List of Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionorder-object) | Order Object | | TPSL | [FutOptTPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futopttpslwrapper-object) | TPSL Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # 設計條件內容 condition = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.MatchedPrice, trigger_value = "100", comparison = Operator.LessThan ) condition2 = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.TotalQuantity, trigger_value = "30", comparison = Operator.LessThan ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "100", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) tp = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="120", price="120" ) sl = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="60", price="60" ) tpsl = FutOptTPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517" ) sdk.futopt.multi_condition(account, "20240426", "20240430", StopSign.Full, [condition,condition2], order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f0000" } } ``` --- ### Single Condition single\_condition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition Object | [Condition](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#condition-object) | Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Resquest Example[​](#resquest-example "Direct link to Resquest Example") ```py # Condition Content condition = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.MatchedPrice, trigger_value = "100", comparison = Operator.LessThan ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "500", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) sdk.stock.single_condition(account, "20240427","20240516", StopSign.Full , condition, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce270f36150", } } ``` --- ### Single Condition with TP & SL single\_condition Stop-loss precautions * The stop-loss setting is only a trigger for placing an order and does not guarantee a transaction. It is subject to adjustment based on market conditions. * Please ensure that the stop-loss order type setting complies with applicable trading rules. #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | Condition Object | [Condition Object](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#condition-object) | Condition Content | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionorder-object) | Order Object | | TPSL | [FutOptTPSLWrapper](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futopttpslwrapper-object) | TPSL Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition COntent condition = Condition( market_type = TradingType.Reference, symbol = "TXO20000E4", trigger = TriggerContent.MatchedPrice, trigger_value = "100", comparison = Operator.LessThan ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "100", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) tp = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="120", price="120" ) sl = FutOptTPSLOrder( time_in_force=TimeInForce.ROD, price_type=FutOptConditionPriceType.Limit, order_type=FutOptConditionOrderType.Close, target_price="60", price="60" ) tpsl = FutOptTPSLWrapper( stop_sign= StopSign.Full, tp=tp, # optional field sl=sl, # optional field end_date="20240517" # optional field ) sdk.futopt.single_condition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "44150047-8977-40b1-953c-ce2XXXXXX" } } ``` --- ### Get Time Slice Order get\_time\_slice\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | batch\_no | string | Condition Sequence Number | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) (Optional) default : Regular Session | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_condition_order_by_id(account,"24081200000006") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ ConditionDetail { guid: "f76c49ee-e955-41ac-8e11-02d6d2b78918", batch_no: "", order_level: "0", last_time: "2024-08-16 17:13:29", condition_type: "定時", parent_guid: "", symbol: "TXO20000H4", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當於2024/08/16 定時單時間大於等於09:15:00 全部成交為止", action: "下單(新倉)", condition_buy_sell: "買", condition_symbol: "買 台指2024年8 月買權履約價:20000", condition_price: "500(ROD)", condition_volume: "1口", condition_filled_volume: "0口", create_time: "2024-08-16 17:13:28", start_date: "2024/08/16", status: "預約(N)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } ] } ``` --- ### Time Slice Condition timeslice\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | split\_description | [SplitDescription](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#condition-object) | Split Condition | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionorder-object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content split = SplitDescription( method=TimeSliceOrderType.Type1, interval=300, single_quantity=1, total_quantity=10, start_time='083000' ) order = FutOptConditionOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "500", lot = 1, market_type = FutOptConditionMarketType.Option, price_type = FutOptConditionPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.New ) sdk.futopt.time_slice_order(target_account, "20240427","20240516", StopSign.Full, split, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : ConditionOrderResult { guid : "24081200000006" } } ``` --- ### Get Trail History get\_trail\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_trail_order(account,"20240301","20240601") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ ConditionDetail { guid: "1d97125b-9847-4b30-a066-2b490be17b2d", batch_no: "", order_level: "0", last_time: "2024-09-15 10:33:33", condition_type: "移動鎖利", parent_guid: "", symbol: "FITX202411", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止", action: "下單(新倉)", condition_buy_sell: "買", condition_symbol: "台指期202411 買", condition_price: "賣出價(3) 檔(ROD)", condition_volume: "1口", condition_filled_volume: "0口", create_time: "2024-09-15 10:33:33", start_date: "2024/09/15", status: "洗價中(Y)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } ... ] } ``` --- ### Get Trail Order get\_trail\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | marketType | [FutOptConditionMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futoptconditionmarkettype) | Market Type | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | list | ConditionDetail is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionDetail Parameter[​](#conditiondetail-parameter "Direct link to ConditionDetail Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ------ | ------------------------------------------ | | guid | string | Condition Sequence Number | | batch\_no | string | Batch number | | order\_level | string | Condition Level : `0` parent、`1、2` Child | | last\_time | string | Last Update Time | | parent\_guid | string | Parent Sequence Number | | symbol | string | Symbol | | order\_amount | string | Order Amount | | child\_batch\_no | string | Chlid Batch Number | | account | string | Account | | condition\_content | string | Condition Content | | action | string | Condition Trigger Action | | condition\_buy\_sell | string | Buy / Sell Action | | condition\_symbol | string | Symbol Name | | condition\_price | string | Order Price | | condition\_volume | string | Order Volume | | condition\_filled\_volume | string | Filled Volume | | create\_time | string | Condition Creation Time | | start\_date | string | Condition Start Date | | status | string | Status | | error\_message | string | Error Message | | detail\_records\_count | string | Detail Count | | detail\_records | List | Detail Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | | tpslCount | string | Take Profit / Stop Loss Count | | tpslRecord | List | Take Profit / Stop Loss Content | | >> guid | string | Condition Sequence Number | | >> account | string | Account | | >> condition\_content | string | Condition Content | | >> action | string | Condition Trigger Action | | >> condition\_buy\_sell | string | Buy / Sell Action | | >> condition\_symbol | string | Symbol Name | | >> condition\_price | string | Symbol Price | | >> condition\_volume | string | Order Volume | | >> condition\_filled\_volume | string | Filled Volume | | >> start\_date | string | Condition Start Date | | >> status | string | Status | | >> error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_trail_order(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ ConditionDetail { guid: "1d97125b-9847-4b30-a066-2b490be17b2d", batch_no: "", order_level: "0", last_time: "2024-09-15 10:33:33", condition_type: "移動鎖利", parent_guid: "", symbol: "FITX202411", order_amount: "0", child_batch_no: "", account: "9974825", condition_content: "當自2024/09/15至2024/11/16內台指期202411成交價小於等於20000點 全部成交為止", action: "下單(新倉)", condition_buy_sell: "買", condition_symbol: "台指期202411 買", condition_price: "賣出價(3) 檔(ROD)", condition_volume: "1口", condition_filled_volume: "0口", create_time: "2024-09-15 10:33:33", start_date: "2024/09/15", status: "洗價中(Y)", error_message: None, detail_records_count: "0", detail_records: [], TPSLCount: "0", TPSLRecord: [], } ... ] } ``` --- ### Trail Profit Condition trail\_profit caution Only Support Future Regular Sessions #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Condition Start Date | | end\_date | string | Condition End Date | | stop\_sign | [StopSign](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#stopsign) | Stop Condition : `Full` Until Fully filled、`Partial` Once Filled happened 、 `UntilEnd` Until Expiry | | TrailOrder | [FutOptTrailOrder](https://www.fbs.com.tw/TradeAPI/en/docs/smart-condition-future/library/python/EnumMatrix.md#futopttrailorder) | Trail Order Condition | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | ConditionOrderResult is returned | | message | string ? (optional) | isSuccess = false error description is returned | ##### ConditionOrderResult Parameter[​](#conditionorderresult-parameter "Direct link to ConditionOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------- | ------ | ----------------------- | | guid | string | Condition Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Condition Content trail = FutOptTrailOrder( symbol ="TXFL4", baseprice = "20000", direction = Direction.Up, tick_num = 5, # Up or Down Percent buysell = BSAction.Buy, lot = 2, price_type = FutOptConditionPriceType.MatchedPrice, tickers = 5, # base price ticker (negative represent down) time_in_force = TimeInForce.ROD, order_type = FutOptConditionOrderType.Close, ) sdk.futopt.trail_profit(target_account, "20240427","20240516", StopSign.Full, trail) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py { is_success : True, message : None, data : ConditionOrderResult { guid : 44150047-8977-40b1-953c-ce2XXXXXX } } ``` --- ### Preparation caution Before starting with the Fubon Neo Condition API, you must complete agreement signature #### Sign agreements[​](#sign-agreements "Direct link to Sign agreements") Sign agreements ![線上簽署](/TradeAPI/en/assets/images/futurecondition-28d403275883db4916ae8c3d249373c3.png) #### Import Constant ( Only require for Python、NodeJs)[​](#import-constant--only-require-for-pythonnodejs "Direct link to Import Constant ( Only require for Python、NodeJs)") Add Condition Package * Python * Node.js ```py from fubon_neo.sdk import FubonSDK, Condition, FutOptConditionOrder from fubon_neo.constant import ( TriggerContent, TradingType, Operator, FutOptTPSLOrder, FutOptTPSLWrapper, SplitDescription, StopSign, TimeSliceOrderType, FutOptConditionPriceType, FutOptConditionOrderType, FutOptConditionMarketType, TrailOrder, Direction, FutOptTrailOrder, ConditionStatus, HistoryStatus ) ``` ```js const { FubonSDK, TriggerContent, TradingType, Operator, FutOptTPSLOrder, FutOptTPSLWrapper, SplitDescription, StopSign, TimeSliceOrderType, FutOptConditionPriceType, FutOptConditionOrderType, FutOptConditionMarketType, TrailOrder, Direction, FutOptTrailOrder, ConditionStatus, HistoryStatus } = require('fubon-neo'); ``` info Condition orders currently do not support mixing future/options and spot products. --- ### Emergency contingency In the event of force majeure or system abnormalities that prevent order placement or confirmation of order execution, please use other platforms as a backup. Alternative platforms for condition orders: * HTS2 * Online APP * Sales representative For more information, please refer to the Fubon Securities official website under [Contingency Measures for Unavailability of Online Trading Systems](https://www.fbs.com.tw/Beginner/TradingNote) --- ### API Key Introduction Version Support Available since v2.2.7 You can still log in and use the API with your existing account credentials.
**API Key is an optional feature** that provides **enhanced security and flexibility**, ideal for advanced users. ##### Why Choose API Key?[​](#why-choose-api-key "Direct link to Why Choose API Key?") * **Granular Access Control**: Restrict keys to specific functions (e.g., market data only, no order placement). * **IP Whitelisting**: Allow access only from trusted IP addresses to reduce external risks. * **Quick Revocation**: Disable a key instantly without affecting your main account. This feature is **not mandatory**, but if you want to improve security or need more flexible integration, **we recommend enabling API Key**. Important Notice **Please note!** When there are changes to the API Key list (such as adding or removing keys), all sessions logged in using an API Key will be forcibly logged out. Mechanism Change since v2.2.8 (with SDK update) The forced disconnect mechanism triggered by API Key permission changes has been adjusted to apply only to the keys affected by the change (Example: logged in simultaneously with key1 and key2; delete key1 => key1 session is forcibly disconnected; key2 session is not affected). #### Apply for a Certificate[​](#apply-for-a-certificate "Direct link to Apply for a Certificate") Before applying for an API Key, you must first apply for your web certificate. Once that's done, you can proceed with the API Key application. 1. Go to [API Key Application](https://www.fbs.com.tw/TradeAPI/en/docs/key.md) ![key\_login\_step1](/TradeAPI/en/assets/images/key_login_step1-62100f52ab0caa87e86729013382abe2.png) 2. Enter your ID number and corresponding password ![key\_login\_step2](/TradeAPI/en/assets/images/key_login_step2-e8aa8f122ec1bd5960ba14bd4b0491eb.png) 3. Apply for a web certificate and receive the OTP ![OTP](/TradeAPI/en/assets/images/OTP-3771c5ab5c12c603f48994c14e130c77.png) 4. After completing the certificate application, you can export the certificate and add a new key ![key\_login\_step3](/TradeAPI/en/assets/images/key_login_step3-add15e5759914e12519b00657532f988.png) CA Certificate with a Default Password Use your login ID when prompted to enter the certificate password. 5. Apply for a key * Click `Add API Key `![add\_key](/TradeAPI/en/assets/images/add_key-5ca3ffea5b0e4c620d916dc950914d40.png) * Set control permissions ( Leave IP or date blank if you do not want to set corresponding controls ) ![add\_key\_step2](/TradeAPI/en/assets/images/add_key_step2-569f33ff9a7763a3a75e1611a83b3c47.png) * After successful setup, the Secret Key will be displayed ( **Once the Secret Key is closed, it will no longer be shown** ) ![add\_key\_step3](/TradeAPI/en/assets/images/add_key_step3-2d2331bc6aadbb61ee743ebc4d2ff3fd.png) 6. You can view previously applied keys or deactivate them ( You can activate for up to 30 keys at the same time ) ![key\_list](/TradeAPI/en/assets/images/key_list-65170f1813ace159f2ac109b2287d624.png) --- ### Accounting *** We can query profit and loss information through trade and inventory inquiries. info The limit of queries is 5 times / sec. If it exceeds the limit, please wait a moment and try again. #### Inventory[​](#inventory "Direct link to Inventory") * Python * Node.js * C# ```python inventories = sdk.accounting.inventories(accounts.data[0]) print(inventories) ``` ```py Result { is_success: true, message: None, data : [ Inventory{ date: "2023/09/20", # Query date(Today) (string) account: "26", # Account (string) branch_no: 6460, # Branch number (number) stock_no: "1101", # Symbol (string) order_type: Stock, # Order Type (OrderType) lastday_qty: 2000, # Yesterday Share balacne (number) buy_qty: 0, # Total volume purchased today (number) buy_filled_qty: 0, # Total purchased filled today (number) buy_value: 0, # Total amount purchased today (number) today_qty: 2000, # Today Share balacne (number) tradable_qty: 2000, #Available quantity (number) sell_qty: 0, # Total volume sell today (number) sell_filled_qty: 0, # Total sell filled today (number) sell_value: 0, # Total amount sell today (number) odd: InventoryOdd{ # odd lot lastday_qty: 0, # Yesterday odd lot balacne (number) buy_qty: 0, # Total volume purchased today (number) buy_filled_qty: 0, # Total purchased filled today (number) buy_value: 0, # Total amount purchased today (number) today_qty: 0, # Today odd lot balacne (number) tradable_qty: 0, # Available quantity (number) sell_qty: 0, # Total volume sell today (number) sell_filled_qty: 0,# Total sell filled today (number) sell_value: 0 # Total amount sell today (number) }}, ... ] } ``` ```js const inventory = sdk.accounting.inventories(accounts.data[0]) console.log(inventory) ``` ```js { isSuccess: true, data:[ { date: '2023/10/13', // Query date(Today) (string) account: '26', // Account (string) branchNo: '6460', // Branch number (string) stockNo: '1101', // Symbol (string) orderType: 'Stock', // Order Type (string) lastdayQty: 2000, // Yesterday Share balacne (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total amount purchased today (number) todayQty: 2000, // Today share balacne (number) tradableQty: 2000, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0, // Total amount sell today (number) odd: { // odd lot lastdayQty: 0, // Yesterday odd lot balacne (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total amount purchased today (number) todayQty: 0, // Today odd lot balacne (number) tradableQty: 0, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0 // Total amount sell today (number) } }, ... ] } ``` ```cs var inventories = sdk.Accounting.Inventoies(accounts.data[0]); foreach (var inventory in inventories.data) { Console.WriteLine(inventory); } ``` ```cs { date = 2023/09/21, // Query date(Today) (string) account = 26, // Account (string) branchNo = 6460, // Branch number (string) stockNo = 1101, // Symbol (string) orderType = Stock, // Order Type (OrderType) lastdayQty = 2000, // Yesterday Share balacne (int) buyQty = 0, // Total volume purchased today (int) buyFilledQty = 0, // Total purchased filled today (int) buyValue = 0, // Total amount purchased today (int) todayQty = 2000, // Today share balacne (int) tradableQty = 2000, // Available quantity (int) sellQty = 0, // Total volume sell today (int) sellFilledQty = 0, // Total sell filled today (int) sellValue = 0, // Total amount sell today (int) odd = InventoryOdd { // odd lot lastdayQty = 0, // Yesterday odd lot balacne (int) buyQty = 0, // Total volume purchased today (int) buyFilledQty = 0, // Total purchased filled today (int) buyValue = 0, // Total amount purchased today (int) todayQty = 0, // Today odd lot balacne (int) tradableQty = 0, // Available quantity (int) sellQty = 0, // Total volume sell today (int) sellFilledQty = 0, // Total sell filled today (int) sellValue = 0 // Total amount sell today (int) } } ``` * Below example only extract data content #### Unrealized profit and loss[​](#unrealized-profit-and-loss "Direct link to Unrealized profit and loss") * Python * Node.js * C# ```python unrealized_pnl = sdk.accounting.unrealized_gains_and_loses(accounts.data[0]) print(unrealized_pnl.data) ``` ```py [UnrealizedData({ date: "2023/05/23", # Date of inquiry (string) account: "482", # Account (string) branch_no: "6460", # Branch number (string) stock_no: "2442", # Symbol (string) buy_sell: Buy, # Transaction direction (BSAction) order_type: Margin, # Order Type (OrderType) cost_price: 19.95, # Holding cost (number) tradable_qty: 6000, # Available quantity (number) unrealized_profit: 0, # Unrealized profit (number) unrealized_loss: 10002 # Unrealized loss (number) }), ... ] ``` ```js const unrealizedPNL = sdk.accounting.unrealizedGainsAndLoses(accounts.data[0]) console.log(unrealizedPNL.data) ``` ```js [ { date: '2021/08/09', // Date of inquiry (string) account: '26', // Account (string) branchNo: '6460', // Branch number (string) stockNo: '2303', // Symbol (string) buySell: 'Buy', // Transaction direction (string) orderType: 'Margin', // Order Type (string) costPrice: 50, // Holding cost (number) tradableQty: 1000, // Available quantity (number) unrealizedProfit: 47000, // Unrealized profit (number) unrealizedLoss: 0 // Unrealized loss (number) }, ... ] ``` ```cs var unrealizedPNL = sdk.Accounting.UnrealizedGainsAndLoses(accounts.data[0]); foreach (var unrealized in unrealizedPNL.data) { Console.WriteLine(unrealized); } ``` ```cs { date = 2021/08/09, // Date of inquiry (string) account = 26, // Account (string) branchNo = 6460, // Branch number (string) stockNo = 2303, // Symbol (string) buySell = Buy, // Transaction direction (BsAction) orderType = Margin, // Order Type (OrderType) costPrice = 50, // Holding cost (double) tradableQty = 1000, // Available quantity (int) unrealizedProfit = 45600, // Unrealized profit (int) unrealizedLoss = 0 // Unrealized loss (int) } ``` #### Settlement information[​](#settlement-information "Direct link to Settlement information") You can inquire about Settlement information to confirm the amount receivable or payable for today or the past three days. * Python * Node.js * C# ```python settlement = sdk.accounting.query_settlement(accounts.data[0],"0d") print(settlement.data) ``` ```js const settlement = sdk.accounting.querySettlement(accounts.data[0],"0d") console.log(settlement.data) ``` ```cs var settlement = sdk.Accounting.QuerySettlement(accounts.data[0],"0d"); Console.WriteLine(settlement.data); Console.WriteLine(settlement.data.settle); ``` The results of the following inquiry represent a receivable delivery amount of 68,100 TWD for September 12th: * Python * Node.js * C# ```py SettlementData({ account: AccountRes { # Account Information branch_no: "6460", # Account (string) account: "26" # Branch number (string) }, details: [ # Settlement Information { date: "2023/09/08", # Query Date (Today) (string) settlement_date: "2023/09/12", # Settlement Date (string) buy_value: 735500, # Buying Value (int) buy_fee: 313, # Buying Fee (int) buy_settlement: -1429513, # Buying Payable / Receivable Amount (int) buy_tax: 0, # Buying Tax (int) sell_value: 770500, # Selling Value (int) sell_fee: 320, # Selling Fee (int) sell_settlement: 0, # Selling Payable / Receivable Amount (int) sell_tax: 2309, # Selling Tax (int) total_bs_value: 1506000, # Total Buying & Selling Value (int) total_fee: 633, # Total Fee (int) total_tax: 2309, # Total Tax (int) total_settlement_amount: -1429513, # Total Payable & Receivable Amount (int) currency: "TWD", # Currency (string) } ] }) ``` ```js { account: { // Account Information branch_no: '6460', // Account (string) account: '26' // Branch number (string) }, details: [ // Settlement Information { date: '2023/09/08', // Query Date (Today) (string) settlement_date: '2023/09/12', // Settlement Date (string) buyValue: 735500, // Buying Value (int) buyFee: 313, // Buying Fee (int) buySettlement: -1429513, // Buying Payable / Received Amount (int) buyTax: 0, // Buying Tax (int) sellValue: 770500, // Selling Value (int) sellFee: 320, // Selling Fee (int) sellSettlement: 0, // Selling Payable / Received Amount (int) sellTax: 2309, // Selling Tax (int) totalBsValue: 1506000, // Total Buying & Selling Amount (int) totalFee: 633, // Total Fee (int) totalSettlementAmount: -1429513, // Total Payable & Received Amount (int) totalTax: 2309, // Total Tax (int) currency: "TWD" // Currency (string) } ] } ``` ```cs { account = AccountRes { // Account Information account = 26, // Account (string) branchNo = 6460 // Branch number (string) }, details = [ // Settlement Information date = 2023/09/08, // Query Date (Today) (string) settlementDate = 2023/09/12, // Settlement Date (string) buyValue = 735500, // Buying Value (int) buyFee = 313, // Buying Fee (int) buySettlement = -1429513, // Buying Payable / Received Amount (int) buyTax = 0, // Buying Tax (int) sellValue = 770500, // Selling Value (int) sellFee = 320, // Selling Fee (int) sellSettlement = 0, // Selling Payable / Received Amount (int) sellTax = 2309, // Selling Tax (int) totalBsValue = 1506000, // Total Buying & Selling Amount (int) totalFee = 633, // Total Fee (int) totalSettlementAmount = -1429513, // Total Payable & Received Amount (int) totalTax = 2309, // Total Tax (int) currency = TWD // Currency (string) ] } ``` --- ### Unblock Order First, let's begin by understanding the concepts of block and unblock. Block and Unblock are two different ways used to describe events, operations, or communication methods. Here are their basic concepts and distinction: info Unblock mode ususally pairs with order and filled callbacks for order management info Block(阻塞)mode can also be used with concurrency programming to send multiple requests simultaneously Reference [**Concurrency Code Example**](#concurrency-code-example) ##### Block(阻塞):[​](#block阻塞 "Direct link to Block(阻塞):") Block operations refer to events or operations that occur in a predetermined sequence, and one operation must be completed before another can begin. Block is typically used in queue processing, where one task must wait for another to finish before it can proceed。 ![block](/TradeAPI/en/assets/images/normal_e-81f260e5278b74675bb38d33bd04514d.png) ##### Unblock(非阻塞):[​](#unblock非阻塞 "Direct link to Unblock(非阻塞):") Unblock operations refer to events or operations that do not have to occur in a fixed sequence and can be executed in parallel. One operation does not need to wait for the completion of another. Unblock processing is typically used in multi-tasking environments where unblock operations are needed to improve efficiency and performance. ![unblock](/TradeAPI/en/assets/images/async_e-578400269af66ffd8ed45da413266f23.png) ##### Using Block[​](#using-block "Direct link to Using Block") After placing the order, the Order Response received will contain the complete data, including fields such as the order number. * Python * Node.js * C# ```py #Create Order Object order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional field ) sdk.stock.place_order(accounts.data[0], order) #Place Order #Or Using #sdk.stock.place_order(accounts.data[0], order, False) ``` ```js //Create Order Object const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; sdk.stock.placeOrder(accounts.data[0], order); // Or Using //sdk.stock.placeOrder(accounts.data[0], order, false); ``` ```cs //Create Order Object var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null ); sdk.Stock.PlaceOrder(accounts.data[0] ,order); // Block mode //Or Using //sdk.Stock.PlaceOrder(accounts.data[0] ,order, false); ``` ##### Using Unblock[​](#using-unblock "Direct link to Using Unblock") After placing the order, the Order Response received will not contain the complete data, such as the order number. * Python * Node.js * C# ```py #Create Order Object order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional field ) sdk.stock.place_order(accounts.data[0], order, True) #Place Order ``` ```js //Create Order Object const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; sdk.stock.placeOrder(accounts.data[0], order, true); ``` ```cs //Create Order Object var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null ); sdk.Stock.PlaceOrder(accounts.data[0] ,order, true); // Place Order with unblock mode ``` The following are functions that support Unblock orders: * PlaceOrder - Plcae Order * ModifyPrice - Modify Order Price * ModifyQuantity - Modify Order Quantity * CancelOrder - Cancel Order ##### Concurrency Code Example[​](#concurrency-code-example "Direct link to Concurrency Code Example") * Python * Node.js * C# ```py import concurrent.futures #Create Order Object order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional ) # Place orders def my_place_order(): sdk.stock.place_order(accounts.data[0], order) #Place Order with concurrent.futures.ThreadPoolExecutor() as executor: # Submit 20 tasks futures = [executor.submit(my_place_order) for _ in range(20)] # Wait for all tasks to complete concurrent.futures.wait(futures) ``` ```js //Create Order Object const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; // Place orders function my_place_order() { return new Promise((resolve) => { sdk.stock.placeOrder(accounts.data[0], order); resolve(); }); } async function main() { const tasks = []; for (let i = 0; i < 20; i++) { tasks.push(my_place_order()); } await Promise.all(tasks); // Wait for all tasks to complete } main().then(() => { console.log("All tasks completed") }); ``` ```cs using System; using System.Threading.Tasks; // Create Order Object var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null ); // Place orders Task[] tasks = new Task[20]; for (int i = 0; i < 20; i++) { tasks[i] = Task.Run(() => sdk.Stock.PlaceOrder(accounts.data[0], order)); } Task.WaitAll(tasks); ``` --- ### Websocket Notification Examples(Co-lo Version) info Co-lo service is a premium service for high-frequency customers. To apply, please contact your broker agent for more information. The following are examples of websocket notifications for trading requests. The listed cases includes non-async (unblock=False) and async (unblock=True) functions. (For more information about async and non-async trading functions, please refer to [Unblock Order](https://www.fbs.com.tw/TradeAPI/en/docs/trading/guide/advance/asyn_order.md)) caution This document is for demostration only. It may not include all possible scenarios. #### Single Order Functions[​](#single-order-functions "Direct link to Single Order Functions") ##### New Single Order[​](#new-single-order "Direct link to New Single Order") ###### Non-async (unblock=False)[​](#non-async-unblockfalse "Direct link to Non-async (unblock=False)") 1. Order placed successfully * Notification(2 messages): The first notification has status=8, meaning that the sysmtem backend is ready to send to request out. The second notification has status=10, which implies the order is placed successfully. ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test45", last_time: "10:44:05.796", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test45", last_time: "10:44:05.797", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test45", last_time: "10:44:05.798", details: None, error_message: None, } } ``` 2. Failed * Notification(2 messages): The first notification has status=8, meaning that the sysmtem backend is ready to send to request out. The second notification has status=90, which implies the request failed. ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000024", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test97", last_time: "10:45:04.122", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 90, date: "2024/10/17", seq_no: "00098000024", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 90, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test97", last_time: "10:45:04.124", details: None, error_message: "超過跌停價[5656-後檯]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 超過跌停價, data: None } ``` ###### Async (unblock=True)[​](#async-unblocktrue "Direct link to Async (unblock=True)") 1. Order placed successfully * Notification(3 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order\_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq\_no can be used for later reference. The last notification has status=10, which means the order is placed successfully. ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test47", last_time: "10:45:44.303", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 8, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test47", last_time: "10:45:44.305", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test47", last_time: "10:45:44.305", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test47", last_time: "10:45:44.303", details: None, error_message: None, } } ``` 2. Failed * Notification(3 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order\_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq\_no can be used for later reference. The last notification has status=90 to implies the order is failed. ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000026", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 430, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 430, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 430, user_def: "Test77", last_time: "10:46:24.101", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000026", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 430, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 8, after_price_type: Limit, after_price: 430, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 430, user_def: "Test77", last_time: "10:46:24.102", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 90, date: "2024/10/17", seq_no: "00098000026", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 430, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 90, after_price_type: Limit, after_price: 430, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 430, user_def: "Test77", last_time: "10:46:24.103", details: None, error_message: "超過漲停價[5655-後檯]", } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000026", branch_no: "20603", account: "9809789", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 430, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 430, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 430, user_def: "Test77", last_time: "10:46:24.101", details: None, error_message: None, } } ``` ##### Change Order Price[​](#change-order-price "Direct link to Change Order Price") info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-async[​](#non-async "Direct link to Non-async") 1. Price change successfully * Notification(2 messages): Here we have function\_type=15 for changing the price. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 43, user_def: "Test47", last_time: "10:47:24.816", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 43, user_def: "Test47", last_time: "10:47:24.817", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 43, user_def: "Test47", last_time: "10:47:24.817", details: None, error_message: None, } } ``` 2. Fail to change the price * Notification(2 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to imply the request failed. info In this case, the request is rejected by the backend, so we have a nofitication with status=4. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test47", last_time: "10:48:00.682", details: None, error_message: None, } ======== ``` ```py ==改單主動回報== Code [DT3_10104]超過漲停價 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 19, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test47", last_time: "10:48:00.683", details: None, error_message: "超過漲停價", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 超過漲停價, data: None } ``` ###### Async[​](#async "Direct link to Async") 1. Price change successfully * Notification(2 messages): Here we have function\_type=15 for changing the price. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test47", last_time: "10:50:55.480", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test47", last_time: "10:50:55.481", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test47", last_time: "10:50:55.479", details: None, error_message: None, } } ``` 2. Fail to change the price * Notification(1 message): The notification with status=19 means that the request failed. info In this case, the request is rejected directly by the system, so there is **NO** status=4 notification. ```py ==Order Change Notification== Code [154]證券改價限價格格和原價格相同==>[00098000025] 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 19, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test47", last_time: "10:51:31.697", details: None, error_message: "證券改價限價格格和原價格相同==>[00098000025]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券改價限價格格和原價格相同==>[00098000025], data: None } ``` ##### Change Order Quantity[​](#change-order-quantity "Direct link to Change Order Quantity") info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-async[​](#non-async-1 "Direct link to Non-async") 1. Quantity change successfully * Notification(2 messages): Here we have function\_type=20 for changing the quantity. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test47", last_time: "10:53:11.924", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test47", last_time: "10:53:11.925", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test47", last_time: "10:53:11.926", details: None, error_message: None, } } ``` 2. Fail to change the quantity * Notification(1 message): Here we have function\_type=20 for changing the quantity. The notification with status=29 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000025] 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 29, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test47", last_time: "10:53:48.940", details: None, error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000025]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券減量使用剩餘數量大於有效單位數量==>[00098000025], data: None } ``` ###### Async[​](#async-1 "Direct link to Async") 1. Quantity change successfully * Notification(2 messages): function\_type=20 for changing the quantity. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test47", last_time: "10:54:17.774", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test47", last_time: "10:54:17.775", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test47", last_time: "10:54:17.773", details: None, error_message: None, } } ``` 2. Fail to change the quantity * Notification(1 message): function\_type=20 for changing the quantity. The notification with status=29 means that the request failed. (Request rejected by the system directly, no status=4 notification) ```py ==Order Change Notification== Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000025] 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 29, after_price_type: None, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test47", last_time: "10:54:54.455", details: None, error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000025]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py response: Result { is_success: False, message: 證券減量使用剩餘數量大於有效單位數量==>[00098000025], data: None } ``` ##### Delete Order[​](#delete-order "Direct link to Delete Order") caution If the order is **partially filled**, the final order status would be 40, otherwise it would be 30 info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-Async[​](#non-async-2 "Direct link to Non-Async") 1. Cancel successfully * Notification(2 messages): function\_type 30 for canceling an order. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=30 (40 if partially filled) to confirm the cancelation succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "Test47", last_time: "10:55:39.567", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 43, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "Test47", last_time: "10:55:39.568", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000025", branch_no: "20603", account: "9809789", order_no: "KQ009", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 43, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "Test47", last_time: "10:55:39.569", details: None, error_message: None, } } ``` 2. Fail to cancel * Notification(1 message): function\_type 30 for canceling an order. The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [115]證券委託目前狀態部分成交單已不允許取消交易 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00090000080", branch_no: "20603", account: "9809789", order_no: "KQ00A", asset_type: 1, market: None, market_type: UnSupported, stock_no: "1102", buy_sell: None, price_type: None, price: None, quantity: None, time_in_force: None, order_type: None, is_pre_order: false, status: 39, after_price_type: None, after_price: None, unit: None, after_qty: None, filled_qty: None, filled_money: None, before_qty: None, before_price: None, user_def: None, last_time: "10:59:25.982", details: None, error_message: "證券委託目前狀態部分成交單已不允許取消交易", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券委託目前狀態部分成交單已不允許取消交易, data: None } ``` ###### Async[​](#async-2 "Direct link to Async") 1. Cancel successfully * Notification(2 messages): function\_type 30 for canceling an order. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=30 (40 if partially filled) to confirm the cancelation succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test45", last_time: "11:00:06.415", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 43, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test45", last_time: "11:00:06.416", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test45", last_time: "11:00:06.414", details: None, error_message: None, } } ``` 2. Fail to cancel * Notification(1 message): function\_type 30 for canceling an order. The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [115]證券委託目前狀態取消單已不允許取消交易 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000023", branch_no: "20603", account: "9809789", order_no: "KQ008", asset_type: 1, market: None, market_type: UnSupported, stock_no: "1102", buy_sell: None, price_type: None, price: None, quantity: None, time_in_force: None, order_type: None, is_pre_order: false, status: 39, after_price_type: None, after_price: None, unit: None, after_qty: None, filled_qty: None, filled_money: None, before_qty: None, before_price: None, user_def: None, last_time: "11:00:35.797", details: None, error_message: "證券委託目前狀態取消單已不允許取消交易", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券委託目前狀態取消單已不允許取消交易, data: None } ``` #### Batch Orders[​](#batch-orders "Direct link to Batch Orders") **When a batch orders request is placed, the system will execute the order requests with threading.** In the examples below, we will use the following orders to showcase the notifications. ```py [Order { buy_sell: Buy, symbol: "1102", price: "42", quantity: 2000, market_type: Common, price_type: Limit, time_in_force: ROD, order_type: Stock, user_def: "batch1", }, Order { buy_sell: Buy, symbol: "1101", price: "32", quantity: 1000, market_type: Common, price_type: Limit, time_in_force: ROD, order_type: Stock, user_def: "batch2", }, Order { buy_sell: Buy, symbol: "2330", price: None, quantity: 1000, market_type: Common, price_type: Market, time_in_force: ROD, order_type: Stock, user_def: "batch3", }] ``` ##### Batch New Orders[​](#batch-new-orders "Direct link to Batch New Orders") * Notification(6 messages): Notifications include three with status=8 (the system backend is ready to send out the request) and another three status=10 (successful confirmation). ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "16:21:19", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "16:21:19", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: None, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Market, after_price: None, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: None, user_def: "batch3", last_time: "16:21:19", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "16:21:18.962", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "16:21:18.963", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: "x0007", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Market, after_price: 0, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 0, user_def: "batch3", last_time: "16:21:19", details: None, error_message: None, } ======== ``` * Function Return: For batch new orders, all returned data has status=4. There would not be order\_no in the data (because the orders have not be confirmed by the stock exchange yet), the seq\_no can be used for a later reference. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "16:21:18.999", details: None, error_message: None, }, OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: None, asset_type: None, market: None, market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 32, unit: None, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "16:21:18.999", details: None, error_message: None, }, OrderResult { function_type: 0, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: None, asset_type: None, market: None, market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: None, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Market, after_price: None, unit: None, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: None, user_def: "batch3", last_time: "16:21:18.999", details: None, error_message: None, }] } ``` ##### Batch Change Order Price[​](#batch-change-order-price "Direct link to Batch Change Order Price") **IMPORTANT. The request list cannot contain orders with the market price type, otherwise the whole request will be rejected.** * Notification(4 messages. We exclude the order with the market price type.): Two messages for ACK (status=4), another two messages of confirmation (status=10). ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "16:23:11.710", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "16:23:11.710", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "16:23:11.673", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "16:23:11.683", details: None, error_message: None, } ======== ``` * Function Return: All returned data of batch requests has status=4. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "16:23:11.708", details: None, error_message: None, }, OrderResult { function_type: 15, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "16:23:11.708", details: None, error_message: None, }] } ``` ##### Batch Change Order Quantity and Cancelation[​](#batch-change-order-quantity-and-cancelation "Direct link to Batch Change Order Quantity and Cancelation") Here we reduce some of the orders to quanitty 0, which is the same as deleting the order. * Notification(6 messages): Three messages of ACK (status=4);Quantity modification function\_type=20, success status=10; Order cancelation function\_type=30, cancel successfully status=30 ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "16:24:16.494", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: "x0007", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 0, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "16:24:16.494", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "16:24:16.494", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "16:24:16.554", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 33, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "16:24:16.558", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: "x0007", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 0, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "16:24:16.558", details: None, error_message: None, } ======== ``` * Function Return: Batch requests always have status=4. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000012", branch_no: "20706", account: "9809268", order_no: "x0007", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 0, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "16:24:16.492", details: None, error_message: None, }, OrderResult { function_type: 30, date: "2024/10/18", seq_no: "00098000011", branch_no: "20706", account: "9809268", order_no: "x0006", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 33, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "16:24:16.492", details: None, error_message: None, }, OrderResult { function_type: 20, date: "2024/10/18", seq_no: "00098000010", branch_no: "20706", account: "9809268", order_no: "x0005", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "16:24:16.492", details: None, error_message: None, }] } ``` #### Order Filled Notification[​](#order-filled-notification "Direct link to Order Filled Notification") Order filled notification includes order\_no and seq\_no for reference. ```py ==Order Filled Notification== Code None FilledData { date: "2024/10/17", branch_no: "20603", account: "9809789", order_no: "KQ00B", stock_no: "1102", buy_sell: Sell, order_type: Stock, seq_no: "00090000081", filled_no: "00000000002", filled_avg_price: 45.0, filled_qty: 2000, filled_price: 45.0, filled_time: "10:57:49.331", user_def: None, } ======== ``` --- ### Websocket Notification Examples(Standard Version) The following are examples of websocket notifications for trading requests. The listed cases includes non-async (unblock=False) and async (unblock=True) functions. (For more information about async and non-async trading functions, please refer to [Unblock Order](https://www.fbs.com.tw/TradeAPI/en/docs/trading/guide/advance/asyn_order.md)) caution This document is for demostration only. It may not include all possible scenarios. #### Single Order Functions[​](#single-order-functions "Direct link to Single Order Functions") ##### New Single Order[​](#new-single-order "Direct link to New Single Order") ###### Non-async (unblock=False)[​](#non-async-unblockfalse "Direct link to Non-async (unblock=False)") 1. Order placed successfully * Notification(1 messages): The notification has status=10, which implies the order is placed successfully. ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00000394159", branch_no: "20706", account: "9809268", order_no: "x0002", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test50", last_time: "11:24:40.378", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00000394159", branch_no: "20706", account: "9809268", order_no: "x0002", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test50", last_time: "11:24:40.378", details: None, error_message: None, } } ``` 2. Failed * Notification(1 messages): The notification has status=90, which implies the request failed. ```py ==New Order Notification== Code [4385715]單價輸入錯誤[4385715] 內容 OrderResult { function_type: 90, date: "2024/10/17", seq_no: "00000394160", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 430, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 90, after_price_type: Limit, after_price: 430, unit: 1000, after_qty: 0, filled_qty: None, filled_money: None, before_qty: 0, before_price: 430, user_def: "Test25", last_time: "11:25:25.670", details: None, error_message: "單價輸入錯誤[4385715]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 單價輸入錯誤[4385715], data: None } ``` ###### Async (unblock=True)[​](#async-unblocktrue "Direct link to Async (unblock=True)") 1. Order placed successfully * Notification(3 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order\_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq\_no can be used for later reference. The last notification has status=10, which means the order is placed successfully. ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test70", last_time: "11:25:54.188", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 8, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test70", last_time: "11:25:54.189", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test70", last_time: "11:25:54.163", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 43, user_def: "Test70", last_time: "11:25:54.188", details: None, error_message: None, } } ``` 2. Failed * Notification(3 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order\_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq\_no can be used for later reference. The last notification has status=90 to implies the order is failed. ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000032", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test64", last_time: "11:26:59.651", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code None 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000032", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 8, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test64", last_time: "11:26:59.652", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== Code [4385715]單價輸入錯誤[4385715] 內容 OrderResult { function_type: 90, date: "2024/10/17", seq_no: "00098000032", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 90, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test64", last_time: "11:26:59.658", details: None, error_message: "單價輸入錯誤[4385715]", } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000032", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 20, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 20, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 20, user_def: "Test64", last_time: "11:26:59.651", details: None, error_message: None, } } ``` ##### Change Order Price[​](#change-order-price "Direct link to Change Order Price") info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-async[​](#non-async "Direct link to Non-async") 1. Price change successfully * Notification(2 messages): Here we have function\_type=15 for changing the price. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 43, user_def: "Test70", last_time: "11:27:47.512", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 43, user_def: "Test70", last_time: "11:27:47.407", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: 43, user_def: "Test70", last_time: "11:27:47.407", details: None, error_message: None, } } ``` 2. Fail to change the price * Notification(2 messages): The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to imply the request failed. info In this case, the request is rejected by the backend, so we have a nofitication with status=4. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test70", last_time: "11:28:46.753", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code [4385715]單價輸入錯誤[4385715] 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 19, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test70", last_time: "11:28:46.754", details: None, error_message: "單價輸入錯誤[4385715]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 單價輸入錯誤[4385715], data: None } ``` ###### Async[​](#async "Direct link to Async") 1. Price change successfully * Notification(2 messages): Here we have function\_type=15 for changing the price. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test70", last_time: "11:29:43.593", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test70", last_time: "11:29:43.682", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "Test70", last_time: "11:29:43.592", details: None, error_message: None, } } ``` 2. Fail to change the price * Notification(1 message): The notification with status=19 means that the request failed. info In this case, the request is rejected directly by the system, so there is **NO** status=4 notification. ```py ==Order Change Notification== Code [154]證券改價限價格格和原價格相同==>[00098000031] 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 19, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test70", last_time: "11:30:20.330", details: None, error_message: "證券改價限價格格和原價格相同==>[00098000031]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py response: Result { is_success: False, message: 證券改價限價格格和原價格相同==>[00098000031], data: None } ``` ##### Change Order Quantity[​](#change-order-quantity "Direct link to Change Order Quantity") info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-async[​](#non-async-1 "Direct link to Non-async") 1. Quantity change successfully * Notification(2 messages): function\_type=20 for changing the quantity. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test70", last_time: "11:31:00.211", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test70", last_time: "11:31:00.332", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: 43, user_def: "Test70", last_time: "11:31:00.332", details: None, error_message: None, } } ``` 2. Fail to change the quantity * Notification(1 message): function\_type=20 for changing the quantity. The notification with status=29 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000031] 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 29, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test70", last_time: "11:31:51.980", details: None, error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000031]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券減量使用剩餘數量大於有效單位數量==>[00098000031], data: None } ``` ###### Async[​](#async-1 "Direct link to Async") 1. Quantity change successfully * Notification(2 messages): function\_type=20 for changing the quantity. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test70", last_time: "11:32:33.047", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test70", last_time: "11:32:33.215", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 3000, filled_qty: 0, filled_money: 0, before_qty: 3000, before_price: None, user_def: "Test70", last_time: "11:32:33.045", details: None, error_message: None, } } ``` 2. Fail to change the quantity * Notification(1 message): function\_type=20 for changing the quantity. The notification with status=29 means that the request failed. (Request rejected by the system directly, no status=4 notification) ```py ==Order Change Notification== Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000031] 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 29, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: None, user_def: "Test70", last_time: "11:33:18.679", details: None, error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000031]", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券減量使用剩餘數量大於有效單位數量==>[00098000031], data: None } ``` ##### Delete Order[​](#delete-order "Direct link to Delete Order") caution If the order is **partially filled**, the final order status would be 40, otherwise it would be 30 info No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification. The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready. ###### Non-Async[​](#non-async-2 "Direct link to Non-Async") 1. Cancel successfully * Notification(2 messages): function\_type 30 for canceling an order. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=30 (40 if partially filled) to confirm the cancelation succeed. ```py ==改單主動回報== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "Test70", last_time: "11:36:14.561", details: None, error_message: None, } ======== ``` ```py ==改單主動回報== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 43, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "Test70", last_time: "11:36:14.499", details: None, error_message: None, } ======== ``` * Function Return: ```py Result { is_success: True, message: None, data: OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000031", branch_no: "20706", account: "9809268", order_no: "x0003", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 43, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: 43, user_def: "Test70", last_time: "11:36:14.499", details: None, error_message: None, } } ``` 2. Fail to cancel * Notification(1 message): function\_type 30 for canceling an order. The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [115]證券委託目前狀態部分成交單已不允許取消交易 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00000394165", branch_no: "20706", account: "9809268", order_no: "x0007", asset_type: 1, market: None, market_type: UnSupported, stock_no: "1102", buy_sell: None, price_type: None, price: None, quantity: None, time_in_force: None, order_type: None, is_pre_order: false, status: 39, after_price_type: None, after_price: None, unit: None, after_qty: None, filled_qty: None, filled_money: None, before_qty: None, before_price: None, user_def: None, last_time: "11:39:57.468", details: None, error_message: "證券委託目前狀態部分成交單已不允許取消交易", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券委託目前狀態部分成交單已不允許取消交易, data: None } ``` ###### Async[​](#async-2 "Direct link to Async") 1. Cancel successfully * Notification(2 messages): function\_type 30 for canceling an order. The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=30 (40 if partially filled) to confirm the cancelation succeed. ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000033", branch_no: "20706", account: "9809268", order_no: "x0008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 41, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 41, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test4", last_time: "11:42:24.961", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000033", branch_no: "20706", account: "9809268", order_no: "x0008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 41, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 41, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test4", last_time: "11:42:25.125", details: None, error_message: None, } ======== ``` * Function Return: Because we use async version of the function, the function returns as soon as ACK (status=4) is available. ```py Result { is_success: True, message: None, data: OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000033", branch_no: "20706", account: "9809268", order_no: "x0008", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 41, quantity: 5000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 41, unit: 1000, after_qty: 5000, filled_qty: 0, filled_money: 0, before_qty: 5000, before_price: None, user_def: "Test4", last_time: "11:42:24.960", details: None, error_message: None, } } ``` 2. Fail to cancel * Notification(1 message): function\_type 30 for canceling an order. The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification). ```py ==Order Change Notification== Code [115]證券委託目前狀態取消單已不允許取消交易 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000033", branch_no: "20706", account: "9809268", order_no: "x0008", asset_type: 1, market: None, market_type: UnSupported, stock_no: "1102", buy_sell: None, price_type: None, price: None, quantity: None, time_in_force: None, order_type: None, is_pre_order: false, status: 39, after_price_type: None, after_price: None, unit: None, after_qty: None, filled_qty: None, filled_money: None, before_qty: None, before_price: None, user_def: None, last_time: "11:48:06.850", details: None, error_message: "證券委託目前狀態取消單已不允許取消交易", } ======== ``` * Function Return: Request failed, order detail is not provided. ```py Result { is_success: False, message: 證券委託目前狀態取消單已不允許取消交易, data: None } ``` #### Batch Orders[​](#batch-orders "Direct link to Batch Orders") **When a batch orders request is placed, the system will execute the order requests with threading.** In the examples below, we will use the following orders to showcase the notifications. ```py [Order { buy_sell: Buy, symbol: "1102", price: "42", quantity: 2000, market_type: Common, price_type: Limit, time_in_force: ROD, order_type: Stock, user_def: "batch1", }, Order { buy_sell: Buy, symbol: "1101", price: "32", quantity: 1000, market_type: Common, price_type: Limit, time_in_force: ROD, order_type: Stock, user_def: "batch2", }, Order { buy_sell: Buy, symbol: "2330", price: None, quantity: 1000, market_type: Common, price_type: Market, time_in_force: ROD, order_type: Stock, user_def: "batch3", }] ``` ##### Batch New Orders[​](#batch-new-orders "Direct link to Batch New Orders") * Notification(6 messages): Notifications include three with status=8 (the system backend is ready to send out the request) and another three status=10 (successful confirmation). ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "11:50:24.656", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "11:50:24.656", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: None, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 8, after_price_type: Market, after_price: None, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: None, user_def: "batch3", last_time: "11:50:24.656", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "11:50:24.796", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "11:50:24.796", details: None, error_message: None, } ======== ``` ```py ==New Order Notification== 內容 OrderResult { function_type: 10, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: "x0015", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Market, after_price: 0, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 0, user_def: "batch3", last_time: "11:50:24.806", details: None, error_message: None, } ======== ``` * Function Return: For batch new orders, all returned data has status=4. There would not be order\_no in the data (because the orders have not be confirmed by the stock exchange yet), the seq\_no can be used for a later reference. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: None, asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 42, user_def: "batch1", last_time: "11:50:24.655", details: None, error_message: None, }, OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: None, asset_type: None, market: None, market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Limit, after_price: 32, unit: None, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 32, user_def: "batch2", last_time: "11:50:24.655", details: None, error_message: None, }, OrderResult { function_type: 0, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: None, asset_type: None, market: None, market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: None, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: true, status: 4, after_price_type: Market, after_price: None, unit: None, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: None, user_def: "batch3", last_time: "11:50:24.655", details: None, error_message: None, }] } ``` ##### Batch Change Order Price[​](#batch-change-order-price "Direct link to Batch Change Order Price") **IMPORTANT. The request list cannot contain orders with the market price type, otherwise the whole request will be rejected.** * Notification(4 messages. We exclude the order with the market price type.): Two messages for ACK (status=4), another two messages of confirmation (status=10). ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 32, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "11:52:24.985", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 42, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "11:52:24.985", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "11:52:25.156", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "11:52:25.162", details: None, error_message: None, } ======== ``` * Function Return: All returned data of batch requests has status=4. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 32, user_def: "batch2", last_time: "11:52:24.984", details: None, error_message: None, }, OrderResult { function_type: 15, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: Limit, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: None, before_price: 42, user_def: "batch1", last_time: "11:52:24.984", details: None, error_message: None, }] } ``` ##### Batch Change Order Quantity and Cancelation[​](#batch-change-order-quantity-and-cancelation "Direct link to Batch Change Order Quantity and Cancelation") Here we reduce some of the orders to quanitty 0, which is the same as deleting the order. * Notification(6 messages): Three messages of ACK (status=4);Quantity modification function\_type=20, success status=10; Order cancelation function\_type=30, cancel successfully status=30 ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: "x0015", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 0, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "11:53:37.765", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "11:53:37.765", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 33, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "11:53:37.765", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: "x0015", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 0, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "11:53:37.790", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 30, after_price_type: None, after_price: 33, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "11:53:37.789", details: None, error_message: None, } ======== ``` ```py ==Order Change Notification== Code None 內容 OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "11:53:37.790", details: None, error_message: None, } ======== ``` * Function Return: Batch requests always have status=4. ```py Result { is_success: True, message: None, data: [OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000042", branch_no: "20706", account: "9809268", order_no: "x0015", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2330", buy_sell: Buy, price_type: Market, price: 0, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 0, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch3", last_time: "11:53:37.763", details: None, error_message: None, }, OrderResult { function_type: 30, date: "2024/10/17", seq_no: "00098000041", branch_no: "20706", account: "9809268", order_no: "x0013", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1101", buy_sell: Buy, price_type: Limit, price: 32, quantity: 1000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 33, unit: 1000, after_qty: 0, filled_qty: 0, filled_money: 0, before_qty: 1000, before_price: None, user_def: "batch2", last_time: "11:53:37.763", details: None, error_message: None, }, OrderResult { function_type: 20, date: "2024/10/17", seq_no: "00098000040", branch_no: "20706", account: "9809268", order_no: "x0014", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "1102", buy_sell: Buy, price_type: Limit, price: 42, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 4, after_price_type: None, after_price: 43, unit: 1000, after_qty: 1000, filled_qty: 0, filled_money: 0, before_qty: 2000, before_price: None, user_def: "batch1", last_time: "11:53:37.763", details: None, error_message: None, }] } ``` #### Order Filled Notification[​](#order-filled-notification "Direct link to Order Filled Notification") Order filled notification includes order\_no and seq\_no for reference. ```py ==Order Filled Notification== Code None FilledData { date: "2024/10/17", branch_no: "20706", account: "9809268", order_no: "x0007", stock_no: "1102", buy_sell: Sell, order_type: Stock, seq_no: "00000394165", filled_no: "00000000061", filled_avg_price: 43.0, filled_qty: 2000, filled_price: 43.0, filled_time: "11:38:08.535", user_def: None, } ======== ``` --- ### WebSocket Parameter Setting Fubon Neo API SDK leverages WebSocket to connect with Fubon servers, the standard ping/pong control frame mechanism is adopted and implemented. By default, a ping frame would be sent to the server every 30 seconds, and if pong response is not received for two cconsecutive attempts, the connection quality is judged to be weak and the connection would be dropped. To accomodate different usage scenarios, since version `2.2.1`, users can set this part of the parameters by themselves. When establishing a connection, you can specify the relevant parameters. For example, if you want to have a ping frame sent every 300 seconds, and drop the connection if three consecutive attempts failed, the corresponding method call would be: * Python * Node.js * C# ```python sdk = FubonSDK(300, 3) ``` ```js var sdk = new FubonSDK(300, 3); ``` ```cs var sdk = new FubonSDK(300, 3, "wss://neoapi.fbs.com.tw/TASP/XCPXWS"); ``` The first parameter is the during between two ping attempts (in seconds), and the second parameter is the maximum tolerable number of consecutive fail attempts. Best Practice It is common to encounter congestion of Internet from time to time, we recommend that the parameter setting should be less strict than the default value (30,2) to prevent over-sensitivity. Test Environment To connect to the test environment, use the following method call (for versions >= `2.2.1`): ```python # "wss://neoapitest.fbs.com.tw/TASP/XCPXWS" is the url for the testing environment sdk = FubonSDK(30, 3, "wss://neoapitest.fbs.com.tw/TASP/XCPXWS") # OR for C# and JavaScript, use # var sdk = new FubonSDK(30, 3, "wss://neoapitest.fbs.com.tw/TASP/XCPXWS"); ``` Note. The values for the first two arguments in the example are only for the demonstration purpose. They can be freely adjusted if needed. --- ### Python Callback Exception Handling When using Python callback functions, because they run in a separate thread, if an error occurs during the execution, the error message will not be automatically thrown back, which may cause obstacles in debugging. To resolve this, you can add the following decorator to the callback function. When an error occurs in the code, the error will be displayed in the console as usual: ```python import os import sys import traceback import functools def handle_exceptions(func): @functools.wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as exp: # Extract the full traceback tb_lines = traceback.format_exc().splitlines() # Find the index of the line related to the original function func_line_index = next((i for i, line in enumerate(tb_lines) if func.__name__ in line), -1) # Highlight the specific part in the traceback where the exception occurred relevant_tb = "\n".join(tb_lines[func_line_index:]) # Include traceback from the function name error_text = f"{func.__name__} exception: {exp}\nTraceback (most recent call last):\n{relevant_tb}" print(error_text, file=sys.stderr) # If you want to terminate the program completely, add the following line (P.S. Don't use with Jupyter) # os._exit(-1) return wrapper def on_event(code, content): print("===event=====") print(code) print(content) print("========") @handle_exceptions def on_order(code, content): print("==Order==") print(code) print(content) print("========") # Add some code that would cause exceptions test = {} print(test["key"]) # This will throw exception ``` In the above sample code, we deliberately put a line `print(test["key"])` in on\_order. Because `"key"` is not in the dictionary `test`, an error will occur. At this time, because we have added the `@handle_exceptions` decorator, after receiving a new order callback message, the console will print out: ```python on_order exception: 'key' Traceback (most recent call last): File "xxx.py", line 47, in on_order print(test["key"]) ~~~~^^^^^^^ KeyError: 'key' ``` --- ### Reconnect The following is a simple demonstration that automatically reconnects the trading socket when a disconnection event is detected using a callback: * Python * Node.js * C# ```py from fubon_neo.sdk import FubonSDK import threading # === Add Your Login Information === USER_ID = "ID" USER_PW = "Trade Password" CERT_PATH = "Certificate File Location" CERT_PW = "Certificate Password" # --- If you want also to reconnect the marketdata WebSocket, you can implement it here --- def handle_marketdata_ws_disconnect(code, msg): print(f"[Marketdata WS] Reconnection, reason: {code}, {msg}") # === Global process lock to prevent multiple triggerings === relogin_lock = threading.Lock() # === Initiate a FubonNeo SDK instnace === sdk = FubonSDK() accounts = None # To store account information after login successfully # === Order and other callback functions(to be implemented) === def on_order(code, msg): pass def on_order_changed(code, msg): pass def on_filled(code, msg): pass def re_login(): """ When connection dropped, reconnect and log in, and reset all callback functions. Use the process lock to prevent multiple triggerings. """ if not relogin_lock.acquire(blocking=False): print("[Reconnect] In progress, ignore this call") return try: global accounts, sdk print("[Reconnect] Try to log out before reconnecting...") try: sdk.logout() except Exception as e: print("[Reconnect] Exception while logging out:", e) try: sdk = FubonSDK() accounts = sdk.login(USER_ID, USER_PW, CERT_PATH, CERT_PW) except Exception as e: print("[Reconnect] Exception while logging in:", e) return if accounts.is_success: print("[Reconnect] Login successfully, reset all callback functions") # IMPORTANT: Please remeber to register all callback functions again! sdk.set_on_event(on_event) sdk.set_on_order(on_order) sdk.set_on_order_changed(on_order_changed) sdk.set_on_filled(on_filled) # Implement the marketdata reconnection here if needed handle_marketdata_ws_disconnect(-9000, "Auto-reconnect") else: print("[Reconnect] Reconnection failed") finally: relogin_lock.release() def on_event(code, content): """ FubonNeo SDK's event callback """ print("[Event] Code:", code, "| Content:", content) if code == "300": print("[Event] Connection dropped(Code 300), start reconnecting ...") re_login() # === Login and register callback functions === accounts = sdk.login(USER_ID, USER_PW, CERT_PATH, CERT_PW) if accounts.is_success: print("[Main] Login successful, registering callbacks ...") sdk.set_on_event(on_event) sdk.set_on_order(on_order) sdk.set_on_order_changed(on_order_changed) sdk.set_on_filled(on_filled) # Can set different account(if choices are available) acc = accounts.data[0] if hasattr(accounts, "data") else None else: print("[Main] Login failed!") # === Example: Simulate reconnecting event to test the program === on_event("300", "Test: WebSocket connection dropped") on_event("300", "Test:Trigger the relogin again to test the process lock") # --- End of The Example --- ``` ```js const { FubonSDK } = require('fubon-neo'); // === Add Your Login Information === const USER_ID = "ID"; const USER_PW = "Trade Password"; const CERT_PATH = "Certificate File Location"; const CERT_PW = "Certificate Password"; // === Global process lock (flag) to prevent multiple triggerings === let reloginLock = false; // === Initiate a FubonNeo SDK instnace=== let sdk = new FubonSDK(); let accounts = null; // To store account information after login successfully // === Order and other callback functions(to be implemented) === function onOrder(code, msg) {} function onOrderChanged(code, msg) {} function onFilled(code, msg) {} // --- If you want also to reconnect the marketdata WebSocket, you can implement it here --- function handleMarketdataWsDisconnect(code, msg) { console.log(`[Marketdata WS] Reconnection, reason: ${code}, ${msg}`); } function reLogin() { // Use the flag to prevent multiple triggering if (reloginLock) { console.log("[Reconnect] In progress, ignore this call"); return; } reloginLock = true; console.log("[Reconnect] Try to log out before reconnecting.."); try { // Cancel callback funtion registration sdk.setOnEvent(() => {}); sdk.setOnOrder(() => {}); sdk.setOnOrderChanged(() => {}); sdk.setOnFilled(() => {}); sdk.logout(); // It is ok for logout error, reconnecting anyway } catch (e) { console.log("[Reconnect] Exception while logging out:", e); } try { // Re-initialize a SDK instnace sdk = new FubonSDK(); accounts = sdk.login(USER_ID, USER_PW, CERT_PATH, CERT_PW); } catch (e) { console.log("[Reconnect] Exception while logging in:", e); reloginLock = false; return; } if (accounts && accounts.isSuccess) { console.log("[Reconnect] Login successfully, reset all callback functions"); # IMPORTANT: Please remeber to register all callback functions again! sdk.setOnEvent(onEvent); sdk.setOnOrder(onOrder); sdk.setOnOrderChanged(onOrderChanged); sdk.setOnFilled(onFilled); // Implement the marketdata reconnection here if needed handleMarketdataWsDisconnect(-9000, "Auto-reconnect"); } else { console.log("[Reconnect] Reconnection failed"); } reloginLock = false; } function onEvent(code, content) { // FubonNeo SDK's event callback console.log("[Event] Code:", code, "| Content:", content); if (code === "300") { console.log("[Event] Connection dropped(Code 300), start reconnecting ..."); reLogin(); } } // === Login and register callback functions === accounts = sdk.login(USER_ID, USER_PW, CERT_PATH, CERT_PW); if (accounts && accounts.isSuccess) { console.log("[Main] Login successful, registering callbacks ..."); sdk.setOnEvent(onEvent); sdk.setOnOrder(onOrder); sdk.setOnOrderChanged(onOrderChanged); sdk.setOnFilled(onFilled); // Can set different account(if choices are available) let acc = (accounts.data && accounts.data.length > 0) ? accounts.data[0] : null; } else { console.log("[Main] Login failed!"); } // === Example: Simulate reconnecting event to test the program === Promise.all([ Promise.resolve().then(() => onEvent("300", "Test: WebSocket connection dropped")), ]); // --- End of The Example --- ``` ```cs using System; using System.Threading; using FubonNeo.Sdk; class Program { // === Add Your Login Information === static string USER_ID = "ID"; static string USER_PW = "Trade Password"; static string CERT_PATH = "Certificate File Location"; static string CERT_PW = "Certificate Password"; // === Global process lock to prevent multiple triggerings === static object reloginLock = new object(); static bool isReloginRunning = false; // === Initiate a FubonSDK instnace === static FubonSDK sdk = new FubonSDK(); static dynamic accounts = null; // # To store account information after login successfully // === Order and other callback functions(to be implemented)=== static void OnOrder(string code, OrderResult data) { } static void OnOrderChanged(string code, OrderResult data) { } static void OnFilled(string code, FilledData data) { } // --- If you want also to reconnect the marketdata WebSocket, you can implement it here --- static void HandleMarketdataWsDisconnect(int code, string msg) { Console.WriteLine($"[Marketdata WS] Reconnection, reason: {code}, {msg}"); } static void ReLogin() { // Use the process lock and the flag to prevent multiple triggerings lock (reloginLock) { if (isReloginRunning) { Console.WriteLine("[Reconnect] In progress, ignore this call"); return; } isReloginRunning = true; } try { Console.WriteLine("[Reconnect] Try to log out before reconnecting..."); try { sdk.Logout(); } catch (Exception e) { Console.WriteLine("[Reconnect] Exception while logging out:" + e.Message); } try { sdk = new FubonSDK(); accounts = sdk.Login(USER_ID, USER_PW, CERT_PATH, CERT_PW); } catch (Exception e) { Console.WriteLine("[Reconnect] Exception while logging in:" + e.Message); return; } if (accounts != null && accounts.isSuccess) { Console.WriteLine("[Reconnect] Login successfully, reset all callback functions"); // IMPORTANT: Please remeber to register all callback functions again! sdk.OnEvent = OnEvent; sdk.OnOrder = OnOrder; sdk.OnOrderChanged = OnOrderChanged; sdk.OnFilled = OnFilled; // Implement the marketdata reconnection here if needed HandleMarketdataWsDisconnect(-9000, "Auto-reconnect"); } else { Console.WriteLine("[Reconnect] Reconnection failed"); } } finally { lock (reloginLock) { isReloginRunning = false; } } } static void OnEvent(string code, string content) { Console.WriteLine("[Event] Code: " + code + " | Content: " + content); if (code == "300") { Console.WriteLine("[Event] Connection dropped(Code 300), start reconnecting ..."); ReLogin(); } } static void Main(string[] args) { // === Login and register callback functions === accounts = sdk.Login(USER_ID, USER_PW, CERT_PATH, CERT_PW); if (accounts != null && accounts.isSuccess) { Console.WriteLine("[Main] Login successful, registering callbacks ..."); sdk.OnEvent = OnEvent; sdk.OnOrder = OnOrder; sdk.OnOrderChanged = OnOrderChanged; sdk.OnFilled = OnFilled; // Can set different account(if choice available) var acc = (accounts.data != null && accounts.data.Count > 0) ? accounts.data[0] : null; } else { Console.WriteLine("[Main] Login failed!"); } // === Example: Simulate reconnecting event to test the program === OnEvent("300", "Test: WebSocket connection dropped"); OnEvent("300", "Test:Trigger the relogin again to test the process lock"); // Pause the main program and wait for user's command Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } ``` --- ### Event/Notification Callback *** Callback Content Examples Callback content examples can be found at [Websocket Notification Examples](https://www.fbs.com.tw/TradeAPI/en/docs/trading/guide/advance/callback/callback_example_standard.md); The reference to content objects is available at [SDK Reference](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) #### Subscribe Order Callback[​](#subscribe-order-callback "Direct link to Subscribe Order Callback") * Python * Node.js * C# * C++ * Go ```py # A callback to receive order data def on_order(code, content): print("==Order==") print(code) print(content) # print(content.seq_no) # Print the order serial number sdk.set_on_order(on_order) ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) ```js //Callback to receive order data sdk.setOnOrder(function(order, content) { console.log("====order===\n",order, content)}); ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) ```cs public void OnOrder(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine("On Order" + response); } } ``` Or use function below: ```cs sdk.OnOrder += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); } ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) ```cpp void on_order(std::optional err, const OrderResult& data) override { if (err.has_value()) { std::cerr << "Error in on_order: " << err.value() << ", status: " << data.status.value() << std::endl; return; } if (data.order_no.has_value()) { // Or simply: if (data.order_no) std::cout << "on order: order_no - " << data.order_no.value() << ". status - " << data.status.value() << std::endl; } else { std::cout << "on order: order_no is not available. status - " << data.status.value() << std::endl; } }; ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) ```go sdk.OnOrder = func(err *string, data fubon.OrderResult) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Order: ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) #### Subscribe Change Order / Cancel Order Callback[​](#subscribe-change-order--cancel-order-callback "Direct link to Subscribe Change Order / Cancel Order Callback") * Python * Node.js * C# * C++ * Go ```py def on_order_changed(code, content): print("=Modified==") print(code) print(content) # print(content.seq_no) # Print the order serial number print("========") sdk.set_on_order_changed(on_order_changed) ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) ```js //Callback to receive Modified data sdk.setOnOrderChanged(function(order, content) { console.log("===Modified===\n", order, content)}); ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) ```cs public void OnOrderChanged(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Modified" + response); } } ``` Or use function below: ```cs sdk.OnOrderChanged += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); } ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) ```cpp void on_order_changed(std::optional err, const OrderResult& data) override { if (data.error_message.has_value()) { std::cout << "on_order_changed: " << data.order_no.value() << ", status: " << data.status.value() << ", message: " << data.error_message.value() << std::endl; } else { std::cout << "on_order_changed: " << data.order_no.value() << ", status: " << data.status.value() << std::endl; } }; ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) ```go sdk.OnOrderChanged = func(err *string, data fubon.OrderResult) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Change ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } ``` info For content object detail, please refer to [OrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) #### Subscribe Filled Callback[​](#subscribe-filled-callback "Direct link to Subscribe Filled Callback") * Python * Node.js * C# * C++ * Go ```py def on_filled(code, content): print("==Filled==") print(code) print(content) # print(content.filled_no) # Print the filled serial number print("========") sdk.set_on_filled(on_filled) ``` info For content object detail, please refer to [FilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) ```js sdk.setOnFilled(function(code, content) { console.log("===Filled===\n",code, content)}) ``` info For content object detail, please refer to [FilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) ```cs public void OnFilled(string code, FilledData data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Filled" + response); } } ``` Or use function below: ```cs sdk.OnFilled += (code, filledData) => { Console.WriteLine(code + filledData.ToString()); } ``` info For content object detail, please refer to [FilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) ```cpp void on_filled(std::optional err, const FilledData& data) override { if (err.has_value()) { std::cerr << "Error in on_order: " << err.value() << std::endl; return; } if (data.order_no.has_value()) { std::cout << "on order: " << data.order_no.value() << std::endl; } else { std::cout << "on order: order_no is not available." << std::endl; } }; ``` info For content object detail, please refer to [FilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#filleddata) ```go sdk.OnFilled = func(err *string, data fubon.FilledData) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Filled ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } ``` info For content object detail, please refer to [FilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#filleddata) #### Subscribe Events Callback[​](#subscribe-events-callback "Direct link to Subscribe Events Callback") * Python * Node.js * C# * C++ * Go ```py def on_event(code, content): print("===event=====") print(code) print(content) print("========") sdk.set_on_event(on_event) ``` ```js sdk.setOnEvent(function(code, content) { console.log("===Event===\n",code, content)}) ``` ```cs public void OnEvent(String code, String data) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Event" + response); } ``` Or use function below: ```cs sdk.OnEvent += (code, msg) => { Console.WriteLine(code + msg ); }; ``` ```cpp void on_event(std::string code, std::string data) override { std::cout< { Console.WriteLine(code + msg ); }; sdk.OnOrder += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); } sdk.OnOrderChanged += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); } sdk.OnFilled += (code, filledData) => { Console.WriteLine(code + filledData.ToString()); } ``` ```cpp struct CustomCallback : public fubon::Callback { void on_event(const std::string& code, const std::string& data) override { std::cout << code << " " << data << std::endl; } void on_order(std::optional err, const OrderResult& data) override { if (err.has_value()) { std::cerr << "Error in on_order: " << err.value() << ", status: " << data.status.value() << std::endl; return; } if (data.order_no.has_value()) { // Or simply: if (data.order_no) std::cout << "on order: order_no - " << data.order_no.value() << ". status - " << data.status.value() << std::endl; } else { std::cout << "on order: order_no is not available. status - " << data.status.value() << std::endl; } }; void on_order_changed(std::optional err, const OrderResult& data) override { if (data.error_message.has_value()) { std::cout << "on_order_changed: " << data.order_no.value() << ", status: " << data.status.value() << ", message: " << data.error_message.value() << std::endl; } else { std::cout << "on_order_changed: " << data.order_no.value() << ", status: " << data.status.value() << std::endl; } }; void on_filled(std::optional err, const FilledData& data) override { std::cout << data.order_no << " " << std::endl; }; void on_futopt_order(std::optional err, const FutOptOrderResult& data) override { return; //if (err.has_value()) { // std::cerr << "Error in on_order: " << err.value() << std::endl; // return; //} //if (data.order_no.has_value()) { // Or simply: if (data.order_no) // std::cout << "on order: " << data.order_no.value() << std::endl; //} //else { // std::cout << "on order: order_no is not available." << std::endl; //} }; void on_futopt_order_changed(std::optional err, const FutOptOrderResult& data) override { /*std::cout << data.order_no.value() << " " << std::endl;*/ return; }; void on_futopt_filled(std::optional err, const FutOptFilledData& data) override { //std::cout << data.order_no << " " << std::endl; return; }; }; int main() { auto callback = std::make_shared(); auto sdk = new FubonSDK(); sdk->register_callback(callback); /// More coding ... /// ... return 0; } ``` ```go import ( "encoding/json" "fmt" "fubon" "strings" ) func main(){ sdk.OnOrder = func(err *string, data fubon.OrderResult) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Order: ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } sdk.OnOrderChanged = func(err *string, data fubon.OrderResult) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Change ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } sdk.OnFilled = func(err *string, data fubon.FilledData) { s, _ := json.MarshalIndent(data, "", " ") fmt.Println("On Filled ", string(s)) if err != nil { fmt.Printf(" Error: %s\n", *err) } } sdk.OnEvent = func(data string, eventType string) { fmt.Printf("📡 OnEvent - Type: %s, Data: %s\n", eventType, data) if eventType == "disconnect" { fmt.Println("⚠️ Connection lost!") } } } ``` --- ### Trade *** This tutorial will demonstrate how to complete the entire buying and selling process #### Place Order[​](#place-order "Direct link to Place Order") We want to buy 2000 share of Fubon Financial Holdings at a price of 66.00, you can execute program as the example * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your Cert Path", "Your Cert Password") #If there is consolidation, multiple account information will be returned #Create order object order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force= TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional field ) sdk.stock.place_order(accounts.data[0], order) #place order ``` info Please refer to the [Python Libary](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) for placing orders for whole shares and odd lots ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID","Your password", "Your cert path", "Your cert password"); const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; sdk.stock.placeOrder(accounts.data[0],order); ``` info Please refer to the [Node.Js Libary](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) for placing orders for whole shares and odd lots ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var accounts = sdk.Login("Your ID","Your password", "Your cert path", "Your cert password"); // If there is consolidation, multiple account information will be returned var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.ROD, OrderType.Stock, null ); sdk.Stock.PlaceOrder(accounts.data[0],order); // To place an block order ``` info Please refer to the [C# Libary](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) for placing orders for whole shares and odd lots #### Confirm the order and trade notifications[​](#confirm-the-order-and-trade-notifications "Direct link to Confirm the order and trade notifications") If you want to confirm the status of that order, you can query the specified order using the example below: * Python * Node.js * C# ```python orderResults = sdk.stock.get_order_results(accounts.data[0]) print(orderResults) ``` ```js const orderResults = sdk.stock.getOrderResults(accounts.data[0]) console.log(orderResults) ``` ```cs var orderResults = sdk.Stock.GetOrderResults(accounts.data[0]); foreach (var results in orderResults) { Console.WriteLine(results); } ``` Based on the result, we can determine whether this order has been executed and the quantity that has been filled: * Python * Node.js * C# ```py [ { ... buy_sell: Buy, # Transaction direction. (BSAction) price: 66, #The original order price (float) quantity: 2000, #The original order quantity (int) after_price: 66, #The Valid order price (float) after_qty: 2000, #The Valid order quantity (int) filled_qty: 0, #Filled quantity (int) filled_money: 0, #Filled Vaule (int) stock_no: "2881", #symbol (string) order_no: "bA888", #The order number(string) last_time: "10:10:10.123", #The last modification time (string) ... } ] ``` ```json [ { ... "buySell": "Buy", // Transaction direction. (string) "price": 66, //The original order price (number) "quantity": 2000, //The original order quantity (number) "afterPrice": 66, //The Valid order price (number) "afterQty": 2000, //The Valid order quantity (number) "filledQty": 0, //Filled quantity (number) "filledMoney": 0, //Filled Vaule (number) "symbol": "2881", //symbol (string) "orderNo": "bA888", //The order number (string) "lastTime": "10:10:10.123", //The last modification time (string) ... } ] ``` ```cs { ... buySell = Buy, // Transaction direction. (BsAction) price = 66, //The original order price (double) quantity = 2000, //The original order quantity (int) afterPrice = 66, //The Valid order price (double) afterQty = 2000, //The Valid order quantity (int) filledQty = 0, //Filled quantity (int) filledMoney = 0, //Filled Vaule (int) symbol = "2881", //symbol (string) orderNo = "bA888", //The order number(string) lastTime = "10:10:10.123", //The last modification time (string) ... } ``` #### Modified order price[​](#modified-order-price "Direct link to Modified order price") Since the original price was unable to execute, we adjusted the original order price and changed it to 66.50 for the purchase: * Python * Node.js * C# ```python orderResults = sdk.stock.get_order_results(accounts.data[0]) modified_pirce = sdk.stock.make_modify_price_obj(orderResults.data[0],"66.5") sdk.stock.modify_price(accounts.data[0], modified_pirce) ``` ```js orderResults = sdk.stock.getOrderResults(accounts.data[0]) const modified_pirce = sdk.stock.makeModifyPriceObj(orderResults.data[0],"66.5") sdk.stock.modifyPrice(accounts.data[0],modified_pirce) ``` ```cs orderResults = sdk.Stock.GetOrderResults(accounts.data[0]); var modified_pirce = sdk.Stock.MakeModifyPriceObj(orderResults.data[0],"66.5"); sdk.Stock.ModifyPrice(accounts.data[0],modified_pirce); ``` "A few minutes later, we queried the order status again and found that it had been executed. * Python * Node.js * C# ```python orderResults = sdk.stock.get_order_results(accounts.data[0]) print(orderResults.data[0]) ``` ```py [ { ... buy_sell: Buy, # Transaction direction. (BSAction) price: 66, #The original order price (number) quantity: 2000, #The original order quantity (number) after_price: 66.5, #The Valid order price (number) after_qty: 1000, #The Valid order quantity (number) filled_qty: 1000, #Filled quantity (number) filled_money: 66000, #Filled Vaule (number) stock_no: "2881", #symbol (string) order_no: "bA888", #The order number (string) last_time: "10:13:12.123", #The last modification time (string) ... } ] ``` ```js orderResults = sdk.stock.getOrderResults(accounts.data[0]) console.log(orderResults.data[0]) ``` ```json { ... "buySell" : "Buy", // Transaction direction. (BSAction) "price" : 66, //The original order price (number) "quantity" : 2000, //The original order quantity (number) "afterPrice" : 66.5, //The Valid order price (number) "afterQty" : 1000, //The Valid order quantity (number) "filledQty" : 1000, //Filled quantity (int) "filledMoney" : 66000, //Filled Vaule (int) "stockNo" : "2881", //symbol (string) "orderNo" : "bA888", //The order number (string) "lastTime" : "10:13:12.123", //The last modification time (string) ... } ``` ```cs orderResults = sdk.Stock.GetOrderResults(accounts.data[0]); Console.WriteLine(orderResults.data[0]); ``` ```cs { ... buySell = Buy, // Transaction direction. (BsAction) price = 66, //The original order price (double) quantity = 2000, //The original order quantity (int) afterPrice = 66.5, //The Valid order price (double) afterQty = 1000, //The Valid order quantity (int) filledQty = 1000, //Filled quantity (int) filledMoney = 66000, //Filled Vaule (int) stockNo = "2881", //symbol (string) orderNo = "bA888", //The order number (string) lastTime = "10:13:12.123", //The last modification time (string) ... } ``` #### Sell Position[​](#sell-position "Direct link to Sell Position") Before the close, we decided to sell 1000 share of Fubon Financial Holdings. * Python * Node.js * C# ```python #Create order object order = Order( buy_sell = BSAction.Sell, symbol = "2881", price = "67", quantity = 1000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force= TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional field ) sdk.stock.place_order(accounts.data[0], order) #Place Order ``` ```js order = { buySell: BSAction.Sell, symbol: "2881", price: "66", quantity: 1000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; sdk.stock.placeOrder(accounts.data[0],order) ``` ```cs order = new Order( BsAction.Sell, "2881", "66", 1000, MarketType.Common, PriceType.Limit, TimeInForce.ROD, OrderType.Stock, null ); sdk.Stock.PlaceOrder(accounts.data[0],order); // To place an block order ``` --- ### Fubon Neo API *** Key takeaways * Overview of Fubon Neo API trading and market services. * Supports multiple languages and cross-platform development. * Next step: [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md). | Item | Details | | --------- | ------------------------------------------------------------------------------------------------------- | | Product | Fubon Neo API | | Services | Trading / Market Data | | Platforms | Windows / macOS / Linux | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Login | Certificate login (API Key optional) | #### Overview[​](#overview "Direct link to Overview") Fubon Neo API provides comprehensive trading and market APIs for your programmatic trading needs, catering to every developer's quantitative and automated trading requirements. Our API allows users to freely choose from mainstream programming languages (Python, C#, JavaScript) and easily access the API during the process of creating programmatic trades, utilizing trading and market services. #### Features[​](#features "Direct link to Features") Cross-platform support: Fubon Neo API supports Windows, MacOS, and Linux.
It also supports mainstream languages like Python, C#, and JavaScript. Stable technical architecture for direct connectivity to exchanges. Customizable market data solutions. #### Key Functions[​](#key-functions "Direct link to Key Functions") Direct trade management: Create orders, modify or cancel orders, and inquire about order status, as well as access historical order records and trade details。
View account information: Retrieve stock gains and losses, realized gains and losses, unrealized gains and losses, maintenance margin。 Receive real-time market data: Various market data information, including stock prices, warrants, options prices。 #### Version Support[​](#version-support "Direct link to Version Support") Python support: 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported).
Node.js Support : 16 and above.
C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. --- ### Bank Balance Inquiry BankRemain #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### BankRemain Fields[​](#bankremain-fields "Direct link to BankRemain Fields") Return type : Object | Parameter | Type | Description | | ------------------ | ------ | ----------------- | | branch\_no | string | Branch code | | account | string | Account number | | currency | string | Currency | | balance | int | Balance | | available\_balance | int | Available Balance | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto bankremain_response = sdk->accounting->bank_remain(target_account); if (bankremain_response.is_success && bankremain_response.data.has_value()) { const auto& bank_remain = bankremain_response.data.value(); // With custom .cpp & hpp Output std::cout << bank_remain << std::endl; } else { std::cout << bankremain_response.message.value() << std::endl; } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp // With custom .cpp & hpp Output { is_success = true, message = , data = BankRemain{ branch_no = 6460, // Branch Code (string) account = 26, // Account Number (string) currency = TWD, // Currency (string) balance = 666666, // Balance (int) available_balance = 123456 // Available Balance (int) } } ``` --- ### Inventory Inquiry inventories #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### Inventory Fields[​](#inventory-fields "Direct link to Inventory Fields") Return type : Object | Parameter | Type | Description | | -------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | | > date | string | Trade Date | | > account | string | Account number | | > branch\_no | string | Branch code | | > stock\_no | string | Stock symbol | | > order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | > lastday\_qty | int | Previous Day Balance | | > buy\_qty | int | Today's Buy Order Qty | | > buy\_filled\_qty | int | Today's Buy Filled Qty | | > buy\_value | int | Buy Value | | > today\_qty | int | Today's Balance | | > tradable\_qty | int | Tradable Quantity | | > sell\_qty | int | Today's Sell Order Qty | | > sell\_filled\_qty | int | Today's Sell Filled Qty | | > sell\_value | int | Sell Value | | > odd | list | Object | | >> lastday\_qty | int | Previous Day Balance | | >> buy\_qty | int | Today's Buy Order Qty | | >> buy\_filled\_qty | int | Today's Buy Filled Qty | | >> buy\_value | int | Buy Value | | >> today\_qty | int | Today's Balance | | >> tradable\_qty | int | Tradable Quantity | | >> sell\_qty | int | Today's Sell Order Qty | | >> sell\_filled\_qty | int | Today's Sell Filled Qty | | >> sell\_value | int | Sell Value | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto inventories_response = sdk->accounting->inventories(target_account); if (!inventories_response.is_success) { std::cerr << "Inventories query failed: " << (inventories_response.message.has_value() ? inventories_response.message.value() : "No message") << std::endl; } // With custom .cpp & hpp Output else if (inventories_response.data.has_value()) { const auto& inventories = inventories_response.data.value(); for (const auto& inventory : inventories) { std::cout << inventory << std::endl; } } else { std::cout << "Inventories query succeeded but no data returned." << std::endl; } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [ Inventory{ date = 2023/10/13, // Trade Date (string) account = 26, // Account Number (string) branchNo = 6460, // Branch Code (string) stockNo = 1101, // Stock Symbol (string) orderType = STOCK, // Order Type (OrderType) lastdayQty = 2000, // Previous Day Balance (int) buyQty = 0, // Today's Buy Order Qty (int) buyFilledQty = 0, // Today's Buy Filled Qty (int) buyValue = 0, // Buy Value (int) todayQty = 2000, // Today's Balance (int) tradableQty = 2000, // Tradable Qty (int) sellQty = 0, // Today's Sell Order Qty (int) sellFilledQty = 0, // Today's Sell Filled Qty (int) sellValue = 0, // Sell Value (int) odd = InventoryOdd { // Odd Lot Object lastdayQty = 0, // Previous Day Balance (int) buyQty = 0, // Today's Buy Order Qty (int) buyFilledQty = 0, // Today's Buy Filled Qty (int) buyValue = 0, // Buy Value (int) todayQty = 0, // Today's Balance (int) tradableQty = 0, // Tradable Qty (int) sellQty = 0, // Today's Sell Order Qty (int) sellFilledQty = 0, // Today's Sell Filled Qty (int) sellValue = 0 // Sell Value (int) } }, ... ] } ``` --- ### Maintenance Ratio Inquiry Maintenance #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### MaintenanceData Fields[​](#maintenancedata-fields "Direct link to MaintenanceData Fields") Return type : Object | Parameter | Type | Description | | ----------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | | maintenance\_data | list | Object | | > date | string | Query Date | | > branch\_no | string | Branch code | | > account | string | Account number | | > maintenance\_summary | list | Object | | >> margin\_value | int | Total Margin Value | | >> shortsell\_value | int | Total Short Sell Value | | >> shortsell\_margin | int | Total Short Sell Margin | | >> collateral | int | Collateral | | >> margin\_loan\_amt | int | Total Margin Loan Amount | | >> maintenance\_ratio | double | Overall Maintenance Ratio | | > maintenance\_detail | list | Object | | >> stock\_no | string | Stock Symbol | | >> order\_no | string | Order Book Number | | >> order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | >> quantity | int | Quantity Held | | >> price | double | Calculation Price | | >> cost\_price | double | Cost Price | | >> shortsell\_margin | int | Short Sell Margin | | >> collateral | int | Collateral | | >> margin\_loan\_amt | int | Margin Loan Amount | | >> maintenance\_ratio | double | Maintenance Ratio | | >> collateral\_interest | double | Collateral Interest | | >> margin\_interest | double | Margin Loan Interest | | >> shortsell\_interest | double | Short Sell Margin Interest | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto maintenance_response = sdk->accounting->maintenance(target_account); if (maintenance_response.is_success){ // With custom .cpp & hpp Output std::cout << maintenance_response.data.value() << std::endl; } ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```cpp { isSuccess = true, message = , data = MaintenanceData { date = 2024/02/27, branchNo = 6460, account = 26, maintenanceSummary = MaintenanceSummary { marginValue = 3135000, shortsellValue = 0, shortsellMargin = 0, collateral = 0, marginLoanAmt = 1494000, maintenanceRatio = 209.83 }, maintenanceDetail = [{ stockNo = 2603, orderNo = x4580, orderType = Stock, quantity = 10000, price = 152.5, costPrice = 119, shortsellMargin = 0, collateral = 0, marginLoanAmt = 0, maintenanceRatio = 213.58, collateralInterest = 0, marginInterest = 20818, shortsellInterest = 0 }, ... ], } } ``` --- ### Settlement Inquiry QuerySettlement #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | | range | string | Date range, valid values: "0d" (Today), "3d" | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### SettlementData Fields[​](#settlementdata-fields "Direct link to SettlementData Fields") Return type : Object | Parameter | Type | Description | | ---------------------------- | ----------------- | ----------------------------------------- | | > account | object | Object | | >> account | string | Account number | | >> branch\_no | string | Branch code | | > details | list | Object | | >> date | string | Query Date | | >> settlement\_date | string (Optional) | Settlement Date (Null if no data) | | >> buy\_value | int (Optional) | Buy Value (Null if no data) | | >> buy\_fee | int (Optional) | Buy Fee (Null if no data) | | >> buy\_settlement | int (Optional) | Buy Receivable/Payable (Null if no data) | | >> buy\_tax | int (Optional) | Buy Tax (Null if no data) | | >> sell\_value | int (Optional) | Sell Value (Null if no data) | | >> sell\_fee | int (Optional) | Sell Fee (Null if no data) | | >> sell\_settlement | int (Optional) | Sell Receivable/Payable (Null if no data) | | >> sell\_tax | int (Optional) | Sell Tax (Null if no data) | | >> total\_bs\_value | int (Optional) | Total Buy/Sell Value (Null if no data) | | >> total\_fee | int (Optional) | Total Fee (Null if no data) | | >> total\_tax | int (Optional) | Total Tax (Null if no data) | | >> total\_settlement\_amount | int (Optional) | Total Settlement Amount (Null if no data) | | >> currency | string (Optional) | Currency (Null if no data) | #### Request Example[​](#request-example "Direct link to Request Example") ```cs auto settlement_response = sdk->accounting->query_settlement(target_account, "3d"); // With custom .cpp & hpp Output if (settlement_response.is_success && settlement_response.data.has_value()) { std::cout << *settlement_response.data << std::endl; } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = SettlementData{ account = AccountRes { // Account Info account = 26, // Account Number (string) branchNo = 6460 // Branch Code (string) }, details = [ Settlement{ // Settlement Details date = 2024/03/04, // Query Date (string) settlementDate = 2024/03/06, // Settlement Date (string) buyValue = 735500, // Buy Value (int) buyFee = 313, // Buy Fee (int) buySettlement = -1429513, // Buy Settlement Amount (int) buyTax = 0, // Buy Tax (int) sellValue = 770500, // Sell Value (int) sellFee = 320, // Sell Fee (int) sellSettlement = 0, // Sell Settlement Amount (int) sellTax = 2309, // Sell Tax (int) totalBsValue = 1506000, // Total B/S Value (int) totalFee = 633, // Total Fee (int) totalSettlementAmount = -1429513, // Total Settlement Amount (int) totalTax = 2309, // Total Tax (int) currency = TWD // Currency (string) }, Settlement{ date = 2024/03/05, // Query Date (string) settlementDate = 2024/03/07, // Settlement Date (string) buyValue = 2261470, // Buy Value (int) buyFee = 1065, // Buy Fee (int) buySettlement = -3895335, // Buy Settlement Amount (int) buyTax = 0, // Buy Tax (int) sellValue = 2488170, // Sell Value (int) sellFee = 1137, // Sell Fee (int) sellSettlement = 677626, // Sell Settlement Amount (int) sellTax = 7412, // Sell Tax (int) totalBsValue = 4749640, // Total B/S Value (int) totalFee = 2202, // Total Fee (int) totalSettlementAmount = -3217709, // Total Settlement Amount (int) totalTax = 7412, // Total Tax (int) currency = TWD // Currency (string) }, // ... (omitted for brevity) ] } } ``` --- ### Realized P&L Detail Inquiry realized\_gains\_and\_loses #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### Realized Fields[​](#realized-fields "Direct link to Realized Fields") Return type : Object | Parameter | Type | Description | | ---------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | | date | string | Data Date | | branch\_no | string | Branch code | | account | string | Account number | | stock\_no | string | Stock symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | filled\_qty | int | Filled Quantity | | filled\_price | double | Filled Price | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | realized\_profit | int | Realized Profit | | realized\_loss | int | Realized Loss | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto realized_response = sdk->accounting->realized_gains_and_loses(target_account); // With custom .cpp & hpp Output if (realized_response.is_success && realized_response.data.has_value()) { for (const auto& r : *realized_response.data) { std::cout << r << std::endl; } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data =[ Realized{ date = 2023/08/16, // Data Date (string) branchNo = 6460, // Branch Code (string) account = 26, // Account Number (string) stockNo = 1101, // Stock Symbol (string) buySell = SELL, // Side (BSAction) filledQty = 1000, // Filled Quantity (int) filledPrice = 36.5, // Filled Price (double) orderType = STOCK, // Order Type (OrderType) realizedProfit = 36339, // Realized Profit (int) realizedLoss = 0 // Realized Loss (int) }, ... ] } ``` --- ### Realized P&L Summary realized\_gains\_and\_loses\_summary #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### RealizedSummary Fields[​](#realizedsummary-fields "Direct link to RealizedSummary Fields") Return type : Object | Parameter | Type | Description | | --------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | | start\_date | string | Summary start date | | end\_date | string | Summary end date | | branch\_no | string | Branch code | | account | string | Account number | | stock\_no | string | Stock symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Spot), `MARGIN` (Margin Buy), `SHORT` (Short Sell), `DAY_TRADE` (Day Trade), `SBL` (Securities Borrowing) | | filled\_qty | int | Filled quantity | | filled\_avg\_price | double | Average filled price | | realized\_profit\_and\_loss | int | Realized P\&L amount | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto realized_summary_response = sdk->accounting->realized_gains_and_loses_summary(target_account); // With custom .cpp & hpp Output if (realized_summary_response.is_success && realized_summary_response.data.has_value()) { const auto& realized_list = *realized_summary_response.data; for (const auto& item : realized_list) { std::cout << item << std::endl; } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [ RealizedSummary{ startDate = 20230801, // Start Date (string) endDate = 20230801, // End Date (string) branchNo = 6460, // Branch Code (string) account = 26, // Account Number (string) stockNo = 1101, // Stock Symbol (string) buySell = SELL, // Side (BSAction) orderType = STOCK, // Order Type (OrderType) filledQty = 3000, // Filled Quantity (int) filledAvgPrice = 35.7, // Average Filled Price (double) realizedProfitAndLoss = 34026 // Realized P&L Amount (int) }, ... ] } ``` --- ### Unrealized P&L Detail Inquiry unrealized\_gains\_and\_loses #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account number | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | | is\_success | bool | Success status | | data | BankRemain | Returns balance information | | message | string | Returns error message when `is_success = False` | ##### UnrealizedData Fields[​](#unrealizeddata-fields "Direct link to UnrealizedData Fields") Return type : Object | Parameter | Type | Description | | ------------------ | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | | date | string | Inventory Date | | branch\_no | string | Branch code | | stock\_no | string | Stock symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | cost\_price | double | Cost Price | | tradable\_qty | int | Tradable Balance | | today\_qty | int | Today's Balance | | unrealized\_profit | int | Unrealized Profit | | unrealized\_loss | int | Unrealized Loss | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto unrealized_response = sdk->accounting->unrealized_gains_and_loses(target_account); // With custom .cpp & hpp Output if (unrealized_response.is_success && unrealized_response.data.has_value()) { for (const auto& u : *unrealized_response.data) { std::cout << u << std::endl; } } ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```cpp { isSuccess = True, message = , data = [ UnrealizedData{ date = 2021/08/09, // Inventory Date (string) account = 26, // Account Number (int) branchNo = 6460, // Branch Code (string) stockNo = 2303, // Stock Symbol (string) buySell = BUY, // Side (BSAction) orderType = SHORT, // Order Type (OrderType) costPrice = 50.0, // Cost Price (double) tradableQty = 1000, // Tradable Balance (int) todayQty = 1000, // Today's Balance (int) unrealizedProfit = 45200, // Unrealized Profit (int) unrealizedLoss = 0 // Unrealized Loss (int) } ] } ``` --- ### List of Enumerations #### Classes[​](#classes "Direct link to Classes") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | -------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | buy\_sell | BSAction | [Side](#bsaction) Options: `BUY`, `SELL` | | symbol | string | Stock Symbol | | price | string | Order Price (Enter ***std::nullopt*** if not using `LIMIT` price) | | quantity | int | Order Quantity | | market\_type | MarketType | [Market Type](#markettype) Options: `COMMON` (Round Lot), `FIXING` (Fixed Price), `INTRADAY_ODD` (Intraday Odd Lot), `ODD` (Post-market Odd Lot), `EMG` (Emerging Market), `EMG_ODD` (Emerging Odd Lot) | | price\_type | PriceType | [Price Flag](#pricetype) Options: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) Options: `ROD`, `FOK`, `IOC` | | order\_type | OrderType | [Order Type](#ordertype) Options: `STOCK` (Spot), `MARGIN` (Margin Buy), `SHORT` (Short Sell), `DAY_TRADE` (Day Trade - Sell First), `SBL` (Securities Borrowing) | | user\_def (optional) | string | User Defined Field (Max 10 characters, no special characters or Chinese, not applicable for Emerging Markets) | caution The unit and range for `quantity` vary depending on the `MarketType`. Please refer to the [Market Type](#markettype) section. caution When `MarketType` is `MarketType.COMMON`, `MarketType.ODD`, or `MarketType.INTRADAY_ODD`, and `priceType` is `PriceType.LIMIT`, the `price` field must be filled. In other cases, the `price` field should be `std::nullopt`. caution For Day Trade Sell First: `order_type` must be `DAY_TRADE`, `buy_sell` must be `SELL`, and `market_type` must be `COMMON`. ##### OrderResult[​](#orderresult "Direct link to OrderResult") Order list, retrieved via [get\_order\_result(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/trade/GetOrderResults.md). | Parameter | Type | Description | | ------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` New Order Execution, `15` Modify Price, `20` Modify Qty, `30` Cancel Order, `90` Failed | | date | string | Trade Date | | seq\_no | string | Order Sequence Number | | branch\_no | string | Branch Code | | account | string | Account Number | | order\_no | string | Order Book Number | | asset\_type | int | Asset Type: `0` Securities | | market | string | Market Type: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | MarketType | Trading Unit: `COMMON`, `FIXING`, `INTRADAY_ODD`, `ODD`, `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | BSAction | Side: `BUY`, `SELL` | | price\_type | PriceType | Original Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | TimeInforce | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | OrderType | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Timeout, `10` Success, `30` Cancelled (Unfilled), `40` Partially Filled (Remainder Cancelled), `50` Fully Filled, `90` Failed | | after\_price\_type | PriceType | Effective Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | after\_price | double | Effective Price | | unit | int | Unit Count | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Valid Qty Before Modification | | before\_price | double | Valid Price Before Modification | | user\_def | string | Custom Field | | last\_time | string | Last Modified Time (See format below) | | error\_message | string | Error Message | | details | list | Order History (Populated when querying order\_result\_detail or order\_history) | | >> function\_type | int | Function Type: `0` New, `10` Exec, `15` Mod Price, `20` Mod Qty, `30` Cancel, `50` Filled, `90` Fail | | >> modified\_time | string | Modification Time (See format below) | | >> before\_qty | int | Original Order Qty | | >> after\_qty | int | Effective Order Qty (Includes filled) | | >> before\_price | double | Original Order Price | | >> after\_price | double | Effective Order Price | | >> filled\_money | double | Filled Amount | | >> status | int | Order Status | | >> err\_msg | string | Error Message | Time Format Description Time format for `last_time` and `modified_time`: **HH:MM:SS.fff** or **HH:MM:SS** (omitted when .fff = .000). ##### BatchResult[​](#batchresult "Direct link to BatchResult") Batch order list, retrieved via [BatchOrderLists(account)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/trade/batchOrder/BatchOrderList.md). | Parameter | Type | Meaning | | -------------- | ------ | --------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New, `10` Exec, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Fail | | date | string | Trade Date | | branch\_no | string | Branch Code | | account | string | Account Number | | batch\_seq\_no | string | Batch Sequence Number | ##### ModifyPriceObj[​](#modifypriceobj "Direct link to ModifyPriceObj") Object for modifying price. | Parameter | Type | Meaning | | ------------- | --------- | ------------------------------------------------------------------------ | | order\_result | Object | [Order List](#orderresult) | | price | string | New Price | | price\_type | PriceType | New Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | ##### ModifyQuantityObj[​](#modifyquantityobj "Direct link to ModifyQuantityObj") Object for modifying quantity. | Parameter | Type | Meaning | | ------------- | ------ | -------------------------- | | order\_result | Object | [Order List](#orderresult) | | quantity | int | New Quantity | ##### FilledData[​](#filleddata "Direct link to FilledData") Trade execution report object. | Parameter | Type | Description | | ------------------ | --------- | ------------------------------------------------------------- | | date | string | Date | | branch\_no | string | Branch Code | | account | string | Account Number | | seq\_no | string | Order Sequence Number (Only returned for active push reports) | | order\_no | string | Order Book Number | | stock\_no | string | Stock Symbol | | buy\_sell | BSAction | Side: `BUY`, `SELL` | | order\_type | OrderType | Order Type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | filled\_no | string | Execution Sequence Number | | filled\_avg\_price | double | Average Filled Price | | filled\_qty | int | Filled Quantity | | filled\_price | double | Filled Price | | filled\_time | string | Filled Time | | user\_def | string | User Defined Field (Only returned for active push reports) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ------------- | ------ | -------------------------------------------------------------- | | name | string | Client Name | | account | string | Account Number | | branch\_no | string | Branch Code | | account\_type | string | Account Type: `stock` (Securities), `futopt` (Futures/Options) | #### Constants (Field Value Mapping)[​](#constants-field-value-mapping "Direct link to Constants (Field Value Mapping)") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy/Sell Action | Name | Value | Meaning | | ------------- | ----- | ---------------- | | BUY | 1 | Buy | | SELL | 2 | Sell | | UN\_SUPPORTED | 3 | Unsupported Type | | UN\_DEFINED | 4 | Undefined Type | ##### MarketType[​](#markettype "Direct link to MarketType") Market Type (Trading Unit) | Name | Value | Meaning | | ------------- | ----- | ------------------- | | COMMON | 1 | Round Lot | | FIXING | 2 | Fixed Price | | ODD | 3 | Post-market Odd Lot | | INTRADAY\_ODD | 4 | Intraday Odd Lot | | EMG | 5 | Emerging Market | | EMG\_ODD | 6 | Emerging Odd Lot | | UN\_SUPPORTED | 7 | Unsupported Type | | UN\_DEFINED | 8 | Undefined Type | The unit and range for Quantity differ when using different MarketTypes, as shown below: | Name | Quantity Unit | Quantity Ranges | | ------------- | ------------- | --------------- | | COMMON | 1000 Shares | 1000 ~ 499000 | | FIXING | 1000 Shares | 1000 ~ 499000 | | INTRADAY\_ODD | Shares | 1 ~ 999 | | ODD | Shares | 1 ~ 999 | | EMG | 1000 Shares | 1000 ~ 499000 | | EMG\_ODD | Shares | 1 ~ 999 | Available `PriceType` and `TimeInForce` vary by `MarketType`, as shown below: | MarketType | Available PriceType | Available TimeInForce | | ------------- | ------------------------------------------------ | --------------------- | | COMMON | LIMIT, LIMIT\_UP, LIMIT\_DOWN, MARKET, REFERENCE | ROD, IOC, FOK | | FIXING | REFERENCE | ROD | | INTRADAY\_ODD | LIMIT, LIMIT\_UP, LIMIT\_DOWN, REFERENCE | ROD | | ODD | LIMIT, LIMIT\_UP, LIMIT\_DOWN, REFERENCE | ROD | | EMG | LIMIT | ROD | | EMG\_ODD | LIMIT | ROD | ##### PriceType[​](#pricetype "Direct link to PriceType") Price Type | Name | Value | Meaning | | ------------- | ----- | ------------------------------------------- | | LIMIT | 1 | Limit Price | | LIMIT\_UP | 2 | Limit Up (Ceiling) | | LIMIT\_DOWN | 3 | Limit Down (Floor) | | MARKET | 4 | Market Price | | REFERENCE | 5 | Reference Price (Fixed Price during fixing) | | UN\_SUPPORTED | 6 | Unsupported Type | | UN\_DEFINED | 7 | Undefined Type | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force Condition | Name | Value | Meaning | | ------------- | ----- | ------------------- | | ROD | 1 | Rest of Day | | FOK | 2 | Fill-or-Kill | | IOC | 3 | Immediate-or-Cancel | | UN\_SUPPORTED | 4 | Unsupported Type | | UN\_DEFINED | 5 | Undefined Type | ##### OrderType[​](#ordertype "Direct link to OrderType") Order Type | Name | Value | Meaning | | ------------- | ----- | -------------------- | | STOCK | 1 | Spot (Cash) | | MARGIN | 2 | Margin Buy | | SHORT | 3 | Short Sell | | SBL | 4 | Securities Borrowing | | DAY\_TRADE | 5 | Day Trade | | UN\_SUPPORTED | 6 | Unsupported Type | | UN\_DEFINED | 7 | Undefined Type | ##### StockType[​](#stocktype "Direct link to StockType") Stock Category | Name | Value | Meaning | | ------------------- | ----- | ------------------------------- | | Stock | 0 | Stock | | ConvertBond | 1 | Convertible Bond | | Warrent | 2 | Warrant | | ETF\_and\_ETN | 3 | ETF & ETN | | Bond\_with\_Warrent | 4 | Depositary Receipt with Warrant | | ForeignStock | 5 | Foreign Stock | | CGS | 6 | Central Government Securities | ##### function\_type[​](#function_type "Direct link to function_type") Function Category | Name | Value | | -------------------------- | ----- | | New Order | 0 | | New Order Exec | 10 | | Modify Price | 15 | | Modify Qty | 20 | | Cancel Order | 30 | | Fully Filled (for History) | 50 | | Failed | 90 | ##### market[​](#market "Direct link to market") Market | Name | Value | | -------- | ------- | | Listed | TAIEX | | OTC | TAISDAQ | | Emerging | TAIEMG | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ------------------------------------- | ---------------------------------------------------- | | Pre-order | 0 | | Sending to Backend | 4 (Use GetOrderResult to query status) | | Backend Transmitting | 8 (Use GetOrderResult to query status) | | Connection Timeout | 9 (Please use GetOrderResult later or contact agent) | | Success | 10 | | Cancelled (Unfilled) | 30 | | Partially Filled, Remainder Cancelled | 40 | | Fully Filled | 50 | | Modify Price Failed | 19 | | Modify Qty Failed | 29 | | Cancel Failed | 39 | | Failed | 90 | --- ### API Key Login apikey\_login Version Info New feature added in v2.2.7 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ------ | -------------------- | | personalID | String | Login ID | | key | String | Applied API Key | | certPath | String | Certificate path | | certPass | String | Certificate password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | --------- | ------ | ------------------------------------ | | isSuccess | bool | Whether the login was successful | | data | List | Returned account information | | message | string | Error message when isSuccess = False | ##### Account Information Fields[​](#account-information-fields "Direct link to Account Information Fields") Return type: Object | Parameter | Type | Description | | ----------- | ------ | ------------------------------------------------------------------ | | name | String | Customer name | | account | String | Customer account number | | branchNo | String | Branch code | | accountType | string | Account type: returns `stock` for securities, `futopt` for futures | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp std::shared_ptr sdk = std::make_shared(); fubon::LoginResponse res = sdk->apikey_login("PersonalID", "Key", "Cert Path", "Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp // Custom .cpp & .hpp Output { isSuccess = true, message = , data = [ Account{ name = Fubon Bill, // Customer name (string) account = 28, // Customer account number (string) branchNo = 6460, // Branch code (string) accountType = stock // Account type (string) } ] } ``` --- ### Login login #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ------ | -------------------- | | personalID | String | Login ID | | password | String | Login password | | certPath | String | Certificate path | | certPass | String | Certificate password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | --------- | ------ | ------------------------------------ | | isSuccess | bool | Whether the login was successful | | data | List | Returned account information | | message | string | Error message when isSuccess = False | ##### Account Information Fields[​](#account-information-fields "Direct link to Account Information Fields") Return type: Object | Parameter | Type | Description | | ----------- | ------ | ------------------------------------------------------------------ | | name | String | Customer name | | account | String | Customer account number | | branchNo | String | Branch code | | accountType | string | Account type: returns `stock` for securities, `futopt` for futures | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp std::shared_ptr sdk = std::make_shared(); fubon::LoginResponse res = sdk->login("PersonalID", "Password", "Cert Path", "Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp // Custom .cpp & .hpp Output { isSuccess = true, message = , data = [ Account{ name = Fubon Bill, // Customer name (string) account = 28, // Customer account number (string) branchNo = 6460, // Branch code (string) accountType = stock // Account type (string) } ] } ``` --- ### Batch Cancel Orders batch\_cancel\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | -------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | | orderResult | [BatchList](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) | Batch Cancel Order Content | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------- | | is\_success | bool | Is Success | | data | List | Returns Modification Info | | message | string | Returns Error Message when isSuccess = False | ##### Modification Info OrderResult Fields[​](#modification-info-orderresult-fields "Direct link to Modification Info OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | seq\_no | string | Sequence Number | | branch\_no | string | Branch Code | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type: `0` Stock | | market | string | Market: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market Type: `COMMON` (Round Lot), `FIXING`, `INTRADAY_ODD`, `ODD` (Post-market Odd), `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | pric\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Cash), `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending, `9` Timeout, `10` Success, `30` Cancelled, `40` Partial Fill/Cancel Remainder, `50` Full Fill, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective Price Type | | after\_price | double | Effective Price | | unit | int | Unit Size | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Quantity Before Modification | | before\_price | double | Price Before Modification | | user\_def | string | User Defined Field | | last\_time | string | Last Modified Time | | details | list | Order History (Available in order\_result\_detail or order\_history) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch Cancel (Using batch detailResult content) std::vector cancel; cancel.push_back(batch_list_res.data.value()[0]); cancel.push_back(batch_list_res.data.value()[1]); // Batch Cancel (Using different individual orders) std::vector cancel; cancel.push_back(order_res.data.value()[10]); cancel.push_back(order_res.data.value()[13]); auto batch_cancel = sdk->stock->batch_cancel_order(target_account, cancel); if (!batch_cancel.is_success) { std::cout << "batch_cancel failed reason: " << (batch_cancel.message.has_value() ? batch_cancel.message.value() : "No message") << std::endl; } else { if (batch_cancel.data.has_value()) { std::cout << batch_cancel << std::endl; } else { std::cout << "batch_cancel success but no data returned." << std::endl; } } ``` #### ResultExample[​](#resultexample "Direct link to ResultExample") ```cpp { isSuccess = true, message = , data =[ OrderResult { // Batch Cancel (Using batch detailResult content) functionType = 30, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 00000308998, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = x0028, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (float) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Is Pre-order (bool) status = 30, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 41.2, // Effective Price (float) unit = 1000, // Unit Size (int) afterQty = 0, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 5000, // Quantity Before Mod (int) beforePrice = 41.2, // Price Before Mod (float) userDef = 12345678, // User Defined Field (string) lastTime = 12:53:57.536, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult { functionType = 30, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 0000030899, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = x0029, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (float) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Is Pre-order (bool) status = 30, // Order Status (int) ... } ] } ``` --- ### Batch Modify Order Price batch\_modify\_price ##### Create ModifyPriceObj using make\_modify\_price\_obj first[​](#create-modifypriceobj-using-make_modify_price_obj-first "Direct link to Create ModifyPriceObj using make_modify_price_obj first") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------- | ------------------------ | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) | The Order to be modified | | price | string | New Price | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | New Price Type Flag | caution When the `price` field has a value, `priceType` must be `std::nullopt`; when `priceType` has a value, `price` must be `std::nullopt`. Pass the Result object into the `batch_modify_price` method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | -------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | | ModifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#modifypriceobj)(list of object) | Batch Modify Order Content | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | --------- | ------ | -------------------------------------------- | | isSuccess | bool | Is Success | | data | List | Returns Modification Info | | message | string | Returns Error Message when isSuccess = False | ##### Modification Info OrderResult Fields[​](#modification-info-orderresult-fields "Direct link to Modification Info OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | seq\_no | string | Sequence Number | | branch\_no | string | Branch Code | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type: `0` Stock | | market | string | Market: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market Type: `COMMON` (Round Lot), `FIXING`, `INTRADAY_ODD`, `ODD` (Post-market Odd), `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | pric\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Cash), `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending, `9` Timeout, `10` Success, `30` Cancelled, `40` Partial Fill/Cancel Remainder, `50` Full Fill, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective Price Type | | after\_price | double | Effective Price | | unit | int | Unit Size | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Quantity Before Modification | | before\_price | double | Price Before Modification | | user\_def | string | User Defined Field | | last\_time | string | Last Modified Time | | details | list | Order History (Available in order\_result\_detail or order\_history) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Batch Modify Price (Using batch detailResult content) std::vector modify_orders = { sdk->stock->make_modify_price_obj(batch_list_res.data.value()[0], "41.1", std::nullopt), sdk->stock->make_modify_price_obj(batch_list_res.data.value()[1], "41.2", std::nullopt) }; // Batch Modify Price (Using different individual orders) std::vector modify_orders = { sdk->stock->make_modify_price_obj(order_res.data.value()[10], "41.1", std::nullopt), sdk->stock->make_modify_price_obj(order_res.data.value()[13], "41.2", std::nullopt) }; auto batch_price = sdk->stock->batch_modify_price(target_account, modify_orders); if (!batch_price.is_success) { std::cout << "batch_price failed reason: " << (batch_price.message.has_value() ? batch_price.message.value() : "No message") << std::endl; } else { if (batch_price.data.has_value()) { std::cout << batch_price << std::endl; } else { std::cout << "batch_price success but no data returned." << std::endl; } } ``` #### ResultExample[​](#resultexample "Direct link to ResultExample") ```cpp isSuccess = true, message = , data =[ OrderResult{ // Batch Modify Price (Using batch detailResult content) functionType = 15, // Function Type (int) date = 2023/11/22, // Trade Date (string) seqNo = 00000322356, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = x0018, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 41.1, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 2000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = , // Quantity Before Mod (int) beforePrice = 41.3, // Price Before Mod (double) userDef = 12345678, // User Defined Field (string) lastTime = 13:56:57.713, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Trade Date (string) seqNo = 00000322355, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = x0017, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) ... } ] } // The following is an excerpt of data content [ OrderResult{ // Batch Modify Price (Using different individual orders) functionType = 15, // Function Type (int) date = 2023/11/22, // Trade Date (string) seqNo = 00000322388, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = x0033, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 41.1, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 2000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = , // Quantity Before Mod (int) beforePrice = 41.3, // Price Before Mod (double) userDef = 12345678, // User Defined Field (string) lastTime = 10:56:57.713, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Trade Date (string) seqNo = 00000322386, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = "26", // Account (string) orderNo = x0031, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 1101, // Stock Symbol (string) buySell = Sell, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) ... } ] ``` --- ### Batch Modify Order Quantity batch\_modify\_quantity ##### Create ModifyQuantityObj using make\_modify\_quantity\_obj first[​](#create-modifyquantityobj-using-make_modify_quantity_obj-first "Direct link to Create ModifyQuantityObj using make_modify_quantity_obj first") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) | The Order to be modified | | quantity | int | Modified Order Quantity (Includes filled portion of this order) | Pass the Result object into the `batch_modify_quantity` method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | | ModifyQuantityObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#modifyquantityobj) (list of object) | Batch Modify Order Content | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------- | | is\_success | bool | Is Success | | data | List | Returns Modification Info | | message | string | Returns Error Message when isSuccess = False | ##### Modification Info OrderResult Fields[​](#modification-info-orderresult-fields "Direct link to Modification Info OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | seq\_no | string | Sequence Number | | branch\_no | string | Branch Code | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type: `0` Stock | | market | string | Market: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market Type: `COMMON` (Round Lot), `FIXING`, `INTRADAY_ODD`, `ODD` (Post-market Odd), `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | pric\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Cash), `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending, `9` Timeout, `10` Success, `30` Cancelled, `40` Partial Fill/Cancel Remainder, `50` Full Fill, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective Price Type | | after\_price | double | Effective Price | | unit | int | Unit Size | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Quantity Before Modification | | before\_price | double | Price Before Modification | | user\_def | string | User Defined Field | | last\_time | string | Last Modified Time | | details | list | Order History (Available in order\_result\_detail or order\_history) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp // Batch Modify Quantity (Using batch detailResult content) std::vector modify_orders = { sdk->stock->make_modify_quantity_obj(batch_list_res.data.value()[0], 1000), sdk->stock->make_modify_quantity_obj(batch_list_res.data.value()[1], 1000) }; // Batch Modify Quantity (Using different individual orders) std::vector modify_orders { sdk->stock->make_modify_quantity_obj(order_res.data.value()[10], 1000), sdk->stock->make_modify_quantity_obj(order_res.data.value()[13], 1000) }; auto batch_qty = sdk->stock->batch_modify_quantity(target_account, modify_qty); if (!batch_qty.is_success) { std::cout << "batch_qty failed reason: " << (batch_qty.message.has_value() ? batch_qty.message.value() : "No message") << std::endl; } else { if (batch_qty.data.has_value()) { std::cout << batch_qty << std::endl; } else { std::cout << "batch_qty success but no data returned." << std::endl; } } ``` #### ResultExample[​](#resultexample "Direct link to ResultExample") ```cpp { isSuccess = true, message = , data =[ OrderResult{ // Batch Modify Qty (Using batch detailResult content) functionType = 20, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 00000000042, // Sequence Number (string) branchNo = 20112, // Branch Code (string) account = 26, // Account (string) orderNo = x0026, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 2881, // Stock Symbol (string) buySell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = , // Effective Price Type (PriceType) afterPrice = 66, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 1000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 2000, // Quantity Before Mod (int) beforePrice = , // Price Before Mod (double) userDef = batch 2, // User Defined Field (string) lastTime = 12:21:51.023, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult{ // Batch Modify Qty (Using batch detailResult content) functionType = 20, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 00000000041, // Sequence Number (string) branchNo = 20112, // Branch Code (string) account = 26, // Account (string) orderNo = x0025, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 2881, // Stock Symbol (string) buySell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = , // Effective Price Type (PriceType) afterPrice = 66, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 1000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 2000, // Quantity Before Mod (int) beforePrice = , // Price Before Mod (double) userDef = batch 1, // User Defined Field (string) lastTime = 12:21:51.023, // Last Modified Time (string) errorMessage = // Error Message (string) } ] } // The following is an excerpt of data content [ OrderResult{ // Batch Modify Qty (Using different individual orders) functionType = 20, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 00000000043, // Sequence Number (string) branchNo = 20112, // Branch Code (string) account = "26", // Account (string) orderNo = x0027, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MaeketType) stockNo = 2881, // Stock Symbol (string) buySell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = , // Effective Price Type (PriceType) afterPrice = 66, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 1000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 2000, // Quantity Before Mod (int) beforePrice = , // Price Before Mod (int) userDef = Test, // User Defined Field (string) lastTime = 12:21:53.023, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 20, // Function Type (int) date = 2024/03/08, // Trade Date (string) seqNo = 00000000044, // Sequence Number (string) branchNo = 20112, // Branch Code (string) account = 26, // Account (string) orderNo = x0028, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 2881, // Stock Symbol (string) buySell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = , // Effective Price Type (PriceType) afterPrice = 66, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 1000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 2000, // Quantity Before Mod (int) beforePrice = , // Price Before Mod (string) userDef = Test, // User Defined Field (string) lastTime = 12:21:53.023, // Last Modified Time (string) errorMessage = // Error Message (string) } ] ``` --- ### Get Batch Order Detail batch\_order\_detail #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | -------------- | ---------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | | BatchOrderList | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#batchresult) | Batch Order List | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | --------- | ------ | -------------------------------------------- | | isSuccess | bool | Is Success | | data | List | Returns Order Information | | message | string | Returns Error Message when isSuccess = False | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | seq\_no | string | Sequence Number | | branch\_no | string | Branch Code | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type: `0` Stock | | market | string | Market: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market Type: `COMMON` (Round Lot), `FIXING`, `INTRADAY_ODD`, `ODD` (Post-market Odd), `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | pric\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Cash), `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending, `9` Timeout, `10` Success, `30` Cancelled, `40` Partial Fill/Cancel Remainder, `50` Full Fill, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective Price Type | | after\_price | double | Effective Price | | unit | int | Unit Size | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Quantity Before Modification | | before\_price | double | Price Before Modification | | user\_def | string | User Defined Field | | last\_time | string | Last Modified Time | | details | list | Order History (Available in order\_result\_detail or order\_history) | | error\_message | string | Error Message | caution This function is only for querying the execution results of batch orders. To get the latest status of an order, please use the single order query function. #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto batch_list = sdk->stock->batch_order_lists(target_account); auto batch_res = batch_list.data.value()[0]; auto batch_list_res = sdk->stock->batch_order_detail(target_account, batch_res); if (!batch_list_res.is_success) { std::cout << "get order result failed reason: " << (batch_list_res.message.has_value() ? batch_list_res.message.value() : "No message") << std::endl; } else { if (batch_list_res.data.has_value()) { std::cout << batch_list_res << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### ReturnExample[​](#returnexample "Direct link to ReturnExample") ```cpp { isSuccess = true, message = , data = [ OrderResult{ functionType = , // Function Type (int) date = 2023/10/18, // Trade Date (date) seqNo = 00000000007, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = bA683, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stockNo = 2888, // Stock Symbol (string) buySell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 8.9, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Is Pre-order (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 8.9, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 2000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 0, // Quantity Before Mod (int) beforePrice = 8.9, // Price Before Mod (double) userDef = , // User Defined Field (string) lastTime = 14:41:32.647, // Last Modified Time (string) details = , // Order History (list) errorMsg = // Error Message (string) }, ... ] } ``` --- ### Get Batch Order List batch\_order\_lists #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------- | | is\_success | bool | Is Success | | data | List | Returns Batch Order Information | | message | string | Returns Error Message when isSuccess = False | ##### BatchResult Fields[​](#batchresult-fields "Direct link to BatchResult Fields") Return type: Object | Parameter | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | branch\_no | string | Branch Code | | account | string | Account | | batch\_seq\_no | string | Batch Sequence Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto batch_list = sdk->stock->batch_order_lists(target_account); if (!batch_list.is_success) { std::cout << "Get batch list result failed reason: " << (batch_list.message.has_value() ? batch_list.message.value() : "No message") << std::endl; } else { if (batch_list.data.has_value()) { std::cout << batch_list << std::endl; } else { std::cout << "Get batch list success but no data returned." << std::endl; } } ``` #### ReturnExample[​](#returnexample "Direct link to ReturnExample") ```cpp { isSuccess = true, message = , data = [ BatchResult{ functionType = 0, // Function Type (int) date = 2023/10/04, // Trade Date (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) batchSeqNo = 11EE626533D072228000000C29304663 // Batch Sequence Number (string) }, ... ] } ``` --- ### Create Batch Order batch\_place\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------------------------- | -------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account Object | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderobject) (list of object) | Order Content | #### Return Result[​](#return-result "Direct link to Return Result") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------- | | is\_success | bool | Is Success | | message | string | Returns Error Message when isSuccess = False | | data | List | Returns Order Information | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type: `0` New Order, `10` Exec New, `15` Mod Price, `20` Mod Qty, `30` Cancel, `90` Failed | | date | string | Trade Date | | seq\_no | string | Sequence Number | | branch\_no | string | Branch Code | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type: `0` Stock | | market | string | Market: `TAIEX` (Listed), `TAISDAQ` (OTC), `TAIEMG` (Emerging) | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market Type: `COMMON` (Round Lot), `FIXING`, `INTRADAY_ODD`, `ODD` (Post-market Odd), `EMG`, `EMG_ODD` | | stock\_no | string | Stock Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Side: `BUY`, `SELL` | | pric\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price Type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time In Force: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order Type: `STOCK` (Cash), `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Is Pre-order | | status | int | Order Status: `0` Pre-order, `4` Sending, `9` Timeout, `10` Success, `30` Cancelled, `40` Partial Fill/Cancel Remainder, `50` Full Fill, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective Price Type | | after\_price | double | Effective Price | | unit | int | Unit Size | | after\_qty | int | Effective Quantity (Includes filled portion) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Amount | | before\_qty | int | Quantity Before Modification | | before\_price | double | Price Before Modification | | user\_def | string | User Defined Field | | last\_time | string | Last Modified Time | | details | list | Order History (Available in order\_result\_detail or order\_history) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp Order order = Order{ BsAction::BUY, "1101", std::nullopt, 1, MarketType::INTRADAY_ODD, PriceType::LIMIT_DOWN, TimeInForce::ROD, OrderType::STOCK, "c++" }; Order order2 = Order{ BsAction::BUY, "1101", std::nullopt, 1, MarketType::INTRADAY_ODD, PriceType::LIMIT_DOWN, TimeInForce::ROD, OrderType::STOCK, "c++" }; std::vector orders; orders.push_back(order); orders.push_back(order2); auto vec_order_result = sdk->stock->batch_place_order(target_account, orders); if (!vec_order_result.is_success) { std::cout << "get order result failed reason: " << (vec_order_result.message.has_value() ? vec_order_result.message.value() : "No message") << std::endl; } else { if (vec_order_result.data.has_value()) { std::cout << vec_order_result << std::endl; } else { std::cout << "Order result success but no data returned." << std::endl; } } ``` #### ReturnExample[​](#returnexample "Direct link to ReturnExample") ```cpp { isSuccess = true, message = , data = [ OrderResult{ functionType = 0, // Function Type (int) date = 2023/09/22, // Trade Date (string) seqNo = 00000221431, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = , // Order Number (string) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stock_no = 2888, // Stock Symbol (string) buy_sell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 8.9, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (OrderType) isPreOrder = true, // Is Pre-order (bool) status = 0, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 8.9, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 2000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 0, // Quantity Before Mod (int) beforePrice = 9.1, // Price Before Mod (double) userDef = null, // User Defined Field (string) lastTime = null, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 0, // Function Type (int) date = 2023/09/22, // Trade Date (string) seqNo = 00000221432, // Sequence Number (string) branchNo = 6460, // Branch Code (string) account = 26, // Account (string) orderNo = , // Order Number (string) market = TAIEX, // Market (string) marketType = Common, // Market Type (MarketType) stock_no = 2888, // Stock Symbol (string) buy_sell = Buy, // Side (BsAction) priceType = Limit, // Original Price Type (PriceType) price = 8.9, // Price (double) quantity = 2000, // Original Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (OrderType) isPreOrder = true, // Is Pre-order (bool) status = 0, // Order Status (int) afterPriceType = Limit, // Effective Price Type (PriceType) afterPrice = 8.9, // Effective Price (double) unit = 1000, // Unit Size (int) afterQty = 2000, // Effective Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Amount (int) beforeQty = 0, // Quantity Before Mod (int) beforePrice = 9.1, // Price Before Mod (double) userDef = , // User Defined Field (string) lastTime =, // Last Modified Time (string) details = , // Order History (list) errorMessage = // Error Message (string) } ] } ``` --- ### Cancel Order cancel\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------- | ---------------------- | | account | Account | Account | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) | Order object to cancel | | unblock | bool (optional) (default = false) | Non-blocking | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ----------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | OrderResult | Returned canceled order info | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") (Same as other order-related APIs) #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto target_order = order_results_response.data.value()[0]; auto cancel_response = sdk->stock->cancel_order(target_account, target_order, std::nullopt); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = OrderResult{functionType = 30, status = 30, afterQty = 0, ...} } ``` --- ### Query Day Trade Quota daytrade\_and\_stock\_info #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | stockNo | string | Stock code | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ----------------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | DayTradeStockInfo | Returned day trade quota info | | message | string | Error message when is\_success = False | ##### DayTradeStockInfo Fields[​](#daytradestockinfo-fields "Direct link to DayTradeStockInfo Fields") Return type: Object | Parameter | Type | Description | | ------------------------- | ------ | -------------------------------------------------------- | | stock\_no | string | Stock code | | date | string | Date | | daytrade\_orig\_quota | int | Original day trade quota | | daytrade\_tradable\_quota | int | Tradable day trade quota | | precollect\_single | int | Pre-collect single quantity | | precollect\_accumulate | int | Pre-collect accumulated quantity | | status | int | Status (bitmask): 0=Disabled, 1=Short sell allowed, etc. | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto daytrade_quo = sdk->stock->daytrade_and_stock_info(target_account, "2330"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [DayTradeStockInfo{stockNo = 3264, daytradeOrigQuota = 0, daytradeTradableQuota = 0, status = 0}] } ``` --- ### Query Historical Fills filled\_history #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | startDate | string | Start date | | endDate | string (default same as startDate if empty) | End date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------- | | is\_success | bool | Whether successful | | data | List | Returned fill history | | message | string | Error message when is\_success = False | ##### FilledData Fields[​](#filleddata-fields "Direct link to FilledData Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ------------------------------------------------------------------------------------------------ | --------------------- | | date | string | Fill date | | branch\_no | string | Branch code | | account | string | Account | | seq\_no | string | Order sequence number | | order\_no | string | Order number | | stock\_no | string | Stock code | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Buy/Sell | | filled\_no | string | Fill sequence number | | filled\_avg\_price | double | Average fill price | | filled\_qty | int | Filled quantity | | filled\_price | double | Fill price | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order type | | filled\_time | string | Fill time | | user\_def | string | Custom field | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto history_filled_response = sdk->stock->filled_history(target_account, "20250401", "20250501"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [FilledData{date = 2025/04/29, stockNo = 1101, filledQty = 1000, filledAvgPrice = 35.2, ...}] } ``` --- ### Get Order Results get\_order\_results #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------- | | is\_success | bool | Whether successful | | data | List | Returned order results | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function type: `0` New, `10` Execute, `15` Modify Price, `20` Modify Qty, `30` Cancel, `90` Failed | | date | string | Trade date | | seq\_no | string | Order sequence number | | branch\_no | string | Branch code | | account | string | Account | | order\_no | string | Order number | | asset\_type | int | Asset type: `0` Stock | | market | string | Market type: `TAIEX` Main Board, `TAISDAQ` OTC, `TAIEMG` Emerging | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market category: `COMMON`, `FIXING`, `INTRADAY_ODD`, `ODD`, `EMG`, `EMG_ODD` | | stock\_no | string | Stock code | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Buy/Sell: `BUY` Buy, `SELL` Sell | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original order quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time condition: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Whether pre-order | | status | int | Order status: `0` Pre-order, `4` Sent, `9` Timeout, `10` Success, `30` Cancel Success, `40` Partial Fill Cancel, `50` Fully Filled, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective price type after modification | | after\_price | double | Effective price after modification | | unit | int | Unit count | | after\_qty | int | Effective quantity after modification | | filled\_qty | int | Filled quantity | | filled\_money | int | Filled amount | | before\_qty | int | Quantity before modification | | before\_price | double | Price before modification | | user\_def | string | Custom field | | last\_time | string | Last update time | | details | list | Order history | | error\_message | string | Error message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto order_results_response = sdk->stock->get_order_results(target_account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [OrderResult{...}] } ``` --- ### Get Order Results (Include Detail) get\_order\_results\_detail #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------- | | is\_success | bool | Whether successful | | data | List | Returned order results with history | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") (Same as GetOrderResults, includes details list for order status change history) #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto order_results_response = sdk->stock->get_order_results_detail(target_account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [OrderResult{...}] } ``` --- ### Query Margin Quota margin\_quota #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | stockNo | string | Stock code | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ---------------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | MarginShortQuota | Returned margin/short quota info | | message | string | Error message when is\_success = False | ##### MarginShortQuota Fields[​](#marginshortquota-fields "Direct link to MarginShortQuota Fields") Return type: Object | Parameter | Type | Description | | -------------------------- | ------ | ------------------------- | | stock\_no | string | Stock code | | date | string | Date | | shortsell\_orig\_quota | int | Original short sell quota | | shortsell\_tradable\_quota | int | Tradable short sell quota | | margin\_orig\_quota | int | Original margin quota | | margin\_tradable\_quota | int | Tradable margin quota | | margin\_ratio | int | Margin ratio | | short\_ratio | int | Short sell ratio | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto quota_response = sdk->stock->margin_quota(target_account, "2330"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = MarginShortQuota{ stockNo = 2330, date = 2024/01/24, shortsellOrigQuota = 894, shortsellTradableQuota = 894, marginOrigQuota = , marginTradableQuota = , marginRatio = 60, shortRatio = 90 } } ``` --- ### Modify Order Price modify\_price ##### First use make\_modify\_price\_obj to create ModifyPriceObj[​](#first-use-make_modify_price_obj-to-create-modifypriceobj "Direct link to First use make_modify_price_obj to create ModifyPriceObj") | Parameter | Type | Description | | ----------- | ------------------------------------------------------------------------------------------------ | ---------------------- | | orderResult | \[OrderResult(/docs/trading/library/cpp/EnumMatrix/#orderresult)] | Target order to modify | | price | string | New price | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | New price type | caution If price is provided, priceType must be std::nullopt; if priceType is provided, price must be std::nullopt. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------ | | account | Account | Account | | modifiedPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#modifypriceobj) | Object for price modification | | unblock | bool (optional) | Non-blocking (default = false) | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ----------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | OrderResult | Returned modified order info | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") (Same as OrderHistory) #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto modify_price_obj = sdk->stock->make_modify_price_obj(target_order, "41.1", std::nullopt); auto modify_price_response = sdk->stock->modify_price(target_account, modify_price_obj, std::nullopt); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = True, message = , data = OrderResult{functionType = 15, afterPrice = 41.1, ...} } ``` --- ### Modify Order Quantity modify\_quantity ##### First use make\_modify\_quantity\_obj to create ModifyQuantityObj[​](#first-use-make_modify_quantity_obj-to-create-modifyquantityobj "Direct link to First use make_modify_quantity_obj to create ModifyQuantityObj") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderresult) | Target order to modify | | quantity | int | New quantity (includes already filled portion) | #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------- | | account | Account | Account | | ModifyQuantityObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#modifyquantityobj) | Object for quantity modification | | unblock | bool (optional) | Non-blocking (default = false) | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ----------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | OrderResult | Returned modified order info | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") (Same as OrderHistory) #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto modify_quantity_obj = sdk->stock->make_modify_quantity_obj(target_order, 1000); auto modify_quantity_response = sdk->stock->modify_quantity(target_account, modify_quantity_obj, std::nullopt); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = OrderResult{functionType = 20, afterQty = 1000, ...} } ``` --- ### Query Historical Orders order\_history #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | -------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | startDate | string | Query start date | | endDate | string (default same as startDate if empty) | Query end date | info From v2.1.1, long-term historical data can be queried, max 30-day range per query; before v2.1.0, only last 2 days history. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ------ | -------------------------------------- | | is\_success | bool | Whether successful | | data | List | Returned order history | | message | string | Error message when is\_success = False | ##### OrderResult Fields[​](#orderresult-fields "Direct link to OrderResult Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function type: `0` New, `10` Execute, `15` Modify Price, `20` Modify Qty, `30` Cancel, `90` Failed | | date | string | Trade date | | seq\_no | string | Order sequence number | | branch\_no | string | Branch code | | account | string | Account | | order\_no | string | Order number | | asset\_type | int | Asset type: `0` Stock | | market | string | Market type: `TAIEX` Main Board, `TAISDAQ` OTC, `TAIEMG` Emerging | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) | Market category: `COMMON`, `FIXING`, `INTRADAY_ODD`, `ODD`, `EMG`, `EMG_ODD` | | stock\_no | string | Stock code | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#bsaction) | Buy/Sell: `BUY` Buy, `SELL` Sell | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Price type: `LIMIT`, `LIMIT_UP`, `LIMIT_DOWN`, `MARKET`, `REFERENCE` | | price | double | Price | | quantity | int | Original order quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#timeinforce) | Time condition: `ROD`, `FOK`, `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#ordertype) | Order type: `STOCK`, `MARGIN`, `SHORT`, `DAY_TRADE`, `SBL` | | is\_pre\_order | bool | Whether pre-order | | status | int | Order status: `0` Pre-order, `4` Sent, `9` Timeout, `10` Success, `30` Cancel Success, `40` Partial Fill Cancel, `50` Fully Filled, `90` Failed | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#pricetype) | Effective price type after modification | | after\_price | double | Effective price after modification | | unit | int | Unit count | | after\_qty | int | Effective quantity after modification | | filled\_qty | int | Filled quantity | | filled\_money | int | Filled amount | | before\_qty | int | Quantity before modification | | before\_price | double | Price before modification | | user\_def | string | Custom field | | last\_time | string | Last update time | | details | list | Order history details | | error\_message | string | Error message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto history_order_response = sdk->stock->order_history(target_account, "20250502", "20250502"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = [OrderResult{...}] } ``` --- ### Create Order place\_order #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | ---------------------------------------------------------------------------------------------------- | -------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#orderobject) | Order content | | unblock | bool (optional) (default = false) | Whether non-blocking | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | ----------- | ----------- | -------------------------------------- | | is\_success | bool | Whether successful | | data | OrderResult | Returned order result | | message | string | Error message when is\_success = False | ##### Order Information Fields (OrderResult)[​](#order-information-fields-orderresult "Direct link to Order Information Fields (OrderResult)") Return type: Object | Parameter | Type | Description | | ------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function type: `0` New, `10` Execute, `15` Modify Price, `20` Modify Qty, `30` Cancel, `90` Failed | | date | string | Trade date | | seq\_no | string | Order sequence number | | branch\_no | string | Branch code | | account | string | Account | | order\_no | string | Order number | | asset\_type | int | Asset type: `0` Stock | | market | string | Market type: `TAIEX` Main Board, `TAISDAQ` OTC, `TAIEMG` Emerging | | market\_type | \[MarketType] | Market category: `COMMON` Regular, `FIXING` Closing, `INTRADAY_ODD` Odd-lot Intraday, `ODD` Odd-lot After, `EMG` Emerging, `EMG_ODD` Emerging Odd-lot | | stock\_no | string | Stock code | | buy\_sell | \[BSAction] | Buy/Sell: `BUY` Buy, `SELL` Sell | | price\_type | \[PriceType] | Price type: `LIMIT` Limit, `LIMIT_UP` Upper Limit, `LIMIT_DOWN` Lower Limit, `MARKET` Market, `REFERENCE` Reference | | price | double | Price | | quantity | int | Original order quantity | | time\_in\_force | \[TimeInForce] | Time condition: `ROD`, `FOK`, `IOC` | | order\_type | \[OrderType] | Order type: `STOCK` Cash, `MARGIN` Margin, `SHORT` Short, `DAY_TRADE` Day Trade, `SBL` Securities Lending | | is\_pre\_order | bool | Whether pre-order | | status | int | Order status: `0` Pre-order, `4` Sent, `9` Timeout, `10` Success, `30` Cancel Success, `40` Partial Fill Cancel, `50` Fully Filled, `90` Failed | | after\_price\_type | \[PriceType] | Effective price type after modification | | after\_price | double | Effective price after modification | | unit | int | Unit count | | after\_qty | int | Effective quantity after modification | | filled\_qty | int | Filled quantity | | filled\_money | int | Filled amount | | before\_qty | int | Quantity before modification | | before\_price | double | Price before modification | | user\_def | string | Custom field | | last\_time | string | Last update time | | details | list | Order history | | error\_message | string | Error message | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp Order order = Order{ BsAction::BUY, "2888", "9.0", 1, MarketType::INTRADAY_ODD, PriceType::LIMIT, TimeInForce::ROD, OrderType::STOCK, "c++" }; auto order_result = sdk->stock->place_order(target_account, order, false); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = true, message = , data = OrderResult{ functionType = 0, date = 2023/10/13, seqNo = 00000000007, branchNo = 6460, account = 26, orderNo = bA619, assetType = 0, market = TAIEX, marketType = COMMON, stockNo = 2888, buySell = BUY, priceType = LIMIT, price = 9.1, quantity = 3000, timeInForce = ROD, orderType = STOCK, isPreOrder = false, status = 10, afterPriceType = LIMIT, afterPrice = 9.1, unit = 1000, afterQty = 3000, filledQty = 0, filledMoney = 0, beforeQty = 0, beforePrice = 9.1, userDef = , lastTime = 12:10:12.546, details = , errorMsg = } } ``` --- ### Query Stock Quote query\_symbol\_quote #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | symbol | String | Stock code | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common`, `IntradayOdd`, `Fixing` | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | --------- | ----------- | ------------------------------------ | | isSuccess | bool | Whether successful | | data | SymbolQuote | Returned quote information | | message | string | Error message when isSuccess = False | ##### SymbolQuote Fields[​](#symbolquote-fields "Direct link to SymbolQuote Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ------ | ---------------------- | | market | string | Market | | symbol | string | Stock code | | is\_tib\_or\_psb | bool | Whether TIB or PSB | | market\_type | string | Market type | | status | int | Status (bitmask) | | reference\_price | double | Reference price | | unit | string | Trading unit | | update\_time | string | Update time | | limitup\_price | double | Upper limit price | | limitdown\_price | double | Lower limit price | | open\_price | double | Opening price | | high\_price | double | Highest price | | low\_price | double | Lowest price | | last\_price | double | Last traded price | | total\_volume | int | Total volume | | total\_transaction | int | Total transactions | | total\_value | double | Total value | | last\_size | int | Last trade size | | last\_transaction | int | Last transaction count | | last\_value | double | Last trade value | | bid\_price | double | Bid price | | bid\_volume | int | Bid volume | | ask\_price | double | Ask price | | ask\_volume | int | Ask volume | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto query_quote = sdk->stock->query_symbol_quote(target_account,"2330"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = True, message = , data = SymbolQuote{ market = TAIEX, symbol = 2330, istibOrPsb = False, marketType = Common, status = 15, referencePrice = 780, unit = 1000, updateTime = , limitupPrice = 858, limitdownPrice = 702, openPrice = 1155, highPrice = 1160, lowPrice = 1145, lastPrice = 1145, totalVolume = 20501, totalTransaction = 0, totalValue = 23551095000, lastSize = 6673, lastTransaction = 0, lastValue = 7640585000, bidPrice = 1145, bidVolume = 1549, askPrice = 1150, askVolume = 4169 } } ``` --- ### Query Market Snapshot query\_symbol\_snapshot #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common`, `IntradayOdd`, `Fixing` | | stock\_type | List [StockType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#stocktype) (Optional)(default = Stock) | Stock category: `Stock`, `ConvertBond`, `ETF_and_ETN` | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Description | | --------- | ---------------------- | ------------------------------------ | | isSuccess | bool | Whether successful | | data | SymbolSnapshotResponse | Returned snapshot information | | message | string | Error message when isSuccess = False | ##### SymbolQuote Fields[​](#symbolquote-fields "Direct link to SymbolQuote Fields") Return type: Object | Parameter | Type | Description | | ------------------ | ------ | ---------------------- | | market | string | Market | | symbol | string | Stock code | | is\_tib\_or\_psb | bool | Whether TIB or PSB | | market\_type | string | Market type | | status | int | Status (bitmask) | | reference\_price | double | Reference price | | unit | int | Trading unit | | update\_time | string | Update time | | limitup\_price | double | Upper limit price | | limitdown\_price | double | Lower limit price | | open\_price | double | Opening price | | high\_price | double | Highest price | | low\_price | double | Lowest price | | last\_price | double | Last traded price | | total\_volume | int | Total volume | | total\_transaction | int | Total transactions | | total\_value | double | Total value | | last\_size | int | Last trade size | | last\_transaction | int | Last transaction count | | last\_value | double | Last trade value | | bid\_price | double | Bid price | | bid\_volume | int | Bid volume | | ask\_price | double | Ask price | | ask\_volume | int | Ask volume | #### Request Example[​](#request-example "Direct link to Request Example") ```cpp auto query_snapshot = sdk->stock->query_symbol_snapshot(target_account, MarketType::COMMON, std::vector{ StockType::COVERT_BOND }); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cpp { isSuccess = True, message = , data = SymbolQuote{ market = TAIEX, symbol = 2330, istibOrPsb = False, marketType = Common, status = 15, referencePrice = 780, unit = 1000, updateTime = , limitupPrice = 858, limitdownPrice = 702, openPrice = 1155, highPrice = 1160, lowPrice = 1145, lastPrice = 1145, totalVolume = 20501, totalTransaction = 0, totalValue = 23551095000, lastSize = 6673, lastTransaction = 0, lastValue = 7640585000, bidPrice = 1145, bidVolume = 1549, askPrice = 1150, askVolume = 4169 } } ``` --- ### Query bank remains BankRemain #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ---------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | BankRemain | BankRemain is returned | | message | string | isSuccess = False error description is returned | ##### BankRemain Parameter[​](#bankremain-parameter "Direct link to BankRemain Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ------ | ----------------- | | branchNo | string | Branch Number | | account | string | Account | | currency | string | Currency | | balance | int | Balance | | availableBalance | int | Available Balance | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Accounting.BankRemain(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```cs { isSuccess = True, message = , data = BankRemain{ branchNo = 6460, // Branch Number (string) account = 26, // Account (string) currency = TWD, // Currency (string) balance = 666666, // Balance (int) availableBalance = 123456 // Available Balance (int) } } ``` --- ### Inventories Inventories #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Inventory list is returned | | message | string | isSuccess = False error description is returned | ##### Inventory Parameter[​](#inventory-parameter "Direct link to Inventory Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | > date | string | Query date(Today) | | > account | string | Account | | > branchNo | string | Branch Number | | > stockNo | string | Symbol | | > orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | > lastdayQty | int | Yesterday Share balacne | | > buyQty | int | Total volume purchased today | | > buyFilledQty | int | Total purchased filled today | | > buyValue | int | Total amount purchased today | | > todayQty | int | Today Share balacne | | > tradableQty | int | Available quantity | | > sellQty | int | Total volume sell today | | > sellFilledQty | int | Total sell filled today | | > sellValue | int | Total amount sell today | | > odd | list | Object | | >> lastdayQty | int | Yesterday odd lot balacne | | >> buyQty | int | Total volume purchased today | | >> buyFilledQty | int | Total purchased filled today | | >> buyValue | int | Total amount purchased today | | >> todayQty | int | Today odd lot balacne | | >> tradableQty | int | Available quantity | | >> sellQty | int | Total volume sell today | | >> sellFilledQty | int | Total sell filled today | | >> sellValue | int | Total amount sell today | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.Inventories(account)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ Inventory{ date = 2023/10/13, // Query date (string) account = 26, // Account (string) branchNo = 6460, // Branch Number (string) stockNo = 1101, // Symbol (string) orderType = Stock, // Order Type (OrderType) lastdayQty = 2000, // Yesterday Share Balance (int) buyQty = 0, // Total volume purchased today (int) buyFilledQty = 0, // Total purchased filled today (int) buyValue = 0, // Total amount purchased today (int) todayQty = 2000, // Today Share Balance (int) tradableQty = 2000, // Available quantity (int) sellQty = 0, // Total volume sell today (int) sellFilledQty = 0, // Total sell filled today (int) sellValue = 0, // Total amount sell today (int) odd = { // Object lastdayQty = 0, // Yesterday odd lot balance (int) buyQty = 0, // Total volume purchased today (int) buyFilledQty = 0, // Total purchased filled today (int) buyValue = 0, // Total amount purchased today (int) todayQty = 0, // Today odd lot balance (int) tradableQty = 0, // Available quantity (int) sellQty = 0, // Total volume sell today (int) sellFilledQty = 0, // Total sell filled today (int) sellValue = 0 // Total amount sell today (int) } }, ... ] } ``` --- ### Maintenance Maintenance #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | --------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | MaintenanceData | MaintenanceData is returned | | message | string | isSuccess = False error description is returned | ##### MaintenanceData Parameter[​](#maintenancedata-parameter "Direct link to MaintenanceData Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | > date | string | Query Date | | > branchNo | string | Branch Number | | > account | string | Account | | > maintenanceSummary | list | Object | | >> marginValue | int | Total Margin Value | | >> shortsellValue | int | Total Short Sell Value | | >> shortsellMargin | int | Total Short sell Margin Amount | | >> collateral | int | Collateral | | >> marginLoanAmt | int | Total Margin Loan Amount | | >> maintenanceRatio | double | Account Maintenance Ratio | | > MaintenanceDetail | list | Object | | >> stockNo | string | Symbol | | >> orderNo | string | Order Number | | >> orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | >> quantity | int | Hoding Share | | >> price | double | Calculated Price | | >> costPrice | double | Cost Price | | >> shortsellMargin | int | Short Sell Margin | | >> collateral | int | Collateral | | >> marginLoanAmt | int | Margin Loan Amount | | >> maintenanceRatio | double | Maintenance Ratio | | >> collateralInterest | double | Collateral Interest | | >> marginInterest | double | Margin Interest | | >> shortsellInterest | double | Short Sell Interest | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.Maintenance(target_user)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, data = MaintenanceData { date = 2024/02/27, // Query Date (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) maintenanceSummary = { marginValue = 3135000, // Total Margin Value (int) shortsellValue = 0, // Total Short Sell Value (int) shortsellMargin = 0, // Total Short Sell Margin Amount (int) collateral = 0, // Collateral (int) marginLoanAmt = 1494000, // Total Margin Loan Amount (int) maintenanceRatio = 209.83 // Account Maintenance Ratio (double) }, maintenanceDetail = [{ stockNo = 2603, // Symbol (string) orderNo = x4580, // Order Number (string) orderType = Stock, // Order Type (OrderType) quantity = 10000, // Holding Share (int) price = 152.5, // Calculated Price (double) costPrice = 119, // Cost Price (double) shortsellMargin = 0, // Short Sell Margin (int) collateral = 0, // Collateral (int) marginLoanAmt = 0, // Margin Loan Amount (int) maintenanceRatio = 213.58, // Maintenance Ratio (double) collateralInterest = 0, // Collateral Interest (double) marginInterest = 20818, // Margin Interest (double) shortsellInterest = 0 // Short Sell Interest (double) }, ... ], } } ``` --- ### Query Settlemet QuerySettlement #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | range | string | Query range, currently valid values are "0d" (today) and "3d". | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | -------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | SettlementData | SettlementResponse is returned | | message | string | isSuccess = False error description is returned | ##### SettlementData Parameter[​](#settlementdata--parameter "Direct link to SettlementData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ----------------- | -------------------------------------------------------------------- | | > account | list | Object | | >> account | string | Account | | >> branchNo | string | Branch Number | | > details | list | Object | | >> date | string | Query Date | | >> settlementDate | string (Optional) | Settlement Date (If no data will return null value ) | | >> buyValue | int (Optional) | Buying Value (If no data will return null value) | | >> buyFee | int (Optional) | Buying Fee (If no data will return null value) | | >> buySettlement | int (Optional) | Buying Payable / Received Amount (If no data will return null value) | | >> buyTax | int (Optional) | Buying Tax (If no data will return null value) | | >> sellValue | int (Optional) | Selling Value (If no data will return null value) | | >> sellFee | int (Optional) | Selling Fee (If no data will return null value) | | >> sellSettlement | int (Optional) | Selling Payable / Received Amount(If no data will return null value) | | >> sellTax | int (Optional) | Selling Tax (If no data will return null value) | | >> totalBsValue | int (Optional) | Total Buying & Selling Value (If no data will return null value) | | >> totalFee | int (Optional) | Total Fee (If no data will return null value) | | >> totalTax | int (Optional) | Total Tax (If no data will return null value) | | >> totalSettlementAmount | int (Optional) | Total Payable & Received Amount (If no data will return null value) | | >> currency | string (Optional) | Currency (If no data will return null value) | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.QuerySettlement(target_user,"3d")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = SettlementData[ { account = AccountRes { // Account Information account = 26, // Account (string) branchNo = 6460 // Branch number (string) }, details = [ Settlement{ // Settlement Data date = 2024/03/04, // Query Date (string) settlementDate = 2024/03/06, // Settle Date (string) buyValue = 735500, // Buying Value (int) buyFee = 313, // Buying Fee (int) buySettlement = -1429513, // Buying Payable / Received Amount (int) buyTax = 0, // Buying Tax (int) sellValue = 770500, // Selling Value (int) sellFee = 320, // Selling Fee (int) sellSettlement = 0, // Selling Payable / Received Amount (int) sellTax = 2309, // Selling Tax (int) totalBsValue = 1506000, // Total Buying & Selling Amount (int) totalFee = 633, // Total Fee (int) totalSettlementAmount = -1429513, // Total Payable & Received Amount (int) totalTax = 2309, // Total Tax (int) currency = TWD // Currency (string) }, Settlement{ date = 2024/03/05, // Query Date (string) settlementDate = 2024/03/07, // Settle Date (string) buyValue = 2261470, // Buying Value (int) buyFee = 1065, // Buying Fee (int) buySettlement = -3895335, // Buying Payable / Received Amount (int) buyTax = 0, // Buying Tax (int) sellValue = 2488170, // Selling Value (int) sellFee = 1137, // Selling Fee (int) sellSettlement = 677626, // Selling Payable / Received Amount (int) sellTax = 7412, // Selling Tax (int) totalBsValue = 4749640, // Total Buying & Selling Amount (int) totalFee = 2202, // Total Fee (int) totalSettlementAmount = -3217709, // Total Payable & Received Amount (int) totalTax = 7412, // Total Tax (int) currency = TWD // Currency (string) }, Settlement{ date = 2024/03/06, // Query Date (string) settlementDate = , // Settle Date (string) buyValue = , // Buying Value (int) buyFee = , // Buying Fee (int) buySettlement = , // Buying Payable / Received Amount (int) buyTax = , // Buying Tax (int) sellValue = , // Selling Value (int) sellFee = , // Selling Fee (int) sellSettlement = , // Selling Payable / Received Amount (int) sellTax = , // Selling Tax (int) totalBsValue = , // Total Buy & Selling Amount (int) totalFee = , // Total Fee (int) totalSettlementAmount = , // Total Payable & Received Amount (int) totalTax = , // Total Tax (int) currency = // Currency (string) } ] } ] } ``` --- ### Realized Gain and Loss RealizedGainsAndLoses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Realized list is returned | | message | string | isSuccess = False error description is returned | ##### Realized Parameter[​](#realized-parameter "Direct link to Realized Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | date | string | Data date | | branchNo | string | Branch number | | account | string | Account | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | filledQty | int | Filled quantity | | filledPrice | double | Filled price | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` Security Landing | | realizedProfit | int | Realized profit | | realizedLoss | int | Realized loss | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.RealizedGainsAndLoses(account)); ``` #### Request Example[​](#request-example-1 "Direct link to Request Example") ```cs { isSuccess = True, message = , data = [ Realized{ date = 2023/08/16, // Data date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell type (BsAction) filledQty = 1000, // Filled quantity (int) filledPrice = 36.5, // Filled price (double) orderType = Stock, // Order type (OrderType) realizedProfit = 36339, // Realized profit amount (int) realizedLoss = 0 // Realized loss amount (int) }, ... ] } ``` --- ### Realized Gains and Loses Summary RealizedGainsAndLosesSummary #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | RealizedSummary list is returned | | message | string | isSuccess = False error description is returned | ##### RealizedSummary Parameter[​](#realizedsummary-parameter "Direct link to RealizedSummary Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | | startDate | string | Query start date | | endDate | string | Query end date | | branchNo | string | Branch number | | account | string | Account | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、`SBL` Security Landing | | filledQty | int | Filled quantity | | filledAvgPrice | double | Filled average price | | realizedProfitAndLoss | int | Realized profit and loss | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.RealizedGainsAndLosesSummary(account)); ``` #### Request Example[​](#request-example-1 "Direct link to Request Example") ```cs { isSuccess = True, message = , data =[ RealizedSummary{ startDate = 20230801, // Query start date (string) endDate = 20230901, // Query end date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell type (BsAction) orderType = Stock, // Order Type (OrderType) filledQty = 3000, // Filled quantity (int) filledAvgPrice = 35.7, // Filled average price (double) realizedProfitAndLoss = 34026 // Realized profit and loss (int) }, ... ] } ``` --- ### Unrealized Gain and Loses UnrealizedGainsAndLoses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | UnrealizedData list is returned | | message | string | isSuccess = False error description is returned | ##### UnrealizedData Response Parameter[​](#unrealizeddata---response-parameter "Direct link to UnrealizedData Response Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | date | string | Date of inquiry | | branchNo | string | Branch number | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` (**Note**. Please refer to the infomation block below the table) | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` Security Landing | | costPrice | double | Hoding price | | tradableQty | int | Available quantity | | todayQty | int | Today Share balacne | | unrealizedProfit | int | Unrealized profit | | unrealizedLoss | int | Unrealized loss | info For spot trades, buySell is always `Buy` and quantity could be positive or negative to denote the net position. For margin trades,buySell could be `Buy` or `Sell` depends on the trade direction. #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Accounting.UnrealizedGainsAndLoses(account)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ UnrealizedSummary{ date = 2021/08/09, // Date of inquiry (string) account = 26, // Account (int) branchNo = 6460, // Branch number (int) stockNo = 2303, // Symbol (string) buySell = Buy, // Buy/Sell type (BsAction) orderType = Margin, // Order type (OrderType) costPrice = 50.0, // Holding price (double) tradableQty = 1000, // Available quantity (int) todayQty = 1000, // Today Share balance (int) unrealizedProfit = 45200, // Unrealized profit (int) unrealizedLoss = 0 // Unrealized loss (int) }, ... ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | ------------------ | ----------- | --------------------------------------------------------------------------------------------------- | | buySell | BsAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price (use ***null*** if priceType is not `Limit`) | | quantity | int | Order Quantity | | marketType | MarketType | [Trading Session](#markettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd`、`Emg` 、 `EmgOdd` | | priceType | PriceType | [Price Type](#pricetype) valid in `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | orderType | OrderType | [Order Type](#ordertype) valid in `Stock`、`Margin`、`Short`、`DayTrade` | | userDef (optional) | string | Customer Field (Up to 10 characters, no special characters supported、 Not applicable to Emg) | caution The units and ranges for 'quantity' vary for different MarketTypes. Please refer to the [MarketType](#markettype) description for details caution When MarketType is one of MarketType.Common, MarketType.Odd, MarketType.IntradayOdd, MarketType.Emg, and priceType is PriceType.Limit, the 'price' field must be filled; otherwise, the 'price' field should be null Spot Short Selling When spot short selling common stocks, orderType should be DayTrade, buySell is Sell, and marketType is Commonn
(For other spot day trading operations, orderType = Stock) ##### OrderResult[​](#orderresult "Direct link to OrderResult") OrderResult; You can use [GetOrderResult(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/trade/GetOrderResults.md) to get data. | Parameter | Type | Meaning | | --------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | MarketType | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | BsAction | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | PriceType | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | TimeInForce | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 SBL | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | PriceType | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time (see below for the format) | | errorMessage | string | Error Message | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | >> functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time (see below for the format) | | >> beforeQty | int | Original Order Quantity | | >> afterQty | int | Valid Order Quantity (filled quantity included) | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> status | int | Order Status | | >> errMsg | string | Error Message | Time Format lastTime and modifiedTime format: **HH:MM:SS.fff** or **HH:MM:SS** (that is, if .fff = .000, .fff will be ommitted). ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult; You can use [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/trade/batchOrder/BatchOrderList.md) to get data. | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | ##### ModifyPriceObj[​](#modifypriceobj "Direct link to ModifyPriceObj") Modified Price Object | Parameter | Type | Meaning | | ----------- | --------- | ------------------------------------------------------------------------------------------ | | OrderResult | Object | [OrderResult](#orderresult) | | price | double | The price after modification | | PriceType | PriceType | The price type after modification : `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | About Price Type The Co-lo version **has** enabled the use of PriceType. ##### ModifyQuantityObj[​](#modifyquantityobj "Direct link to ModifyQuantityObj") Modified Quantity Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------- | | OrderResult | Object | [OrderResult](#orderresult) | | quantity | int | The quantity after modification | ##### FilledData[​](#filleddata "Direct link to FilledData") Filled Data Object | Parameter | Type | Meaning | | -------------- | --------- | --------------------------------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | stockNo | string | Symbol | | buySell | BsAction | Buy/Sell Type : `Buy` 、 `Sell` | | orderType | OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 SBL | | filledNo | string | Filled Serial Number | | filledAvgPrice | double | Filled Average Price | | filledQty | int | Filled Share | | filledPrice | double | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ----------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branchNo | string | Branch Number | | accountType | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### MarketType[​](#markettype "Direct link to MarketType") Trading Session Type | Name | Meaning | | ----------- | ------------------------------------ | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | | Emg | Emerging Stock Market | | EmgOdd | Emerging Stock Market ( Share Unit ) | When using different MarketTypes, the corresponding units and ranges represented by Quantity may also vary. Details are as follows | Name | Quantity Unit | Quantity Ranges | | ----------- | --------------- | --------------- | | Common | Thousand Shares | 1000 ~ 499000 | | Fixing | Thousand Shares | 1000 ~ 499000 | | IntradayOdd | Share | 1 ~ 999 | | Odd | Share | 1 ~ 999 | | Emg | Thousand Shares | 1000 ~ 499000 | | EmgOdd | Share | 1 ~ 999 | When using different MarketTypes, the available PriceType and TimeInForce as below. | 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") Price Type | Name | Meaning | | --------- | ------------------------------------------------ | | Limit | Limit | | LimitUp | Limit Up | | LimitDown | Limit Down | | Market | Market | | Reference | Reference Price (Fixing Price at Fixing Session) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | Rod | Rest of Day | | Fok | Fill-or-Kill | | Ioc | Immediate-or-Cancel | ##### OrderType[​](#ordertype "Direct link to OrderType") Order Type | Name | Meaning | | -------- | -------------------------------------- | | Stock | Common Stock | | Margin | Margin | | Short | Margin Short Selling | | DayTrade | Spot Short Selling (day trading) | | SBL | Short Selling (with security borrowed) | ##### StockType[​](#stocktype "Direct link to StockType") Stock Category | Name | Meaning | | ------------- | ---------------- | | Stock | Common Stock | | ConvertBond | Convertible Bond | | ETF\_and\_ETN | ETF and ETN | ##### functionType[​](#functiontype "Direct link to functionType") Function Type | Name | Value | | -------------------------------------- | ----- | | New Order | 0 | | New Order Executed | 10 | | Change Price | 15 | | Change Quantity | 20 | | Cancel Order | 30 | | Fully Filled (for OrderResult details) | 50 | | Order Failed | 90 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | ----------------------------- | ------- | | Listed stocks | TAIEX | | Over-the-Counter (OTC) stocks | TAISDAQ | | Emerging Stock | TAIEMG | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | Reservation | 0 | | Sending to the system backend | 4 (Using GetOrderResult to retrieve the latest status) | | Processing by the backend | 8 (Using GetOrderResult to retrieve the latest status) | | Timeout | 9 (Please wait a moment and use GetOrderResult to retrieve the latest status ; or contact your broker agent) | | Active order | 10 | | Canceled | 30 | | Partially filled, others canceled | 40 | | Fully filled | 50 | | Order not valid | 90 | | Flags for order result details | 14 - ACK of modifing price、24 - ACK of modifing quantity、34 - ACK of canceling | | Modify price successfully (for history order inquiry) | 15 | | Modify quantity successfully (for history order inquiry) | 20 | | Fail to modify order price (for callback) | 19 | | Fail to modify order quantity (for callback) | 29 | | Fail to cancel (for callback) | 39 | --- ### API Key Login ApikeyLogin Version Info. Avaiable since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------ | ---------------------- | | ID | String | Login ID | | key | String | API Key | | Cert Path | String | Certification Path | | Cert Password | String | Certification password | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Account list is returned | | message | string | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `Stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.ApikeyLogin("Your ID", "API Key","Your Cert Path","Your Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = Account{ name = 富邦Bill, // Account Name (string) account = 28, // Account Number (string) branchNo = 6460, // Branch Number (string) accountType = stock // Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------ | ---------------------- | | ID | String | Login ID | | Password | String | Login Password | | Cert Path | String | Certification Path | | Cert Password | String | Certification password | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Account list is returned | | message | string | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `Stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password","Your Cert Path","Your Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = Account{ name = 富邦Bill, // Account Name (string) account = 28, // Account Number (string) branchNo = 6460, // Branch Number (string) accountType = stock // Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ---- | ---------------- | | isSuccess | bool | Interface result | #### Resquest Example[​](#resquest-example "Direct link to Resquest Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Logout(); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs True ``` --- ### Batch Cancel Order BatchCancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) (list of object) | The object list for cancel | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | 參數 | 類別 | 說明 | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch cancel ( modifying orders using the content returned by batch detail ) var cancel_object = new List{ batch_detail.data[0], batch_detail.data[1], }; sdk.Stock.BatchCancelOrder(account, cancel_object); // Batch cancel ( Using different individual orders ) var cancel_object = new List{ order_res.data[0], order_res.data[1], }; sdk.Stock.BatchCancelOrder(account, cancel_object); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult { functionType = 30, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000308998, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0028, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BSAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Order Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Reservation Order Flag (bool) status = 30, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.2, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 0, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 5000, // Before the Quantity Modification (int) beforePrice = 41.2, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 12:53:57.536, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) }, OrderResult { functionType = 30, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 0000030899, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0029, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Order Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Reservation Order Flag (bool) status = 30, // Order Status (int) ... } ] } ``` --- ### Batch Modify Price BatchModifyPrice ##### First, using 'MakeModifyPriceObj' create a 'ModifyPriceObj' object[​](#first-using-makemodifypriceobj-create-a-modifypriceobj-object "Direct link to First, using 'MakeModifyPriceObj' create a 'ModifyPriceObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'BatchModifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | ModifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#modifypriceobj) (list of object) | The object list for price modification | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | 參數 | 類別 | 說明 | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch price modification ( modifying orders using the content returned by batch detail ) var modified_orders = new List { sdk.Stock.MakeModifyPriceObj(batch_result.data[0], "41.1", null), sdk.Stock.MakeModifyPriceObj(batch_result.data[1], "41.2", null) }; var batch_modify_price = sdk.Stock.BatchModifyPrice(account, modified_orders); Console.WriteLine(batch_modify_price); // Batch price modification ( Using different individual orders ) var modified_orders = new List { sdk.Stock.MakeModifyPriceObj(orderResults.data[37], "41.1", null), sdk.Stock.MakeModifyPriceObj(orderResults.data[35], "41.2", null) }; var batch_modify_price = sdk.Stock.BatchModifyPrice(account, modified_orders); Console.WriteLine(batch_modify_price); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ // Batch price modification (modifying orders using the content returned by batch detail) OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Transaction Date (string) seqNo = 00000322356, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0018, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.1, // Valid Order Price (double) unit = 1000, // Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = , // Before the Quantity Modification (int) beforePrice = 41.3, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 13:56:57.713, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Transaction Date (string) seqNo = 00000322355, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0017, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = ROD, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) ... } ] } Below example only extract data content [ // Batch price modification( Using different individual orders ) OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Transaction Date (string) seqNo = 00000322388, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0033, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.1, // Valid Order Price (double) unit = 1000, // Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = , // Before the Quantity Modification (int) beforePrice = 41.3, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 10:56:57.713, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Transaction Date (string) seqNo = 00000322386, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = "26", // Account (string) orderNo = x0031, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) ... } ] ``` --- ### Batch Modify Quantity BatchModifyPrice ##### First, using 'MakeModifyQuantityObj' create a 'ModifyQuantityObj' object[​](#first-using-makemodifyquantityobj-create-a-modifyquantityobj-object "Direct link to First, using 'MakeModifyQuantityObj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) | The intended order result object to be modified | | quantity | int | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | ModifyQuantityObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#modifyquantityobj) (list of object) | The object list for quantity modification | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch quantity modification ( modifying orders using the content returned by batch detail ) var modified_orders = new List { sdk.Stock.MakeModifyQuantityObj(batch_result.data[0], 1000), sdk.Stock.MakeModifyQuantityObj(batch_result.data[1], 1000) }; var batch_modify_qty = sdk.Stock.BatchModifyQuantity(account, modified_orders); Console.WriteLine(batch_modify_qty); // Batch quantity modification ( Using different individual orders ) var modified_orders = new List { sdk.Stock.MakeModifyQuantityObj(orderResults.data[0], 1000), sdk.Stock.MakeModifyQuantityObj(orderResults.data[1], 1000) }; var batch_modify_qty = sdk.Stock.BatchModifyQuantity(account, modified_orders); Console.WriteLine(batch_modify_qty); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ // Batch quantity modification ( modifying orders using the content returned by batch detail ) OrderResult{ functionType = 20, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000000042, // Order Serial Number (string) branchNo = 20112, // Branch Number (string) account = 26, // Account (string) orderNo = x0026, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2881, // Symbol (string) buySell = Buy, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 66, // Order Price (double) quantity = 2000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = , // Valid Order Price Type (PriceType) afterPrice = 66, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 2000, // Before the Quantity Modification (int) beforePrice = , // Before the Price Modification (string) userDef = batch 2, // Custom Fields (string) lastTime = 12:21:51.023, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) }, OrderResult{ functionType = 20, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000000041, // Order Serial Number (string) branchNo = 20112, // Branch Number (string) account = 26, // Account (string) orderNo = x0025, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2881, // Symbol (string) buySell = Buy, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 66, // Order Price (double) quantity = 2000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = , // Valid Order Price Type (PriceType) afterPrice = 66, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 2000, // Before the Quantity Modification (int) beforePrice = , // Before the Price Modification (string) userDef = batch 1, // Custom Fields (string) lastTime = 12:21:51.023, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } ] } Below example only extract data content [ // Batch quantity modification ( Using different individual orders ) { functionType = 20, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000000043, // Order Serial Number (string) branchNo = 20112, // Branch Number (string) account = "26", // Account (string) orderNo = x0027, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MaeketType) stockNo = 2881, // Symbol (string) buySell = Buy, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = , // Valid Order Price Type (PriceType) afterPrice = 66, // Valid Order Price (double) unit = 1000, // Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 2000, // Before the Quantity Modification (int) beforePrice = , // Before the Price Modification (int) userDef = Test, // Custom Fields (string) lastTime = 12:21:53.023, // Last Modification Time (string) errorMessage = // Error Message (string) }, { functionType = 20, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000000044, // Order Serial Number (string) branchNo = 20112, // Branch Number (string) account = 26, // Account (string) orderNo = x0028, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2881, // Symbol (string) buySell = Buy, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 66, // Price (double) quantity = 2000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = , // Valid Order Price Type (PriceType) afterPrice = 66, // Valid Order Price (double) unit = 1000, // Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 2000, // Before the Quantity Modification (int) beforePrice = , // Before the Price Modification (string) userDef = Test, // Custom Fields (string) lastTime = 12:21:53.023, // Last Modification Time (string) errorMessage = // Error Message (string) } ] ``` --- ### Get Batch Order Detail BatchOrderDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | BatchOrderList | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#batchresult) | Batch order list | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | OrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```cs var batch_order_list = sdk.Stock.BatchOrderLists(account); var batch_order_detail = sdk.Stock.BatchOrderDetail(account, batch_order_list.data[0]); Console.WriteLine(batch_order_detail.data[0]); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = , // Function Type (int) date = 2023/10/18, // Date (string) seqNo = 00000000007, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = bA683, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 8.9, // Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time in Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 8.9, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 8.9, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 14:41:32.647, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) }, ... ] } ``` --- ### Get Batch Order List BatchOrderLists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | BatchResult list is returned | | message | string | isSuccess = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Stock.BatchOrderLists(account)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ BatchResult{ functionType = 0, // Type of function (int) date = 2023/10/04, // Query Date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) batchSeqNo = 11EE626533D072228000000C29304663 // Serial number (string) }, ... ] } ``` --- ### Place Batch Order BatchPlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderobject)(list of object) | Order Object | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | OrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orders = new Order[]{ new Order( BsAction.Buy, "2888", "8.90", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null ), new Order( BsAction.Buy, "2888", "8.90", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null )}; sdk.Stock.BatchPlaceOrder(account,orders.ToList()); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = 0, // Function Type (int) date = 2023/09/22, // Trading Date (string) seqNo = 00000221431, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = , // Order Number (string) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 8.9, // Order Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = true, // Reservation Flag (bool) status = 0, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 8.9, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 9.1, // Before the Price Modification (double) userDef = null, // Custom Fields (string) lastDatetime = null, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (String) }, OrderResult{ functionType = 0, // Function Type (int) date = 2023/09/22, // Trading Date (string) seqNo = 00000221432, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = , // Order Number (string) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 8.9, // Order Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = true, // Reservation Flag (bool) status = 0, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 8.9, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 9.1, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastDatetime = , // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } ] } ``` --- ### Cancel Order CancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | orderResult | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) | The intended order result object to be cancel | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Stock.CancelOrder(account, cancel_order)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = OrderResult{ functionType = 30, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000308948, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0023, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Order Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInforce) orderType = Stock, // Order Type (string) isPreOrder = False, // Reservation Order Flag (bool) status = 30, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.2, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 0, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 5000, // Before the Quantity Modification (int) beforePrice = 41.2, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 12:53:57.536, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Get Daytrade Quota and Precollect Information DaytradeAndStockInfo #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | stockNo | string | Symbol | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | DayTradeStockInfo | DayTradeStockInfo is returned | | message | string | isSuccess = False error description is returned | ##### DayTradeStockInfo Parameter[​](#daytradestockinfo-parameter "Direct link to DayTradeStockInfo Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | stockNo | string | Symbol | | date | string | Query Date | | daytradeOrigQuota | int | Original short daytrade quota | | daytradeTradableQuota | int | Available short daytrade quota | | precollectSingle | int | Precollect for single order | | precollectAccumulate | int | Precollect for accumulate order | | status | int | Status (bitmask type ) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | dispositionStatus | string | Disposition Status `{ SETTYPE : 1}` : Full-Cash-Delivery、 `{ MARK-W : 1}` : Warning、`{ MARK-P : 1}` : Attention、`{ MARK-L : 1}` : Order Placement Restricted 【**New field for version >=2.2.5**】 | info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```cs var daytrade = sdk.DaytradeAndStockInfo(account, "2330"); Console.WriteLine(daytrade); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [DayTradeStockInfo{ stockNo = 3264, // Stock symbol (string) date = 2023/10/04, // Query date (string) daytradeOrigQuota = 0, // Original short daytrade quota (int) daytradeTradableQuota = 0, // Available short daytrade quota (int) precollectSingle = , // Precollect for single order (int) precollectAccumulate = , // Precollect for accumulate order (int) status = 0, // Status (int) dispositionStatus = // Disposition Status (string)【New field for version >=2.2.5】 }] } ``` --- ### Get Historical Filled FilledHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Query start date | | endDate | string (null or empty will equals startDate ) | Query end date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FilledData list is returned | | message | string | isSuccess = False error description is returned | ##### FilledData Parameter[​](#filleddata-parameter "Direct link to FilledData Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | date | date | Filled Date | | branchNo | string | Branch number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order number | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | filledNo | string | Filled Transaction number | | filledAvgPrice | double | Filled Average Price | | filledQty | int | Filled Share | | filledPrice | double | Filled Price | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Stock.FilledHistory(account,"20230921","20230922")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FilledData{ date = 2023/09/15, // Trade date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) seqNo = , // Order serial number (string) orderNo = bA422, // Order number (string) stockNo = 1101, // Stock symbol (string) buySell = Sell, // Buy or sell direction (BsAction) filledNo = 00000000001, // Filled transaction number (string) filledAvgPrice = 35.2, // Filled Average Price (double) filledQty = 1000, // Filled Share (int) filledPrice = 35.2, // Filled Price (double) orderType = Stock, // Order type (OrderType) filledTime = 10:31:00.931 // Filled time (string) user_def = , // Custom Fields (string) }, ... ] } ``` --- ### Get Order Results GetOrderResult #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | OrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orderResults = sdk.Stock.GetOrderResults(accounts.data[0]); Console.WriteLine(orderResults); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = , // Type of function (int) date = 2023/10/13, // Trading Date (string) seqNo = 00000000002, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = bA614, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 9.0, // Order Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time in Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 9.0, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 9.0, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 10:05:54.608, // Last Modification Time (string) errorMessage = // Error Message (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) GetOrderResultDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | OrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process | | >> functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | int | Original Order Quantity | | >> afterQty | int | Valid Order Quantity (filled quantity included) | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> status | int | Order Status | | >> errMsg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orderResults = sdk.Stock.GetOrderResults(accounts.data[0]); Console.WriteLine(orderResults); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = , // Type of function (int) date = 2023/10/13, // Trading Date (string) seqNo = 00000000002, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = bA614, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 9.0, // Order Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time in Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 9.0, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 9.0, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 10:05:54.608, // Last Modification Time (string) errorMessage = // Error Message (string) details = [ // Order Detail (list) OrderDetail{ functionType = 10, // Function Type (int) modifiedTime = 10:05:54, // Order Modified Time (string) beforeQty = 0, // Original Order Quantity (int) afterQty = 2000, // Valid Order Quantity (int) beforePrice = 9.0, // Original Order Price (double) afterPrice = 9.0, // Valid Order Price (double) status = 10, // Order Status (int) errMsg= // Error Message (string) } ] }, ... ] } ``` --- ### Get Margin Quota MarginQuota #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | stockNo | string | symbol | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ---------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | MarginShortQuota | MarginShortQuota is returned | | message | string | isSuccess = False error description is returned | ##### MarginShortQuota Parameter[​](#marginshortquota-parameter "Direct link to MarginShortQuota Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------- | ------ | ---------------------------- | | stockNo | string | Symbol | | date | string | Query date (today) | | shortsellOrigQuota | int | The original shortsell quota | | shortsellTradableQuota | int | Available shortsell quota | | marginOrigQuota | int | The original margin quota | | marginTradableQuota | int | Available margin quota | | marginRatio | int | Margin Ration | | shortRatio | int | Short Sell Ration | info Explanation of Quota: If the marginRatio return empty, it means margin is halted. If the shorRatio return empty, it means short selling is halted. Explanation of Returned Quota: 0 - No quota / Greater than 0 - Quota available / Empty - No restrictions / Both of ratio of and quota return 0 - margin or short selling halted. #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Stock.MarginQuota(account, "2330")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = MarginShortQuota{ stockNo = 2330, // Stock symbol (string) date = 2024/01/24, // Query date (string) shortsellOrigQuota = 894, // The original short sell quota (int) shortsellTradableQuota = 894, // Available short sell quota (int) marginOrigQuota = , // The original margin quota (int) marginTradableQuota = , // Available margin quota (int) marginRatio = 60, // Margin Ratio (int) shortRatio = 90 // Short Sell Ratio (int) } } ``` --- ### Modify Order Price ModifyPrice ##### First, using 'MakeModifyPriceObj' create a 'ModifyPriceObj' object[​](#first-using-makemodifypriceobj-create-a-modifypriceobj-object "Direct link to First, using 'MakeModifyPriceObj' create a 'ModifyPriceObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'modifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | ModifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#modifypriceobj) | The object for price modification | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var modify_price_obj = sdk.Stock.MakeModifyPriceObj(order_result, "41.1", null); var modify_price = sdk.Stock.ModifyPrice(account, modify_price_obj); Console.WriteLine(modify_price); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = OrderResult{ functionType = 15, // Function Type (int) date = 2023/11/22, // Transaction Date (string) seqNo = 00000308866, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0011, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (BsAction) priceType = Limit, // Original Order Price Type (PriceType) price = 41.2, // Order Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.1, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 2000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = , // Before the Quantity Modification (int) beforePrice = 41.3, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 10:56:57.713, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Modify Order Quantity ModifyQuantity ##### First, using 'MakeModifyQuantityObj' create a 'ModifyQuantityObj' object[​](#first-using-makemodifyquantityobj-create-a-modifyquantityobj-object "Direct link to First, using 'MakeModifyQuantityObj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderresult) | The intended order result object to be modified | | quantity | int | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | Put the returned object into the 'ModifyQuantity' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | ModifyQuantutyObj | [ModifyQuantutyObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#modifyquantityobj) | The object for Quantity modification | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var modify_qty_obj = sdk.Stock.MakeModifyQuantityObj(order_result, 1000); var modify_qty = sdk.Stock.ModifyQuantity(account, modify_qty_obj); Console.WriteLine(modify_qty); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = OrderResult{ functionType = 20, // Function Type (int) date = 2024/03/08, // Transaction Date (string) seqNo = 00000308866, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = x0011, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Type (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 1101, // Symbol (string) buySell = Sell, // Buy/Sell Type (string) priceType = Limit, // Original Order Price Type (string) price = 41.2, // Order Price (double) quantity = 5000, // Original Order Quantity (int) timeInForce = Rod, // Time In Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Order Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 41.3, // Valid Order Price (double) unit = 1000, // Trading Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 3000, // Before the Quantity Modification (int) beforePrice = 41.2, // Before the Price Modification (double) userDef = 12345678, // Custom Fields (string) lastTime = 12:56:28.966, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Get Historical Order OrderHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Query start date | | endDate | string ( null or empty will equals startDate ) | Query end date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | OrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process | | >> functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | int | Original Order Quantity | | >> afterQty | int | Valid Order Quantity (filled quantity included) | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> status | int | Order Status | | >> errMsg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.Rrade.OrderHistory(account,"20230921","20230922")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = , // Function Type (int) date = 2023/10/12, // Trading Date (string) seqNo = 00000000001, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = bA598, // Order Number (string) assetType = 0, // Asset Type (int) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 8.9, // Order Price (double) quantity = 2000, // Order Quantity (int) timeInForce = Rod, // Time in Force (TimeInForce) orderType = Stock, // Order Type (int) isPreOrder = False, // Reservation Flag (bool) status = 10, // Order Status (int) afterPriceType = , // Valid Order Price Type (PriceType) afterPrice = 9, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 1000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = , // Before the Quantity Modification (int) beforePrice = , // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 14:19:41.879, // Last Modification Time (string) details = [ // Order Detail (list) OrderDetail{ functionType = 10, // Function Type (int) modifiedTime = 14:19:41.879, // Order Modified Time (string) beforeQty = 0, // Original Order Quantity (int) afterQty = 1000, // Valid Order Quantity (int) beforePrice = 9.0, // Original Order Price (double) afterPrice = 9.0, // Valid Order Price (double) status = 10, // Order Status (int) errMsg= // Error Message (string) } ] errorMessage = // Error Message (string) }, ... ] } ``` --- ### PlaceOrder PlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#orderobject) | Order Object | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | OrderResult | OrderResult is returned | | message | string | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` Emg | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Original OPrder Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | double | Order Price | | quantity | int | Original Order Quantity | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#timeinforce) | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#status) | | afterPriceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterQty | int | Valid Order Quantity (filled quantity included) | | filledQty | int | Filled Quantity | | filledMoney | int | Filled Value | | beforeQty | int | Before the Quantity Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.Rod, OrderType.Stock, null // User_def ); sdk.Stock.PlaceOrder(accounts.data[0],order); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = OrderResult{ functionType = 0, // Function Type (int) date = 2023/10/13, // Trading Date (string) seqNo = 00000000007, // Order Serial Number (string) branchNo = 6460, // Branch Number (string) account = 26, // Account (string) orderNo = bA619, // Order Number (string) market = TAIEX, // Market Category (string) marketType = Common, // Trading Session Type (MarketType) stockNo = 2888, // Symbol (string) buySell = Buy, // Transaction Direction (BsAction) priceType = Limit, // Order Price Type (PriceType) price = 9.1, // Order Price (double) quantity = 3000, // Order Quantity (int) timeInForce = Rod, // Time in Force (TimeInForce) orderType = Stock, // Order Type (OrderType) isPreOrder = False, // Reservation Flag (bool) status = 10, // Order Status (int) afterPriceType = Limit, // Valid Order Price Type (PriceType) afterPrice = 9.1, // Valid Order Price (double) unit = 1000, // Share Unit (int) afterQty = 3000, // Valid Order Quantity (int) filledQty = 0, // Filled Quantity (int) filledMoney = 0, // Filled Value (int) beforeQty = 0, // Before the Quantity Modification (int) beforePrice = 9.1, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 12:10:12.546, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Query Stock Quote Information (Single) QuerySymbolQuote info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | symbol | String | Symbol | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | --------- | ----------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | OrderResult | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | market | string | Market | | symbol | string | Symbol | | istibOrPsb | bool | Whether it is TIB or PSB board | | marketType | string | Market type | | status | int | Status (bitmask) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | referencePrice | double | Reference price | | unit | int | Trading unit | | updateTime | string | Update time | | limitupPrice | double | Upper price limit | | limitdownPrice | double | Lower price limit | | openPrice | double | Opening price | | highPrice | double | Highest price | | lowPrice | double | Lowest price | | lastPrice | double | Latest traded price | | totalVolume | int | Total traded volume | | totalTransaction | int | Total number of trades (Reserved field, not currently in use) | | totalValue | int | Total traded value | | lastSize | int | Latest traded volume | | lastTransaction | int | Latest number of trades (Reserved field, not currently in use) | | lastValue | int | Latest traded value | | bidPrice | double | Best bid price | | bidVolume | int | Best bid volume | | askPrice | double | Best ask price | | askVolume | int | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```cs var quote = sdk.Stock.QuerySymbolQuote(result.data[0],"2330"); Console.WriteLine(quote.data) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = SymbolQuote{ market = TAIEX, // string - Market symbol = 2330, // string - Symbol istibOrPsb = False, // bool - Whether it is TIB or PSB board marketType = Common, // string - Market type status = 15, // int - Status (bitmask sum) referencePrice = 780, // double - Reference price unit = 1000, // int - Trading unit updateTime = , // string - Update time limitupPrice = 858, // double - Upper price limit limitdownPrice = 702, // double - Lower price limit openPrice = 1155, // double - Opening price highPrice = 1160, // double - Highest price lowPrice = 1145, // double - Lowest price lastPrice = 1145, // double - Latest traded price totalVolume = 20501, // int - Total traded volume totalTransaction = 0, // int - Total number of trades (Reserved field, not currently in use) totalValue = 23551095000, // int - Total traded value lastSize = 6673, // int - Latest traded volume lastTransaction = 0, // int - Latest number of trades (Reserved field, not currently in use) lastValue = 7640585000, // int - Latest traded value bidPrice = 1145, // double - Best bid price bidVolume = 1549, // int - Best bid volume askPrice = 1150, // double - Best ask price askVolume = 4169 // int - Best ask volume } } ``` --- ### Query Stock Quote Information (Batch) QuerySymbolSnapshot info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Account | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#account) | Account | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | | stock\_type | List [StockType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/EnumMatrix.md#stocktype) (Optional)(default = Stock) | Product category: `Stock` (stocks), `ConvertBond` (convertible bonds), `ETF_and_ETN` (ETFs and ETNs) | #### Result[​](#result "Direct link to Result") | Parameter | Account | Description | | --------- | ---------------------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | SymbolSnapshotResponse | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | market | string | Markets | | symbol | string | Symbol | | istibOrPsb | bool | Whether it is TIB or PSB board | | marketType | string | Market type | | status | int | Status (bitmask sum) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | referencePrice | double | Reference price | | unit | int | Trading unit | | updateTime | string | Update time | | limitupPrice | double | Upper price limit | | limitdownPrice | double | Lower price limit | | openPrice | double | Opening price | | highPrice | double | Highest price | | lowPrice | double | Lowest price | | lastPrice | double | Latest traded price | | totalVolume | int | Total traded volume | | totalTransaction | int | Total number of trades (Reserved field, not currently in use) | | totalValue | int | Total traded value | | lastSize | int | Latest traded volume | | lastTransaction | int | Latest number of trades (Reserved field, not currently in use) | | lastValue | int | Latest traded value | | bidPrice | double | Best bid price | | bidVolume | int | Best bid volume | | askPrice | double | Best ask price | | askVolume | int | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.stock.QuerySymbolSnapshot(accounts.data[0]) // Default sdk.stock.QuerySymbolSnapshot(accounts.data[0], MarketType.Common, [StockType.Stock]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = SymbolQuote{ market = TAIEX, // string - Market symbol = 2330, // string - Symbol istibOrPsb = False, // bool - Whether it is TIB or PSB board marketType = Common, // string - Market type status = 15, // int - Status (bitmask sum) referencePrice = 780, // double - Reference price unit = 1000, // int - Trading unit updateTime = , // string - Update time limitupPrice = 858, // double - Upper price limit limitdownPrice = 702, // double - Lower price limit openPrice = 1155, // double - Opening price highPrice = 1160, // double - Highest price lowPrice = 1145, // double - Lowest price lastPrice = 1145, // double - Latest traded price totalVolume = 20501, // int - Total traded volume totalTransaction = 0, // int - Total number of trades (Reserved field, not currently in use) totalValue = 23551095000, // int - Total traded value lastSize = 6673, // int - Latest traded volume lastTransaction = 0, // int - Latest number of trades (Reserved field, not currently in use) lastValue = 7640585000, // int - Latest traded value bidPrice = 1145, // double - Best bid price bidVolume = 1549, // int - Best bid volume askPrice = 1150, // double - Best ask price askVolume = 4169 // int - Best ask volume }, SymbolQuote{ market = TAIEX, // string - Market symbol = 2881, // string - Symbol } } ``` --- ### Version Upgrade Guide This document will guide you through upgrading your existing Fubon Neo API version 1.0.4 to versions >= 1.3.1 #### Main differences[​](#main-differences "Direct link to Main differences") ##### C# CallBack Subscription[​](#c-callback-subscription "Direct link to C# CallBack Subscription") v1.0.4 callback ```cs public class MyCallback : Callback { public string code =""; public string response = ""; //Callback to receive order data public void OnOrder(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine("On Order" + response); } } //Callback to receive Modified data public void OnOrderChanged(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Modified" + response); } } //Callback to receive Filled data public void OnFilled(string code, FilledData data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Filled" + response); } } //Callback to receive Event data public void OnEvent(String code, String data) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Event" + response); } } var callback = new MyCallback(); sdk.RegisterCallback(callback); ``` #### Use the new subscription method[​](#use-the-new-subscription-method "Direct link to Use the new subscription method") With this update, a new subscription method has been released. Subscribe using the following method The new method allows subscription based on the desired category, eliminating the need to implement every method individually. ```cs sdk.OnEvent += (code, msg) => { Console.WriteLine(code + msg ); }; // Stock sdk.OnOrder += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); }; sdk.OnOrderChanged += (code, ordeResult) => { Console.WriteLine(code + ordeResult.ToString()); }; sdk.OnFilled += (code, filledData) => { Console.WriteLine(code + filledData.ToString()); }; // Future sdk.OnFutoptOrder += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); }; sdk.OnFutoptOrderChanged += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); }; sdk.OnFutoptFilled += (code, FutOptFilledData) => { Console.WriteLine(code + FutOptFilledData.ToString()); }; ``` --- ### Bank Balance Query BankRemain #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------ | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*BankRemain | Returns balance info | | Message | \*string | Returns error message when IsSuccess = false | ##### Balance Information BankRemain Fields[​](#balance-information-bankremain-fields "Direct link to Balance Information BankRemain Fields") Return type : Object | Parameter | Type | Description | | ---------------- | -------- | ----------------- | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | Currency | \*string | Currency | | Balance | \*int64 | Balance | | AvailableBalance | \*int64 | Available Balance | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Bank Balance bankRemain, err := sdk.Accounting.BankRemain(account) // Error Handling if err != nil { fmt.Printf("❌ Bank Remain Format Error: %v (Type: %T)\n", err, err) return } // Check Success if !bankRemain.IsSuccess { message := "No message" if bankRemain.Message != nil { message = *bankRemain.Message } fmt.Printf("Bank remain failed. Message: %s\n", message) return } // Output Balance Info if bankRemain.Data != nil { fmt.Println("✅ Bank Remain:") fmt.Printf("BranchNo: %s\n", *bankRemain.Data.BranchNo) fmt.Printf("Account: %s\n", *bankRemain.Data.Account) fmt.Printf("Currency: %s\n", *bankRemain.Data.Currency) fmt.Printf("Balance: %d\n", *bankRemain.Data.Balance) fmt.Printf("AvailableBalance: %d\n", *bankRemain.Data.AvailableBalance) } else { fmt.Println("Bank remain success but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // BankRemain Return Structure Result{ IsSuccess: true, Message: nil, Data: &BankRemain{ BranchNo: "6460", // Branch Code Account: "26", // Account Currency: "TWD", // Currency Balance: 666666, // Balance AvailableBalance: 123456, // Available Balance }, } ``` --- ### Inventory Query Inventories #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | -------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]Inventory | Returns inventory list | | Message | \*string | Returns error message when IsSuccess = false | ##### Inventory Information Inventory Fields[​](#inventory-information-inventory-fields "Direct link to Inventory Information Inventory Fields") Return type : Object | Parameter | Type | Description | | ---------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Transaction Date | | Account | \*string | Account | | BranchNo | \*string | Branch Code | | StockNo | \*string | Stock Symbol | | OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | LastdayQty | \*int64 | Previous Day Inventory Balance | | BuyQty | \*int64 | Today's Buy Quantity | | BuyFilledQty | \*int64 | Today's Buy Filled Quantity | | BuyValue | \*int64 | Buy Amount | | TodayQty | \*int64 | Today's Inventory Balance | | TradableQty | \*int64 | Tradable Quantity | | SellQty | \*int64 | Today's Sell Quantity | | SellFilledQty | \*int64 | Today's Sell Filled Quantity | | SellValue | \*int64 | Sell Amount | | Odd | \*InventoryOdd | Odd Lot Inventory Info | | >> LastdayQty | \*int64 | Previous Day Inventory Balance | | >> BuyQty | \*int64 | Today's Buy Quantity | | >> BuyFilledQty | \*int64 | Today's Buy Filled Quantity | | >> BuyValue | \*int64 | Buy Amount | | >> TodayQty | \*int64 | Today's Inventory Balance | | >> TradableQty | \*int64 | Tradable Quantity | | >> SellQty | \*int64 | Today's Sell Quantity | | >> SellFilledQty | \*int64 | Today's Sell Filled Quantity | | >> SellValue | \*int64 | Sell Amount | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Inventory inventories, err := sdk.Accounting.Inventories(account) // Error Handling if err != nil { fmt.Printf("❌ Inventories Error: %v (Type: %T)\n", err, err) return } // Check Success if !inventories.IsSuccess { message := "No message" if inventories.Message != nil { message = *inventories.Message } fmt.Printf("Inventories query failed. Message: %s\n", message) return } // Output Inventory List if inventories.Data != nil && len(*inventories.Data) > 0 { fmt.Printf("✅ Found %d inventory items\n", len(*inventories.Data)) for i, inv := range *inventories.Data { fmt.Printf("\n=== Inventory %d ===\n", i+1) fmt.Printf("StockNo: %s\n", *inv.StockNo) fmt.Printf("OrderType: %v\n", inv.OrderType) fmt.Printf("Previous Qty: %d\n", *inv.LastdayQty) fmt.Printf("Today Qty: %d\n", *inv.TodayQty) fmt.Printf("Tradable Qty: %d\n", *inv.TradableQty) fmt.Printf("Today Buy: %d (Filled: %d)\n", *inv.BuyQty, *inv.BuyFilledQty) fmt.Printf("Today Sell: %d (Filled: %d)\n", *inv.SellQty, *inv.SellFilledQty) // Odd Lot Info if inv.Odd != nil { fmt.Printf("\n Odd Lot Inventory:\n") fmt.Printf(" Today Odd Qty: %d\n", *inv.Odd.TodayQty) fmt.Printf(" Tradable Odd Qty: %d\n", *inv.Odd.TradableQty) } } } else { fmt.Println("Inventories query succeeded but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // Inventories Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]Inventory{ { Date: "2023/10/13", // Transaction Date Account: "26", // Account BranchNo: "6460", // Branch Code StockNo: "1101", // Stock Symbol OrderType: OrderTypeStock, // Order Type LastdayQty: 2000, // Previous Day Inventory Balance BuyQty: 0, // Today's Buy Quantity BuyFilledQty: 0, // Today's Buy Filled Quantity BuyValue: 0, // Buy Amount TodayQty: 2000, // Today's Inventory Balance TradableQty: 2000, // Tradable Quantity SellQty: 0, // Today's Sell Quantity SellFilledQty: 0, // Today's Sell Filled Quantity SellValue: 0, // Sell Amount Odd: &InventoryOdd{ // Odd Lot Inventory LastdayQty: 0, BuyQty: 0, BuyFilledQty: 0, BuyValue: 0, TodayQty: 0, TradableQty: 0, SellQty: 0, SellFilledQty: 0, SellValue: 0, }, }, // ... more inventory items }, } ``` --- ### Maintenance Ratio Query Maintenance #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ----------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*MaintenanceData | Returns maintenance ratio info | | Message | \*string | Returns error message when IsSuccess = false | ##### Maintenance Data Fields[​](#maintenance-data-fields "Direct link to Maintenance Data Fields") | Parameter | Type | Description | | --------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Query Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | MaintenanceSummary | \*MaintenanceSummary | Account Maintenance Summary | | >> MarginValue | \*int64 | Total Margin Value | | >> ShortsellValue | \*int64 | Total Short Sell Value | | >> ShortsellMargin | \*int64 | Total Short Sell Margin | | >> Collateral | \*int64 | Collateral | | >> MarginLoanAmt | \*int64 | Total Margin Loan Amount | | >> MaintenanceRatio | \*string | Maintenance Ratio (%) | | MaintenanceDetail | \*\[]MaintenanceDetail | Stock Maintenance Details | | >> StockNo | \*string | Stock Symbol | | >> OrderNo | \*string | Order Number | | >> OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | >> Quantity | \*int64 | Held Quantity | | >> Price | \*string | Calculation Price | | >> CostPrice | \*string | Cost Price | | >> ShortsellMargin | \*int64 | Short Sell Margin | | >> Collateral | \*int64 | Collateral | | >> MarginLoanAmt | \*int64 | Margin Loan Amount | | >> MaintenanceRatio | \*string | Maintenance Ratio (%) | | >> CollateralInterest | \*string | Collateral Interest | | >> MarginInterest | \*string | Margin Loan Interest | | >> ShortsellInterest | \*string | Short Sell Margin Interest | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Maintenance Ratio maintenance, err := sdk.Accounting.Maintenance(account) if err != nil { fmt.Printf("❌ Maintenance Format/Parser Error: %v\n", err) return } if maintenance.IsSuccess && maintenance.Data != nil { fmt.Println("✅ Maintenance Data:") // Account Summary if maintenance.Data.MaintenanceSummary != nil { summary := maintenance.Data.MaintenanceSummary fmt.Printf("\nAccount Maintenance Ratio: %s%%\n", *summary.MaintenanceRatio) fmt.Printf("Margin Value: %d\n", *summary.MarginValue) fmt.Printf("Margin Loan Amount: %d\n", *summary.MarginLoanAmt) fmt.Printf("Collateral: %d\n", *summary.Collateral) } // Stock Details if maintenance.Data.MaintenanceDetail != nil { fmt.Printf("\nStock Details (%d items):\n", len(*maintenance.Data.MaintenanceDetail)) for i, detail := range *maintenance.Data.MaintenanceDetail { fmt.Printf("\n[%d] %s\n", i+1, *detail.StockNo) fmt.Printf(" Held: %d shares\n", *detail.Quantity) fmt.Printf(" Cost: %s, Calc Price: %s\n", *detail.CostPrice, *detail.Price) fmt.Printf(" Maintenance Ratio: %s%%\n", *detail.MaintenanceRatio) } } } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &MaintenanceData{ Date: "2024/02/27", BranchNo: "6460", Account: "26", MaintenanceSummary: &MaintenanceSummary{ MarginValue: 3135000, ShortsellValue: 0, ShortsellMargin: 0, Collateral: 0, MarginLoanAmt: 1494000, MaintenanceRatio: "209.83", }, MaintenanceDetail: &[]MaintenanceDetail{ { StockNo: "2603", OrderNo: "x4580", OrderType: OrderTypeStock, Quantity: 10000, Price: "152.5", CostPrice: "119", ShortsellMargin: 0, Collateral: 0, MarginLoanAmt: 0, MaintenanceRatio: "213.58", CollateralInterest: "0", MarginInterest: "20818", ShortsellInterest: "0", }, }, }, } ``` --- ### Settlement Query QuerySettlement #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | range | string | Time range, valid values: "0d" (Today), "3d" (3 Days) | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*SettlementData | Returns settlement info | | Message | \*string | Returns error message when IsSuccess = false | ##### Settlement Data Fields[​](#settlement-data-fields "Direct link to Settlement Data Fields") | Parameter | Type | Description | | --------- | --------------- | ----------------------- | | Account | \*AccountRes | Account Info | | Details | \*\[]Settlement | Settlement Details List | ##### Account Info AccountRes Fields[​](#account-info-accountres-fields "Direct link to Account Info AccountRes Fields") | Parameter | Type | Description | | --------- | -------- | ----------- | | Account | \*string | Account | | BranchNo | \*string | Branch Code | ##### Settlement Details Settlement Fields[​](#settlement-details-settlement-fields "Direct link to Settlement Details Settlement Fields") | Parameter | Type | Description | | --------------------- | -------- | ---------------------------------- | | Date | \*string | Query Date | | SettlementDate | \*string | Settlement Date (Optional) | | BuyValue | \*int64 | Buy Amount (Optional) | | BuyFee | \*int64 | Buy Fee (Optional) | | BuySettlement | \*int64 | Buy Settlement Amount (Optional) | | BuyTax | \*int64 | Buy Tax (Optional) | | SellValue | \*int64 | Sell Amount (Optional) | | SellFee | \*int64 | Sell Fee (Optional) | | SellSettlement | \*int64 | Sell Settlement Amount (Optional) | | SellTax | \*int64 | Sell Tax (Optional) | | TotalBsValue | \*int64 | Total Buy/Sell Amount (Optional) | | TotalFee | \*int64 | Total Fee (Optional) | | TotalTax | \*int64 | Total Tax (Optional) | | TotalSettlementAmount | \*int64 | Total Settlement Amount (Optional) | | Currency | \*string | Currency (Optional) | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Settlement (3 Days) settlement, err := sdk.Accounting.QuerySettlement(account, "3d") if err != nil { fmt.Printf("❌ Query Settlement Format/Parser Error: %v\n", err) return } if settlement.IsSuccess && settlement.Data != nil { fmt.Println("✅ Settlement Data:") fmt.Printf("Account: %s\n", *settlement.Data.Account.Account) if settlement.Data.Details != nil { for i, detail := range *settlement.Data.Details { fmt.Printf("\n=== Day %d (%s) ===\n", i+1, *detail.Date) if detail.SettlementDate != nil { fmt.Printf("Settlement Date: %s\n", *detail.SettlementDate) fmt.Printf("Buy: %d (Fee: %d, Tax: %d)\n", *detail.BuyValue, *detail.BuyFee, *detail.BuyTax) fmt.Printf("Sell: %d (Fee: %d, Tax: %d)\n", *detail.SellValue, *detail.SellFee, *detail.SellTax) fmt.Printf("Total Settlement: %d\n", *detail.TotalSettlementAmount) } else { fmt.Println("No settlement data yet") } } } } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &SettlementData{ Account: &AccountRes{ Account: "26", BranchNo: "6460", }, Details: &[]Settlement{ { Date: "2024/03/04", SettlementDate: "2024/03/06", BuyValue: 735500, BuyFee: 313, BuySettlement: -1429513, BuyTax: 0, SellValue: 770500, SellFee: 320, SellSettlement: 0, SellTax: 2309, TotalBsValue: 1506000, TotalFee: 633, TotalSettlementAmount: -1429513, TotalTax: 2309, Currency: "TWD", }, { Date: "2024/03/06", SettlementDate: nil, // Settlement data not yet generated // Other fields are nil }, }, }, } ``` --- ### Realized P&L Query RealizedGainsAndLoses #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]Realized | Returns realized P\&L list | | Message | \*string | Returns error message when IsSuccess = false | ##### Realized Data Fields[​](#realized-data-fields "Direct link to Realized Data Fields") | Parameter | Type | Description | | -------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Data Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | StockNo | \*string | Stock Symbol | | BuySell | BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | FilledQty | \*int64 | Filled Quantity | | FilledPrice | \*string | Filled Price | | OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | RealizedProfit | \*int64 | Realized Profit Amount | | RealizedLoss | \*int64 | Realized Loss Amount | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Realized P&L Detail realized, err := sdk.Accounting.RealizedGainsAndLoses(account) if err != nil { fmt.Printf("❌ Realized P&L Format/Parser Error: %v\n", err) return } if realized.IsSuccess && realized.Data != nil { fmt.Printf("✅ Found %d realized records\n", len(*realized.Data)) } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]Realized{ { Date: "2023/08/16", // Data Date BranchNo: "6460", // Branch Code Account: "26", // Account StockNo: "1101", // Stock Symbol BuySell: BsActionSell, // Buy/Sell Action FilledQty: 1000, // Filled Quantity FilledPrice: "36.5", // Filled Price OrderType: OrderTypeStock,// Order Type RealizedProfit: 36339, // Realized Profit Amount RealizedLoss: 0, // Realized Loss Amount }, }, } ``` #### Notes[​](#notes "Direct link to Notes") 1. **Detail Records**: One record per filled transaction. 2. **Profit/Loss**: `RealizedProfit` and `RealizedLoss` will not have values simultaneously. 3. **Fees Included**: P\&L is net of fees and transaction tax. --- ### Realized P&L Summary RealizedGainsAndLosesSummary #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | -------------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]RealizedSummary | Returns realized P\&L summary list | | Message | \*string | Returns error message when IsSuccess = false | ##### Realized Summary Fields[​](#realized-summary-fields "Direct link to Realized Summary Fields") | Parameter | Type | Description | | --------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | StartDate | \*string | Summary Start Date | | EndDate | \*string | Summary End Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | StockNo | \*string | Stock Symbol | | BuySell | BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | FilledQty | \*int64 | Filled Quantity | | FilledAvgPrice | \*string | Filled Average Price | | RealizedProfitAndLoss | \*int64 | Realized P\&L Amount | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Realized P&L Summary realizedSum, err := sdk.Accounting.RealizedGainsAndLosesSummary(account) if err != nil { fmt.Printf("❌ Realized P&L Summary Format Parser error: %v\n", err) return } if realizedSum.IsSuccess && realizedSum.Data != nil { fmt.Printf("✅ Found %d realized summaries\n", len(*realizedSum.Data)) totalPnL := int64(0) for _, item := range *realizedSum.Data { fmt.Printf("\nStock: %s\n", *item.StockNo) fmt.Printf("Period: %s ~ %s\n", *item.StartDate, *item.EndDate) fmt.Printf("Filled Qty: %d\n", *item.FilledQty) fmt.Printf("Filled Avg Price: %s\n", *item.FilledAvgPrice) fmt.Printf("Realized P&L: %d\n", *item.RealizedProfitAndLoss) totalPnL += *item.RealizedProfitAndLoss } fmt.Printf("\nTotal Realized P&L: %d\n", totalPnL) } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]RealizedSummary{ { StartDate: "20230801", // Start Date EndDate: "20230801", // End Date BranchNo: "6460", // Branch Code Account: "26", // Account StockNo: "1101", // Stock Symbol BuySell: BsActionSell,// Buy/Sell Action OrderType: OrderTypeStock, // Order Type FilledQty: 3000, // Filled Quantity FilledAvgPrice: "35.7", // Filled Avg Price RealizedProfitAndLoss: 34026, // Realized P&L Amount }, }, } ``` --- ### Unrealized P&L Query UnrealizedGainsAndLoses #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]UnrealizedData | Returns unrealized P\&L list | | Message | \*string | Returns error message when IsSuccess = false | ##### Unrealized Data Fields[​](#unrealized-data-fields "Direct link to Unrealized Data Fields") | Parameter | Type | Description | | ---------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Inventory Creation Date | | BranchNo | \*string | Branch Code | | StockNo | \*string | Stock Symbol | | BuySell | BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | CostPrice | \*string | Cost Price | | TradableQty | \*int64 | Tradable Balance | | TodayQty | \*int64 | Today's Balance | | UnrealizedProfit | \*int64 | Unrealized Profit | | UnrealizedLoss | \*int64 | Unrealized Loss | info For common stock trading, `buy_sell` is always `Buy`, and the net position is indicated by the positive/negative sign of the balance. For margin trading, `buy_sell` is `Buy` or `Sell` to indicate the transaction type. #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Unrealized P&L unreal, err := sdk.Accounting.UnrealizedGainsAndLoses(account) if err != nil { fmt.Printf("❌ Unrealized P&L Format/Parser Error: %v\n", err) return } if unreal.IsSuccess && unreal.Data != nil { fmt.Printf("✅ Found %d positions\n", len(*unreal.Data)) totalProfit := int64(0) totalLoss := int64(0) for _, u := range *unreal.Data { fmt.Printf("\nStock: %s\n", *u.StockNo) fmt.Printf("Cost Price: %s\n", *u.CostPrice) fmt.Printf("Today Balance: %d\n", *u.TodayQty) fmt.Printf("Unrealized Profit: %d\n", *u.UnrealizedProfit) fmt.Printf("Unrealized Loss: %d\n", *u.UnrealizedLoss) totalProfit += *u.UnrealizedProfit totalLoss += *u.UnrealizedLoss } netPnL := totalProfit - totalLoss fmt.Printf("\nTotal Unrealized P&L: %d\n", netPnL) } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]UnrealizedData{ { Date: "2021/08/09", // Inventory Creation Date Account: "26", // Account BranchNo: "6460", // Branch Code StockNo: "2303", // Stock Symbol BuySell: Buy, // Buy/Sell Action OrderType: Short, // Order Type CostPrice: "50.0", // Cost Price TradableQty: 1000, // Tradable Balance TodayQty: 1000, // Today's Balance UnrealizedProfit: 45200, // Unrealized Profit UnrealizedLoss: 0, // Unrealized Loss }, }, } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### Order[​](#order "Direct link to Order") | Parameter | Type | Meaning | | ----------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | BuySell | BsAction | [Buy/Sell](#bsaction) Optional parameters: `BsActionBuy` Buy, `BsActionSell` Sell | | Symbol | string | Stock Symbol | | Price | \*string | Order Price (If not using `PriceTypeLimit` (Limit Price), pass ***nil***) | | Quantity | int64 | Order Quantity | | MarketType | MarketType | [Market Type](#markettype) Optional parameters: `MarketTypeCommon` Regular, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | PriceType | PriceType | [Price Flag](#pricetype) Optional parameters: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | TimeInForce | TimeInForce | [Order Condition](#timeinforce) Optional parameters: `TimeInForceRod`, `TimeInForceFok`, `TimeInForceIoc` | | OrderType | OrderType | [Order Type](#ordertype) Optional parameters: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade (for Day Trade Sell First), `OrderTypeSbl` SBL | | UserDef | \*string | User Defined Field (Max 10 characters, special characters and Chinese not supported. Not applicable for Emerging market) | caution Different `MarketType` corresponds to different units and ranges for `Quantity`. Please refer to the [Market Type](#markettype) description. caution When `MarketType` is one of `MarketTypeCommon`, `MarketTypeOdd`, or `MarketTypeIntradayOdd`, and `PriceType` is `PriceTypeLimit`, the `Price` field must be filled; otherwise, the `Price` field should be nil. caution For Day Trade Sell First operations: `OrderType` = `OrderTypeDayTrade`, `BuySell` must be `BsActionSell`, and `MarketType` must be `MarketTypeCommon`. (For **other** day trade entry/exit operations, orderType = `OrderTypeStock`) ##### OrderResult[​](#orderresult "Direct link to OrderResult") Order List, retrieved via [OrderResults(account)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/trade/GetOrderResults.md). | Parameter | Type | Description | | --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market Type: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Original Order Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time (Format: HH:MM:SS.fff or HH:MM:SS) | | ErrorMessage | \*string | Error Message | | Details | \*\[]OrderDetail | Order History (Value exists only when querying OrderResultsDetail or OrderHistory) | | >> FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `50` Fully Filled, `90` Fail | | >> ModifiedTime | \*string | Modified Time (Format: HH:MM:SS.fff or HH:MM:SS) | | >> BeforeQty | \*int64 | Original Order Quantity | | >> AfterQty | \*int64 | Effective Order Quantity (including filled part) | | >> BeforePrice | \*string | Original Order Price | | >> AfterPrice | \*string | Effective Order Price | | >> FilledMoney | \*string | Filled Amount | | >> Status | \*int64 | Order Status | | >> ErrMsg | \*string | Error Message | Time Format Description `last_time` and `modified_time` format: **HH:MM:SS.fff** or **HH:MM:SS** (omitted when .fff = .000) ##### BatchResult[​](#batchresult "Direct link to BatchResult") Batch Order List, retrieved via [BatchOrderLists(account)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/trade/batchOrder/BatchOrderList.md). | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | date | string | Transaction Date | | branchNo | string | Branch Code | | account | string | Account | | batchSeqNo | string | Batch Order Sequence Number | ##### ModifyPriceObj[​](#modifypriceobj "Direct link to ModifyPriceObj") Modify Price Object | Parameter | Type | Meaning | | ----------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | OrderResult | OrderResult | [Order List](#orderresult) | | Price | \*string | Price after modification | | PriceType | \*PriceType | Price Type after modification: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | ##### ModifyQuantityObj[​](#modifyquantityobj "Direct link to ModifyQuantityObj") Modify Quantity Object | Parameter | Type | Meaning | | ----------- | ----------- | --------------------------- | | OrderResult | OrderResult | [Order List](#orderresult) | | Quantity | int64 | Quantity after modification | ##### FilledData[​](#filleddata "Direct link to FilledData") Filled Report Object | Parameter | Type | Meaning | | -------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | SeqNo | \*string | Order Sequence Number (Only returned for active reports) | | OrderNo | \*string | Order Number | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | FilledNo | \*string | Fill Sequence Number | | FilledAvgPrice | \*string | Filled Average Price | | FilledQty | \*int64 | Filled Quantity | | FilledPrice | \*string | Filled Unit Price | | FilledTime | \*string | Filled Time | | UserDef | \*string | User Defined Field (Only returned for active reports) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ----------- | ------ | -------------------------------------------------------------------------- | | Name | string | Client Name | | Account | string | Account | | BranchNo | string | Branch Code | | AccountType | string | Account Type, returns `stock` for Securities, `futopt` for Futures/Options | #### Constants (Enum Values)[​](#constants-enum-values "Direct link to Constants (Enum Values)") ##### BsAction[​](#bsaction "Direct link to BsAction") Buy/Sell Action | Name | Value | Meaning | | ------------ | ----- | ------- | | BsActionBuy | 1 | Buy | | BsActionSell | 2 | Sell | ##### MarketType[​](#markettype "Direct link to MarketType") Market Type | Name | Value | Meaning | | --------------------- | ----- | ------------------- | | MarketTypeCommon | 1 | Regular (Common) | | MarketTypeFixing | 2 | Fixing | | MarketTypeOdd | 3 | Post-market Odd Lot | | MarketTypeIntradayOdd | 4 | Intraday Odd Lot | | MarketTypeEmg | 5 | Emerging | | MarketTypeEmgOdd | 6 | Emerging Odd Lot | When using different `MarketType`, the unit and range represented by `Quantity` will differ, as shown below: | Name | Quantity Unit | Quantity Ranges | | --------------------- | ------------- | --------------- | | MarketTypeCommon | 1,000 Shares | 1000 ~ 499000 | | MarketTypeFixing | 1,000 Shares | 1000 ~ 499000 | | MarketTypeIntradayOdd | Shares | 1 ~ 999 | | MarketTypeOdd | Shares | 1 ~ 999 | | MarketTypeEmg | 1,000 Shares | 1000 ~ 499000 | | MarketTypeEmgOdd | Shares | 1 ~ 999 | When using different `MarketType`, the available `PriceType` and `TimeInForce` will differ, as shown below: | MarketType | Available PriceType | Available TimeInForce | | --------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- | | MarketTypeCommon | PriceTypeLimit, PriceTypeLimitUp, PriceTypeLimitDown, PriceTypeMarket, PriceTypeReference | TimeInForceRod, TimeInForceIoc, TimeInForceFok | | MarketTypeFixing | PriceTypeReference | TimeInForceRod | | MarketTypeIntradayOdd | PriceTypeLimit, PriceTypeLimitUp, PriceTypeLimitDown, PriceTypeReference | TimeInForceRod | | MarketTypeOdd | PriceTypeLimit, PriceTypeLimitUp, PriceTypeLimitDown, PriceTypeReference | TimeInForceRod | | MarketTypeEmg | PriceTypeLimit | TimeInForceRod | | MarketTypeEmgOdd | PriceTypeLimit | TimeInForceRod | ##### PriceType[​](#pricetype "Direct link to PriceType") Price Type | Name | Value | Meaning | | ------------------ | ----- | -------------------------------------- | | PriceTypeLimit | 1 | Limit | | PriceTypeLimitUp | 2 | Limit Up | | PriceTypeLimitDown | 3 | Limit Down | | PriceTypeMarket | 4 | Market | | PriceTypeReference | 5 | Reference (Fixing Price during Fixing) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Order Condition | Name | Value | Meaning | | -------------- | ----- | ------------------------- | | TimeInForceRod | 1 | Rest of Day (ROD) | | TimeInForceFok | 2 | Fill-or-Kill (FOK) | | TimeInForceIoc | 3 | Immediate-or-Cancel (IOC) | ##### OrderType[​](#ordertype "Direct link to OrderType") Order Type | Name | Value | Meaning | | ----------------- | ----- | -------------------------------------- | | OrderTypeStock | 1 | Common (Stock) | | OrderTypeMargin | 2 | Margin | | OrderTypeShort | 3 | Short Sell | | OrderTypeSbl | 4 | SBL (Securities Borrowing and Lending) | | OrderTypeDayTrade | 5 | Day Trade | ##### StockType[​](#stocktype "Direct link to StockType") Stock Category | Name | Value | Meaning | | -------------------- | ----- | ---------------- | | StockTypeStock | 0 | Stock | | StockTypeConvertBond | 1 | Convertible Bond | | StockTypeEtfAndEtn | 3 | ETF and ETN | ##### FunctionType[​](#functiontype "Direct link to FunctionType") Function Type | Name | Value | | -------------------------------- | ----- | | New Order | 0 | | Execute New Order | 10 | | Change Price | 15 | | Change Qty | 20 | | Cancel Order | 30 | | Fully Filled (for Order History) | 50 | | Fail | 90 | ##### Market[​](#market "Direct link to Market") Market | Name | Value | | --------------- | ------- | | Listed Stocks | TAIEX | | OTC Stocks | TAISDAQ | | Emerging Stocks | TAIEMG | ##### Status[​](#status "Direct link to Status") Order Status | Name | Value | | ------------------------------------ | ----------------------------------------------------------- | | Pre-order | 0 | | Sending to Backend | 4 (Use OrderResults to check status) | | Sending to Exchange | 8 (Use OrderResults to check status) | | Connection Timeout | 9 (Please check OrderResults later or contact your agent) | | Order Success | 10 | | Cancelled Unfilled | 30 | | Partial Fill/Rest Cancelled | 40 | | Fully Filled | 50 | | Order History Query Flag | 14 - Change Price ACK, 24 - Change Qty ACK, 34 - Cancel ACK | | Change Price Success (Order History) | 15 | | Change Qty Success (Order History) | 20 | | Change Price Failed (Active Report) | 19 | | Change Qty Failed (Active Report) | 29 | | Cancel Failed (Active Report) | 39 | --- ### API Key Login ApikeyLogin Version Requirement New feature added in version 2.2.7 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ------ | -------------------- | | personalID | String | Login ID | | key | String | Applied API Key | | certPath | String | Certificate Path | | certPass | String | Certificate Password | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------ | -------------------------------------------- | | isSuccess | bool | Whether the login was successful | | data | List | Returns account information | | message | string | Returns error message when isSuccess = False | ##### Account Information Fields[​](#account-information-fields "Direct link to Account Information Fields") Return type : Object | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------------------------------------- | | name | String | Client Name | | account | String | Client Account | | branchNo | String | Branch Code | | accountType | string | Account Type. Returns `stock` for Securities, `futopt` for Futures/Options | #### Request Example[​](#request-example "Direct link to Request Example") ```go loginResp, err := sdk.ApikeyLogin(personalId, key, certPath, &certPass) if err != nil { fmt.Printf("❌ Login Format/Parse Error: %v (Type: %T)\n", err, err) return } if loginResp.IsSuccess { fmt.Println("✓ Login successful!") } else { fmt.Printf("❌ Login failed: %s\n", *loginResp.Message) return } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go { isSuccess = true, message = , data = [ Account{ name = Fubon Bill, // Client Name (string) account = 28, // Client Account (string) branchNo = 6460, // Branch Code (string) accountType = stock // Account Type (string) } ] } ``` --- ### Login login #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ------ | -------------------- | | personalID | String | Login ID | | password | String | Login Password | | certPath | String | Certificate Path | | certPass | String | Certificate Password | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------ | -------------------------------------------- | | isSuccess | bool | Whether the login was successful | | data | List | Returns account information | | message | string | Returns error message when isSuccess = False | ##### Account Information Fields[​](#account-information-fields "Direct link to Account Information Fields") Return type : Object | Parameter | Type | Description | | ----------- | ------ | -------------------------------------------------------------------------- | | name | String | Client Name | | account | String | Client Account | | branchNo | String | Branch Code | | accountType | string | Account Type. Returns `stock` for Securities, `futopt` for Futures/Options | #### Request Example[​](#request-example "Direct link to Request Example") ```go loginResp, err := sdk.Login(personalId, password, certPath, &certPass) if err != nil { fmt.Printf("❌ Login Format/Parse Error: %v (Type: %T)\n", err, err) return } if loginResp.IsSuccess { fmt.Println("✓ Login successful!") } else { fmt.Printf("❌ Login failed: %s\n", *loginResp.Message) return } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go { isSuccess = true, message = , data = [ Account{ name = Fubon Bill, // Client Name (string) account = 28, // Client Account (string) branchNo = 6460, // Branch Code (string) accountType = stock // Account Type (string) } ] } ``` --- ### Logout Logout #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---- | ------------------ | | isSuccess | bool | Whether successful | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) sdk := fubon.NewFubonCore() // login ... logoutResp, err := sdk.Logout() fmt.Println("Logout result: ", logoutResp) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Logout result: true ``` --- ### Batch Cancel Order BatchCancelOrder #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | ------------------------------------------------------------------------------------------- | ------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | orderResults | \[]OrderResult | List of orders to batch cancel | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns cancellation result list | | Message | \*string | Returns error message when IsSuccess = false | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Method 1: Batch cancel (using content returned by batch detail) batchList, _ := sdk.Stock.BatchOrderLists(account) if batchList.Data != nil && len(*batchList.Data) > 0 { batchRes := (*batchList.Data)[0] batchDetail, _ := sdk.Stock.BatchOrderDetail(account, batchRes) if batchDetail.Data != nil && len(*batchDetail.Data) >= 2 { cancelOrders := []fubon.OrderResult{ (*batchDetail.Data)[0], (*batchDetail.Data)[1], } batchCancel, err := sdk.Stock.BatchCancelOrder(account, cancelOrders) if err != nil { fmt.Printf("❌ Batch Cancel Order Format/Parse Error: %v\n", err) return } if batchCancel.IsSuccess && batchCancel.Data != nil { fmt.Printf("✅ Cancelled %d orders\n", len(*batchCancel.Data)) for i, result := range *batchCancel.Data { fmt.Printf("Order %d: OrderNo=%s, Status=%d (30=Cancelled)\n", i+1, *result.OrderNo, *result.Status) } } } } // Method 2: Batch cancel (using different single orders) ordResult, _ := sdk.Stock.OrderResults(account) if ordResult.Data != nil && len(*ordResult.Data) >= 2 { cancelOrders := []fubon.OrderResult{ (*ordResult.Data)[0], (*ordResult.Data)[1], } batchCancel, err := sdk.Stock.BatchCancelOrder(account, cancelOrders) if err != nil { fmt.Printf("❌ Batch Cancel Order Format/Parse Error: %v\n", err) return } if !batchCancel.IsSuccess { message := "No message" if batchCancel.Message != nil { message = *batchCancel.Message } fmt.Printf("Batch cancel failed. Message: %s\n", message) return } if batchCancel.Data != nil { fmt.Println("✅ Batch cancel succeeded!") for i, result := range *batchCancel.Data { fmt.Printf("\n--- Cancelled Order %d ---\n", i+1) fmt.Printf("FunctionType: %d (30=Cancel)\n", *result.FunctionType) fmt.Printf("OrderNo: %s\n", *result.OrderNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("Status: %d\n", *result.Status) fmt.Printf("AfterQty: %d (0 after cancel)\n", *result.AfterQty) fmt.Printf("BeforeQty: %d\n", *result.BeforeQty) } } } else { fmt.Println("⚠️ No orders found for batch cancellation") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: 30, // Function Type (30=Cancel) Date: "2024/03/08", // Transaction Date SeqNo: "00000308998", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "x0028", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "1101", // Stock Symbol BuySell: Sell, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "41.2", // Price Quantity: 5000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 30, // Order Status (30=Cancelled Unfilled) AfterPrice: "41.2", // Effective Price AfterQty: 0, // Effective Order Quantity (0 after cancellation) BeforeQty: 5000, // Effective Qty Before Change BeforePrice: "41.2", // Effective Price Before Change UserDef: "12345678", // User Defined Field LastTime: "12:53:57.536", // Last Modified Time // ... Other fields }, { FunctionType: 30, // Function Type (30=Cancel) Date: "2024/03/08", // Transaction Date SeqNo: "0000030899", // Order Sequence Number OrderNo: "x0029", // Order Number StockNo: "1101", // Stock Symbol Status: 30, // Order Status // ... Other fields }, }, } ``` --- ### Batch Modify Order Price BatchModifyPrice ##### First use MakeModifyPriceObj to create a ModifyPriceObj object[​](#first-use-makemodifypriceobj-to-create-a-modifypriceobj-object "Direct link to First use MakeModifyPriceObj to create a ModifyPriceObj object") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | ------------------------ | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#orderresult) | The order to be modified | | price | \*string | The modified price | | priceType | \*PriceType | The modified price flag | caution When the `price` field has a value, `priceType` must be `nil`. When `priceType` has a value, `price` must be `nil`. Pass the returned object into the BatchModifyPrice method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------------- | ------------------------------------------------------------------------------------------- | ---------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | modifyPriceObjs | \[]ModifyPriceObj | List of price modification objects | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns modification information list | | Message | \*string | Returns error message when IsSuccess = false | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Method 1: Modify price using content returned by batch detail batchList, _ := sdk.Stock.BatchOrderLists(account) if batchList.Data != nil && len(*batchList.Data) > 0 { batchRes := (*batchList.Data)[0] batchDetail, _ := sdk.Stock.BatchOrderDetail(account, batchRes) if batchDetail.Data != nil && len(*batchDetail.Data) >= 2 { price1 := "41.1" price2 := "41.2" modifyObjs := []fubon.ModifyPrice{ sdk.Stock.MakeModifyPriceObj((*batchDetail.Data)[0], &price1, nil), sdk.Stock.MakeModifyPriceObj((*batchDetail.Data)[1], &price2, nil), } batchPrice, err := sdk.Stock.BatchModifyPrice(account, modifyObjs) if err != nil { fmt.Printf("❌ Batch Modify Price Format/Parse Error: %v\n", err) return } if batchPrice.IsSuccess && batchPrice.Data != nil { fmt.Printf("✅ Modified %d orders\n", len(*batchPrice.Data)) } } } // Method 2: Modify price using different single orders ordResult, _ := sdk.Stock.OrderResults(account) if ordResult.Data != nil && len(*ordResult.Data) >= 2 { price1 := "41.1" price2 := "41.2" modifyObjs := []fubon.ModifyPrice{ sdk.Stock.MakeModifyPriceObj((*ordResult.Data)[0], &price1, nil), sdk.Stock.MakeModifyPriceObj((*ordResult.Data)[1], &price2, nil), } batchPrice, _ := sdk.Stock.BatchModifyPrice(account, modifyObjs) // ... Handle result } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: 15, // Function Type (15=Change Price) Date: "2023/11/22", // Transaction Date SeqNo: "00000322356", // Order Sequence Number OrderNo: "x0018", // Order Number StockNo: "1101", // Stock Symbol BeforePrice: "41.3", // Effective Price Before Change AfterPrice: "41.1", // Effective Price (After modification) // ... Other fields }, // ... More modification results }, } ``` --- ### Batch Modify Order Quantity BatchModifyQuantity ##### First use MakeModifyQuantityObj to create a ModifyQuantityObj object[​](#first-use-makemodifyquantityobj-to-create-a-modifyquantityobj-object "Direct link to First use MakeModifyQuantityObj to create a ModifyQuantityObj object") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#orderresult) | The order to be modified | | quantity | int64 | The modified quantity (Quantity after modification includes the filled part of this order) | Pass the returned object into the BatchModifyQuantity method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | modifyQuantityObjs | \[]ModifyQuantityObj | List of quantity modification objects | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns modification information list | | Message | \*string | Returns error message when IsSuccess = false | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Method 1: Modify quantity using content returned by batch detail batchList, _ := sdk.Stock.BatchOrderLists(account) if batchList.Data != nil && len(*batchList.Data) > 0 { batchRes := (*batchList.Data)[0] batchDetail, _ := sdk.Stock.BatchOrderDetail(account, batchRes) if batchDetail.Data != nil && len(*batchDetail.Data) >= 2 { modifyObjs := []fubon.ModifyQuantity{ sdk.Stock.MakeModifyQuantityObj((*batchDetail.Data)[0], 1000), sdk.Stock.MakeModifyQuantityObj((*batchDetail.Data)[1], 1000), } batchQty, err := sdk.Stock.BatchModifyQuantity(account, modifyObjs) if err != nil { fmt.Printf("❌ Batch Modify Quantity Format/Parse Error: %v\n", err) return } if batchQty.IsSuccess && batchQty.Data != nil { fmt.Printf("✅ Modified %d orders quantity\n", len(*batchQty.Data)) for i, result := range *batchQty.Data { fmt.Printf("Order %d: BeforeQty=%d, AfterQty=%d\n", i+1, *result.BeforeQty, *result.AfterQty) } } } } // Method 2: Modify quantity using different single orders ordResult, _ := sdk.Stock.OrderResults(account) if ordResult.Data != nil && len(*ordResult.Data) >= 2 { modifyObjs := []fubon.ModifyQuantity{ sdk.Stock.MakeModifyQuantityObj((*ordResult.Data)[0], 1000), sdk.Stock.MakeModifyQuantityObj((*ordResult.Data)[1], 1000), } batchQty, _ := sdk.Stock.BatchModifyQuantity(account, modifyObjs) // ... Handle result } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: 20, // Function Type (20=Change Qty) Date: "2024/03/08", // Transaction Date SeqNo: "00000000042", // Order Sequence Number OrderNo: "x0026", // Order Number StockNo: "2881", // Stock Symbol BeforeQty: 2000, // Effective Qty Before Change AfterQty: 1000, // Effective Order Quantity (After modification) UserDef: "batch 2", // User Defined Field // ... Other fields }, // ... More modification results }, } ``` --- ### Get Batch Order Detail BatchOrderDetail #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | --------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | batchResult | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#batchresult) | Batch Order List Item | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns order information list | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | caution This function is only for querying the result of batch order submission. To get the latest status of orders, please use the single order query function. #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get batch order list first batchList, err := sdk.Stock.BatchOrderLists(account) if err != nil { fmt.Printf("❌ Get Batch List Format/Parse Error: %v\n", err) return } // Select the first batch to query details if batchList.Data != nil && len(*batchList.Data) > 0 { batchRes := (*batchList.Data)[0] fmt.Printf("Querying batch detail for: %s\n", *batchRes.BatchSeqNo) // Query Batch Order Detail batchDetail, err := sdk.Stock.BatchOrderDetail(account, batchRes) if err != nil { fmt.Printf("❌ Batch Order Detail Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !batchDetail.IsSuccess { message := "No message" if batchDetail.Message != nil { message = *batchDetail.Message } fmt.Printf("Get order result failed. Message: %s\n", message) return } // Output Batch Details if batchDetail.Data != nil && len(*batchDetail.Data) > 0 { fmt.Printf("✅ Batch contains %d orders\n", len(*batchDetail.Data)) for i, result := range *batchDetail.Data { fmt.Printf("\n--- Order %d ---\n", i+1) fmt.Printf("OrderNo: %s\n", *result.OrderNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("BuySell: %v\n", *result.BuySell) fmt.Printf("Price: %s\n", *result.Price) fmt.Printf("Quantity: %d\n", *result.Quantity) fmt.Printf("Status: %d\n", *result.Status) } } else { fmt.Println("Order result success but no data returned.") } } else { fmt.Println("⚠️ No batch orders found") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // BatchOrderDetail Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: nil, // Function Type Date: "2023/10/18", // Date SeqNo: "00000000007", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "bA683", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "8.9", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: Limit, // Effective Price Type AfterPrice: "8.9", // Effective Price Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "8.9", // Effective Price Before Change UserDef: "", // User Defined Field LastTime: "14:41:32.647", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, // ... more orders }, } ``` --- ### Get Batch Order List BatchOrderLists #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]BatchResult | Returns batch order info list | | Message | \*string | Returns error message when IsSuccess = false | ##### Batch Order BatchResult Fields[​](#batch-order-batchresult-fields "Direct link to Batch Order BatchResult Fields") Return type : Object | Parameter | Type | Description | | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | BatchSeqNo | \*string | Batch Order Sequence Number | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Batch Order List batchList, err := sdk.Stock.BatchOrderLists(account) // Error Handling if err != nil { fmt.Printf("❌ Get Batch List Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !batchList.IsSuccess { message := "No message" if batchList.Message != nil { message = *batchList.Message } fmt.Printf("Get batch list failed. Message: %s\n", message) return } // Output Batch List if batchList.Data != nil && len(*batchList.Data) > 0 { fmt.Printf("✅ Found %d batch orders\n", len(*batchList.Data)) for i, batch := range *batchList.Data { fmt.Printf("\n--- Batch %d ---\n", i+1) fmt.Printf("Date: %s\n", *batch.Date) fmt.Printf("BatchSeqNo: %s\n", *batch.BatchSeqNo) fmt.Printf("FunctionType: %d\n", *batch.FunctionType) fmt.Printf("Account: %s\n", *batch.Account) } } else { fmt.Println("Get batch list success but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // BatchOrderLists Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]BatchResult{ { FunctionType: 0, // Function Type (New Order) Date: "2023/10/04", // Transaction Date BranchNo: "6460", // Branch Code Account: "26", // Account BatchSeqNo: "11EE626533D072228000000C29304663", // Batch Order Sequence Number }, // ... more batch orders }, } ``` --- ### Batch Place Order BatchPlaceOrder #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ---------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | orders | \[]Order | List of order contents | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns order information list | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Prepare Batch Orders userDef1 := "batch1" userDef2 := "batch2" orders := []fubon.Order{ { BuySell: fubon.BsActionBuy, Symbol: "2881", Price: nil, // Use PriceType to specify Quantity: 2000, MarketType: fubon.MarketTypeCommon, PriceType: fubon.PriceTypeLimitDown, // Limit Down TimeInForce: fubon.TimeInForceRod, OrderType: fubon.OrderTypeStock, UserDef: &userDef1, }, { BuySell: fubon.BsActionBuy, Symbol: "2881", Price: nil, Quantity: 2000, MarketType: fubon.MarketTypeCommon, PriceType: fubon.PriceTypeLimitDown, TimeInForce: fubon.TimeInForceRod, OrderType: fubon.OrderTypeStock, UserDef: &userDef2, }, } // Place Batch Order batResult, err := sdk.Stock.BatchPlaceOrder(account, orders) // Error Handling if err != nil { fmt.Printf("❌ Batch Place Order Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !batResult.IsSuccess { message := "No message" if batResult.Message != nil { message = *batResult.Message } fmt.Printf("Batch place order failed. Message: %s\n", message) return } // Output Batch Place Order Result if batResult.Data != nil && len(*batResult.Data) > 0 { fmt.Printf("✅ Batch placed %d orders successfully!\n", len(*batResult.Data)) for i, result := range *batResult.Data { fmt.Printf("\n--- Order %d ---\n", i+1) fmt.Printf("SeqNo: %s\n", *result.SeqNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("Price: %s\n", *result.Price) fmt.Printf("Quantity: %d\n", *result.Quantity) fmt.Printf("Status: %d\n", *result.Status) if result.UserDef != nil { fmt.Printf("UserDef: %s\n", *result.UserDef) } } } else { fmt.Println("Batch order succeeded but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // BatchPlaceOrder Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: 0, // Function Type (New Order) Date: "2023/09/22", // Transaction Date SeqNo: "00000221431", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "", // Order Number Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "8.9", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: true, // Is Pre-order Status: 0, // Order Status (Pre-order) AfterPriceType: Limit, // Effective Price Type AfterPrice: "8.9", // Effective Price Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "9.1", // Effective Price Before Change UserDef: nil, // User Defined Field LastTime: nil, // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, { FunctionType: 0, // Function Type (New Order) Date: "2023/09/22", // Transaction Date SeqNo: "00000221432", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "", // Order Number Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "8.9", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: true, // Is Pre-order Status: 0, // Order Status AfterPriceType: Limit, // Effective Price Type AfterPrice: "8.9", // Effective Price Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "9.1", // Effective Price Before Change UserDef: nil, // User Defined Field LastTime: nil, // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, }, } ``` --- ### Cancel Order CancelOrder #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#orderresult) | The order object to cancel | | unblock | \*bool (optional) (default = false) | Whether to use non-blocking | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*OrderResult | Returns order information | | Message | \*string | Returns error message when IsSuccess = false | ##### Cancellation Information OrderResult Fields[​](#cancellation-information-orderresult-fields "Direct link to Cancellation Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get Order List ordResult, err := sdk.Stock.OrderResults(account) if err != nil { fmt.Printf("❌ Get Order Results Error: %v\n", err) return } // Select order to cancel var cancelOrder fubon.OrderResult if ordResult.Data != nil && len(*ordResult.Data) > 0 { cancelOrder = (*ordResult.Data)[0] fmt.Println("Selected order for cancellation") fmt.Printf("OrderNo: %s, StockNo: %s\n", *cancelOrder.OrderNo, *cancelOrder.StockNo) // Cancel Order unblock := false cancelRes, err := sdk.Stock.CancelOrder(account, cancelOrder, &unblock) if err != nil { fmt.Printf("❌ Cancel Order Error: %v (Type: %T)\n", err, err) return } // Check Success if !cancelRes.IsSuccess { message := "No message" if cancelRes.Message != nil { message = *cancelRes.Message } fmt.Printf("Cancel failed. Message: %s\n", message) return } // Output Cancellation Result if cancelRes.Data != nil { fmt.Println("✅ Order cancelled successfully!") fmt.Printf("FunctionType: %d (30=Cancel)\n", *cancelRes.Data.FunctionType) fmt.Printf("Status: %d (30=Cancelled Unfilled)\n", *cancelRes.Data.Status) fmt.Printf("OrderNo: %s\n", *cancelRes.Data.OrderNo) fmt.Printf("AfterQty: %d\n", *cancelRes.Data.AfterQty) } else { fmt.Println("Order cancelled but no data returned.") } } else { fmt.Println("⚠️ No orders found for cancellation") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // CancelOrder Return Structure Result{ IsSuccess: true, Message: nil, Data: &OrderResult{ FunctionType: 30, // Function Type (30=Cancel) Date: "2024/03/08", // Transaction Date SeqNo: "00000308948", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "x0023", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "1101", // Stock Symbol BuySell: Sell, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "41.2", // Price Quantity: 5000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 30, // Order Status (30=Cancelled Unfilled) AfterPriceType: Limit, // Effective Price Type AfterPrice: "41.2", // Effective Price Unit: 1000, // Unit AfterQty: 0, // Effective Order Quantity (0 after cancellation) FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 5000, // Effective Qty Before Change BeforePrice: "41.2", // Effective Price Before Change UserDef: "12345678", // User Defined Field LastTime: "12:53:57.536", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, } ``` #### Notes[​](#notes "Direct link to Notes") 1. **Cancellation Conditions**: Only unfilled or partially filled orders can be cancelled. Fully filled orders cannot be cancelled. 2. **FunctionType**: hen cancellation is successful, `FunctionType` is `30`. 3. **Status**: When cancellation is successful, `Status` is `30` (Cancelled Unfilled) or `40` (Partial Fill/Rest Cancelled). 4. **AfterQty**: After successful cancellation, `AfterQty` becomes `0`, indicating no effective order quantity. 5. **Order Object**: You need to obtain the order list via `OrderResults()` first, and then select the order to cancel. 6. **Non-blocking Mode**: Use the `&unblock` parameter to set whether to use non-blocking mode, default is `false` (blocking mode). --- ### Day Trade Stock Info Query DaytradeAndStockInfo #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | stockNo | string | Stock Symbol | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*DayTradeStockInfo | Returns quota information | | Message | \*string | Returns error message when IsSuccess = false | ##### Quota Information DayTradeStockInfo Fields[​](#quota-information-daytradestockinfo-fields "Direct link to Quota Information DayTradeStockInfo Fields") Return type : Object | Parameter | Type | Description | | --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | StockNo | \*string | Stock Symbol | | Date | \*string | Date | | DaytradeOrigQuota | \*int64 | Original Day Trade Short Quota | | DaytradeTradableQuota | \*int64 | Tradable Day Trade Short Quota | | PrecollectSingle | \*int64 | Single Pre-collect Share Count (Returns nil if not required) | | PrecollectAccumulate | \*int64 | Accumulated Pre-collect Share Count (Returns nil if not required) | | Status | \*int64 | Status (bitmask sum): `0` All Disabled, `1` Short selling allowed below flat, `2` SBL selling allowed below flat, `4` Day trade allowed (Buy then Sell), `8` Day trade allowed (Sell then Buy) | | DispositionStatus | \*string | Disposition Status `{ SETTYPE : 1}` : Full Delivery, `{ MARK-W : 1}` : Warning, `{ MARK-P : 1}` : Attention, `{ MARK-L : 1}` : Order Restricted | info Status Example Explanation: If Status = 15, it is the decomposition of 1 (Short selling allowed below flat) + 2 (SBL selling allowed below flat) + 4 (Day trade buy-sell) + 8 (Day trade sell-buy). If Status = 3, it is 1 + 2. Others follow the same logic. #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Day Trade Stock Info stockNo := "2330" daytradeStock, err := sdk.Stock.DaytradeAndStockInfo(account, stockNo) // Error handling if err != nil { fmt.Printf("❌ DayTrade Stock Info Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check success if !daytradeStock.IsSuccess { message := "No message" if daytradeStock.Message != nil { message = *daytradeStock.Message } fmt.Printf("DayTrade Stock Info failed. Message: %s\n", message) return } // Output quota information if daytradeStock.Data != nil { fmt.Println("✅ DayTrade Stock Info:") fmt.Printf("StockNo: %s\n", *daytradeStock.Data.StockNo) fmt.Printf("Date: %s\n", *daytradeStock.Data.Date) fmt.Printf("Original Day Trade Short Quota: %d\n", *daytradeStock.Data.DaytradeOrigQuota) fmt.Printf("Tradable Day Trade Short Quota: %d\n", *daytradeStock.Data.DaytradeTradableQuota) } else { fmt.Println("No DayTrade Stock Info data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // DaytradeAndStockInfo Return Structure Result{ IsSuccess: true, Message: nil, Data: &DayTradeStockInfo{ StockNo: "3264", // Stock Symbol Date: "2023/10/04", // Date DaytradeOrigQuota: 0, // Original Day Trade Short Quota DaytradeTradableQuota: 0, // Tradable Day Trade Short Quota PrecollectSingle: nil, // Single Pre-collect Share Count (Not required) PrecollectAccumulate: nil, // Accumulated Pre-collect Share Count (Not required) Status: 0, // Status (All Disabled) DispositionStatus: "", // Disposition Status }, } ``` --- ### Query Filled History FilledHistory #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | startDate | \*string | Query Start Date (Format: YYYYMMDD) | | endDate | \*string (Null default same as Start Date) | Query End Date (Format: YYYYMMDD) | info Maximum query range setting is 30 days per query. #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | --------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]FilledData | Returns filled list | | Message | \*string | Returns error message when IsSuccess = false | ##### Filled Information FilledData Fields[​](#filled-information-filleddata-fields "Direct link to Filled Information FilledData Fields") Return type : Object | Parameter | Type | Description | | -------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | Date | \*string | Filled Date | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | SeqNo | \*string | Order Sequence Number (Only returned for active reports) | | OrderNo | \*string | Order Number | | StockNo | \*string | Stock Symbol | | BuySell | BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | FilledNo | \*string | Fill Sequence Number | | FilledAvgPrice | \*string | Filled Average Price | | FilledQty | \*int64 | Filled Quantity | | FilledPrice | \*string | Filled Price | | OrderType | OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | FilledTime | \*string | Filled Time | | UserDef | \*string | User Defined Field (Only returned for active reports) | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Filled History startDate := "20250401" endDate := "20250501" filledHis, err := sdk.Stock.FilledHistory(account, &startDate, &endDate) // Error Handling if err != nil { fmt.Printf("❌ Filled History Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !filledHis.IsSuccess { message := "No message" if filledHis.Message != nil { message = *filledHis.Message } fmt.Printf("Filled history failed. Message: %s\n", message) return } // Output Filled History List if filledHis.Data != nil && len(*filledHis.Data) > 0 { fmt.Printf("✅ Found %d filled records\n", len(*filledHis.Data)) for i, filled := range *filledHis.Data { fmt.Printf("\n--- Filled %d ---\n", i+1) fmt.Printf("Date: %s\n", *filled.Date) fmt.Printf("OrderNo: %s\n", *filled.OrderNo) fmt.Printf("StockNo: %s\n", *filled.StockNo) fmt.Printf("BuySell: %v\n", filled.BuySell) fmt.Printf("FilledQty: %d\n", *filled.FilledQty) fmt.Printf("FilledPrice: %s\n", *filled.FilledPrice) fmt.Printf("FilledAvgPrice: %s\n", *filled.FilledAvgPrice) fmt.Printf("FilledTime: %s\n", *filled.FilledTime) fmt.Printf("OrderType: %v\n", filled.OrderType) if filled.UserDef != nil && *filled.UserDef != "" { fmt.Printf("UserDef: %s\n", *filled.UserDef) } } } else { fmt.Println("No filled data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // FilledHistory Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]FilledData{ { Date: "2025/04/29", // Filled Date BranchNo: "6460", // Branch Code Account: "26", // Account SeqNo: nil, // Order Sequence Number OrderNo: "bA422", // Order Number StockNo: "1101", // Stock Symbol BuySell: Sell, // Buy/Sell Action FilledNo: "00000000001", // Fill Sequence Number FilledAvgPrice: "35.2", // Filled Average Price FilledQty: 1000, // Filled Quantity FilledPrice: "35.2", // Filled Price OrderType: Stock, // Order Type FilledTime: "10:31:00.931", // Filled Time UserDef: nil, // User Defined }, // ... more filled records }, } ``` --- ### Get Order Results GetOrderResults #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns order list | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get Order Results ordResult, err := sdk.Stock.GetOrderResults(account) // Error Handling if err != nil { fmt.Printf("❌ Get Order Results Error: %v (Type: %T)\n", err, err) return } // Check Success if !ordResult.IsSuccess { message := "No message" if ordResult.Message != nil { message = *ordResult.Message } fmt.Printf("Get order result failed. Message: %s\n", message) return } // Output Order List if ordResult.Data != nil && len(*ordResult.Data) > 0 { fmt.Printf("✅ Found %d orders\n", len(*ordResult.Data)) for i, result := range *ordResult.Data { fmt.Printf("\n--- Order %d ---\n", i+1) fmt.Printf("OrderNo: %s\n", *result.OrderNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("BuySell: %v\n", *result.BuySell) fmt.Printf("Price: %s\n", *result.Price) fmt.Printf("Quantity: %d\n", *result.Quantity) fmt.Printf("Status: %d\n", *result.Status) fmt.Printf("FilledQty: %d\n", *result.FilledQty) fmt.Printf("AfterQty: %d\n", *result.AfterQty) } } else { fmt.Println("Order result success but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // OrderResults Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: nil, // Function Type Date: "2023/10/13", // Transaction Date SeqNo: "00000000002", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "bA614", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "9.0", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: Limit, // Effective Price Type AfterPrice: "9.0", // Effective Price Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "9.0", // Effective Price Before Change UserDef: "", // User Defined Field LastTime: "10:05:54.608", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, // ... more orders }, } ``` --- ### Get Order Results (With Changing Logs) GetOrderResultsDetail #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns order list (including changing logs) | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | ErrorMessage | \*string | Error Message | | Details | \*\[]OrderDetail | Order Changing Logs | | >> FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `50` Fully Filled, `90` Fail | | >> ModifiedTime | \*string | Modified Time | | >> BeforeQty | \*int64 | Original Order Quantity | | >> AfterQty | \*int64 | Effective Order Quantity (including filled part) | | >> BeforePrice | \*string | Original Order Price | | >> AfterPrice | \*string | Effective Order Price | | >> FilledMoney | \*string | Filled Amount | | >> Status | \*int64 | Order Status | | >> ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get Order Results (With Changing Logs) ordResultDetail, err := sdk.Stock.GetOrderResultsDetail(account) // Error Handling if err != nil { fmt.Printf("❌ Get Order Results Detail Error: %v (Type: %T)\n", err, err) return } // Check Success if !ordResultDetail.IsSuccess { message := "No message" if ordResultDetail.Message != nil { message = *ordResultDetail.Message } fmt.Printf("Get order result detail failed. Message: %s\n", message) return } // Output Order List and Changing Logs if ordResultDetail.Data != nil && len(*ordResultDetail.Data) > 0 { fmt.Printf("✅ Found %d orders with details\n", len(*ordResultDetail.Data)) for i, result := range *ordResultDetail.Data { fmt.Printf("\n=== Order %d ===\n", i+1) fmt.Printf("OrderNo: %s\n", *result.OrderNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("BuySell: %v\n", *result.BuySell) fmt.Printf("Price: %s\n", *result.Price) fmt.Printf("Quantity: %d\n", *result.Quantity) fmt.Printf("Status: %d\n", *result.Status) // Display Order Changing Logs if result.Details != nil && len(*result.Details) > 0 { fmt.Printf("\n Order Changing Logs (%d records):\n", len(*result.Details)) for j, detail := range *result.Details { fmt.Printf(" [%d] FunctionType: %d\n", j+1, *detail.FunctionType) fmt.Printf(" ModifiedTime: %s\n", *detail.ModifiedTime) fmt.Printf(" BeforeQty: %d -> AfterQty: %d\n", *detail.BeforeQty, *detail.AfterQty) fmt.Printf(" BeforePrice: %s -> AfterPrice: %s\n", *detail.BeforePrice, *detail.AfterPrice) fmt.Printf(" Status: %d\n", *detail.Status) } } else { fmt.Println(" No Order Changing Logs") } } } else { fmt.Println("Order result detail success but no data returned.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // OrderResultsDetail Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: nil, // Function Type Date: "2023/10/13", // Transaction Date SeqNo: "00000000002", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "bA614", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "9.0", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: Limit, // Effective Price Type AfterPrice: "9.0", // Effective Price Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "9.0", // Effective Price Before Change UserDef: "", // User Defined Field LastTime: "10:05:54.608", // Last Modified Time ErrorMessage: "", // Error Message Details: &[]OrderDetail{ // Order Changing Logs { FunctionType: 10, ModifiedTime: "10:05:54.608", BeforeQty: 0, AfterQty: 2000, BeforePrice: "9.0", AfterPrice: "9.0", Status: 10, ErrorMessage: "", }, }, }, // ... more orders }, } ``` --- ### Margin Quota Query MarginQuota #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | stockNo | string | Stock Symbol | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------------ | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*MarginShortQuota | Returns quota information | | Message | \*string | Returns error message when IsSuccess = false | ##### Quota Information MarginShortQuota Fields[​](#quota-information-marginshortquota-fields "Direct link to Quota Information MarginShortQuota Fields") Return type : Object | Parameter | Type | Description | | ---------------------- | -------- | ------------------------- | | StockNo | \*string | Stock Symbol | | Date | \*string | Date | | ShortsellOrigQuota | \*int64 | Original Short Sell Quota | | ShortsellTradableQuota | \*int64 | Tradable Short Sell Quota | | MarginOrigQuota | \*int64 | Original Margin Quota | | MarginTradableQuota | \*int64 | Tradable Margin Quota | | MarginRatio | \*int64 | Margin Ratio | | ShortRatio | \*int64 | Short Sell Ratio | info Quota Description: 0 - No quota / Greater than 0 - Has quota / nil - Unlimited #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Margin Quota stockNo := "2330" marginQuo, err := sdk.Stock.MarginQuota(account, stockNo) // Error handling if err != nil { fmt.Printf("❌ Margin Quota Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check success if !marginQuo.IsSuccess { message := "No message" if marginQuo.Message != nil { message = *marginQuo.Message } fmt.Printf("Margin Quota failed. Message: %s\n", message) return } // Output quota information if marginQuo.Data != nil { fmt.Println("✅ Margin/Short Quota:") fmt.Printf("StockNo: %s\n", *marginQuo.Data.StockNo) fmt.Printf("Date: %s\n", *marginQuo.Data.Date) } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // MarginQuota Return Structure Result{ IsSuccess: true, Message: nil, Data: &MarginShortQuota{ StockNo: "2330", // Stock Symbol Date: "2024/01/24", // Date ShortsellOrigQuota: 894, // Original Short Sell Quota ShortsellTradableQuota: 894, // Tradable Short Sell Quota MarginOrigQuota: nil, // Original Margin Quota (Unlimited) MarginTradableQuota: nil, // Tradable Margin Quota (Unlimited) MarginRatio: 60, // Margin Ratio 60% ShortRatio: 90, // Short Sell Ratio 90% }, } ``` --- ### Modify Order Price ModifyPrice ##### First use MakeModifyPriceObj to create a ModifyPriceObj object[​](#first-use-makemodifypriceobj-to-create-a-modifypriceobj-object "Direct link to First use MakeModifyPriceObj to create a ModifyPriceObj object") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | ------------------------ | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#orderresult) | The order to be modified | | price | \*string | The modified price | | priceType | \*PriceType | The modified price flag | caution When the `price` field has a value, `priceType` must be `nil`. When `priceType` has a value, `price` must be `nil`. Pass the returned object into the ModifyPrice method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | -------------- | --------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | modifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#modifypriceobj) | Price modification object | | unblock | \*bool (optional) (default = false) | Whether to use non-blocking | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*OrderResult | Returns order information | | Message | \*string | Returns error message when IsSuccess = false | ##### Modification Information OrderResult Fields[​](#modification-information-orderresult-fields "Direct link to Modification Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get the order to modify first ordResult, err := sdk.Stock.GetOrderResults(account) if err != nil { fmt.Printf("❌ Get Order Results Format/Parse Error: %v\n", err) return } var modifyOrder fubon.OrderResult if ordResult.Data != nil && len(*ordResult.Data) > 0 { modifyOrder = (*ordResult.Data)[0] fmt.Println("Selected order for price modification") fmt.Printf("OrderNo: %s, Current Price: %s\n", *modifyOrder.OrderNo, *modifyOrder.Price) // Create Modify Price Object newPrice := "41.1" modifyPriceObj, err := sdk.Stock.MakeModifyPriceObj(modifyOrder, &newPrice, nil) if err != nil { fmt.Printf("❌ Make Modify Price Format/Parse Error: %v (Type: %T)\n", err, err) return } // Execute Modify Price unblock := false modifyPriceRes, err := sdk.Stock.ModifyPrice(account, modifyPriceObj, &unblock) if err != nil { fmt.Printf("❌ Modify Price Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !modifyPriceRes.IsSuccess { message := "No message" if modifyPriceRes.Message != nil { message = *modifyPriceRes.Message } fmt.Printf("Modify Price failed. Message: %s\n", message) return } // Output Modification Result if modifyPriceRes.Data != nil { fmt.Println("✅ Price modified successfully!") fmt.Printf("BeforePrice: %s -> AfterPrice: %s\n", *modifyPriceRes.Data.BeforePrice, *modifyPriceRes.Data.AfterPrice) } else { fmt.Println("Modify Price succeeded but no data returned.") } } else { fmt.Println("⚠️ No orders found for price modification") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // ModifyPrice Return Structure Result{ IsSuccess: true, Message: nil, Data: &OrderResult{ FunctionType: 15, // Function Type (15=Change Price) Date: "2023/11/22", // Transaction Date SeqNo: "00000308866", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "x0011", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: MarketTypeCommon, // Market Type Category StockNo: "1101", // Stock Symbol BuySell: BsActionSell, // Buy/Sell Action PriceType: PriceTypeLimit, // Original Price Type Price: "41.2", // Price Quantity: 5000, // Original Order Quantity TimeInForce: TimeInForceRod, // Order Condition OrderType: OrderTypeStock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: PriceTypeLimit, // Effective Price Type AfterPrice: "41.1", // Effective Price (After modification) Unit: 1000, // Unit AfterQty: 2000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: nil, // Effective Qty Before Change BeforePrice: "41.3", // Effective Price Before Change UserDef: "12345678", // User Defined Field LastTime: "10:56:57.713", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, } ``` --- ### Modify Order Quantity ModifyQuantity ##### First use MakeModifyQuantityObj to create a ModifyQuantityObj object[​](#first-use-makemodifyquantityobj-to-create-a-modifyquantityobj-object "Direct link to First use MakeModifyQuantityObj to create a ModifyQuantityObj object") | Parameter | Type | Description | | ----------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#orderresult) | The order to be modified | | quantity | int64 | The modified quantity (Quantity after modification includes the filled part of this order) | Pass the returned object into the ModifyQuantity method. #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ----------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | modifyQuantityObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#modifyquantityobj) | Order to modify | | unblock | \*bool (optional) (default = false) | Whether to use non-blocking | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*OrderResult | Returns order information | | Message | \*string | Returns error message when IsSuccess = false | ##### Modification Information OrderResult Fields[​](#modification-information-orderresult-fields "Direct link to Modification Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Get the order to modify first ordResult, err := sdk.Stock.OrderResults(account) if err != nil { fmt.Printf("❌ Get Order Results Format/Parse Error: %v\n", err) return } var modifyOrder fubon.OrderResult if ordResult.Data != nil && len(*ordResult.Data) > 0 { modifyOrder = (*ordResult.Data)[0] fmt.Println("Selected order for quantity modification") fmt.Printf("OrderNo: %s, Current Quantity: %d\n", *modifyOrder.OrderNo, *modifyOrder.AfterQty) // Create Modify Quantity Object (Can only reduce quantity) newQuantity := int64(1000) modifyQtyObj, err := sdk.Stock.MakeModifyQuantityObj(modifyOrder, newQuantity) if err != nil { fmt.Printf("❌ Make Modify Quantity Format/Parse Error: %v (Type: %T)\n", err, err) return } // Execute Modify Quantity unblock := false modifyQtyRes, err := sdk.Stock.ModifyQuantity(account, modifyQtyObj, &unblock) if err != nil { fmt.Printf("❌ Modify Quantity Format/Parse Error: %v (Type: %T)\n", err, err) return } // Check Success if !modifyQtyRes.IsSuccess { message := "No message" if modifyQtyRes.Message != nil { message = *modifyQtyRes.Message } fmt.Printf("Modify Quantity failed. Message: %s\n", message) return } // Output Modification Result if modifyQtyRes.Data != nil { fmt.Println("✅ Quantity modified successfully!") fmt.Printf("FunctionType: %d (20=Change Qty)\n", *modifyQtyRes.Data.FunctionType) fmt.Printf("BeforeQty: %d -> AfterQty: %d\n", *modifyQtyRes.Data.BeforeQty, *modifyQtyRes.Data.AfterQty) } else { fmt.Println("Modify Quantity succeeded but no data returned.") } } else { fmt.Println("⚠️ No orders found for quantity modification") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // ModifyQuantity Return Structure Result{ IsSuccess: true, Message: nil, Data: &OrderResult{ FunctionType: 20, // Function Type (20=Change Qty) Date: "2024/03/08", // Transaction Date SeqNo: "00000308866", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "x0011", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "1101", // Stock Symbol BuySell: Sell, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "41.2", // Price Quantity: 5000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: Limit, // Effective Price Type AfterPrice: "41.3", // Effective Order Price Unit: 1000, // Unit AfterQty: 1000, // Effective Order Quantity (After modification) FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 3000, // Effective Qty Before Change BeforePrice: "41.2", // Effective Price Before Change UserDef: "12345678", // User Defined Field LastTime: "12:56:28.966", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, } ``` --- ### Query Order History OrderHistory #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | ----------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | startDate | string | Query Start Date (Format: YYYYMMDD) | | endDate | \*string (Null default same as Start Date) | Query End Date (Format: YYYYMMDD) | info Maximum query range setting is 30 days per query. #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------- | --------------------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*\[]OrderResult | Returns historical order list (including history details) | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | ErrorMessage | \*string | Error Message | | Details | \*\[]OrderDetail | Order History | | >> FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `50` Fully Filled, `90` Fail | | >> ModifiedTime | \*string | Modified Time | | >> BeforeQty | \*int64 | Original Order Quantity | | >> AfterQty | \*int64 | Effective Order Quantity (including filled part) | | >> BeforePrice | \*string | Original Order Price | | >> AfterPrice | \*string | Effective Order Price | | >> FilledMoney | \*string | Filled Amount | | >> Status | \*int64 | Order Status | | >> ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK and login sdk := fubon.NewSDK() // ... Login, connection, and other initialization steps ... // Query Order History startDate := "20250502" endDate := "20250502" orderHis, err := sdk.Stock.OrderHistory(account, startDate, &endDate) // Error Handling if err != nil { fmt.Printf("❌ Order History Format/Parse Error:: %v (Type: %T)\n", err, err) return } // Check Success if !orderHis.IsSuccess { message := "No message" if orderHis.Message != nil { message = *orderHis.Message } fmt.Printf("Order history failed. Message: %s\n", message) return } // Output Order History List if orderHis.Data != nil && len(*orderHis.Data) > 0 { fmt.Printf("✅ Found %d historical orders\n", len(*orderHis.Data)) for i, result := range *orderHis.Data { fmt.Printf("\n=== Historical Order %d ===\n", i+1) fmt.Printf("Date: %s\n", *result.Date) fmt.Printf("OrderNo: %s\n", *result.OrderNo) fmt.Printf("StockNo: %s\n", *result.StockNo) fmt.Printf("BuySell: %v\n", *result.BuySell) fmt.Printf("Price: %s\n", *result.Price) fmt.Printf("Quantity: %d\n", *result.Quantity) fmt.Printf("Status: %d\n", *result.Status) fmt.Printf("FilledQty: %d\n", *result.FilledQty) // Display Order History Details if result.Details != nil && len(*result.Details) > 0 { fmt.Printf("\n Order Details (%d records):\n", len(*result.Details)) for j, detail := range *result.Details { fmt.Printf(" [%d] FunctionType: %d, Time: %s\n", j+1, *detail.FunctionType, *detail.ModifiedTime) fmt.Printf(" Qty: %d -> %d, Price: %s -> %s\n", *detail.BeforeQty, *detail.AfterQty, *detail.BeforePrice, *detail.AfterPrice) } } } } else { fmt.Println("No order history data.") } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // OrderHistory Return Structure Result{ IsSuccess: true, Message: nil, Data: &[]OrderResult{ { FunctionType: nil, // Function Type Date: "2025/05/02", // Transaction Date SeqNo: "00000000001", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "bA598", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: Common, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: Buy, // Buy/Sell Action PriceType: Limit, // Original Price Type Price: "8.9", // Price Quantity: 2000, // Original Order Quantity TimeInForce: Rod, // Order Condition OrderType: Stock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: nil, // Effective Price Type AfterPrice: "9", // Effective Price Unit: 1000, // Unit AfterQty: 1000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: nil, // Effective Qty Before Change BeforePrice: nil, // Effective Price Before Change UserDef: "", // User Defined Field LastTime: "14:19:41.879", // Last Modified Time ErrorMessage: "", // Error Message Details: &[]OrderDetail{ // Order History { FunctionType: 10, ModifiedTime: "14:19:41.879", BeforeQty: 0, AfterQty: 1000, BeforePrice: "9.0", AfterPrice: "9.0", Status: 10, ErrorMessage: "", }, }, }, // ... more historical orders }, } ``` --- ### Place Order PlaceOrder #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | --------- | ------------------------------------------------------------------------------------------- | --------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#account) | Account | | order | [Order](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/go/EnumMatrix.md#order) | Order Content | | unblock | \*bool (optional) (default = false) | Whether to use non-blocking | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ------------- | -------------------------------------------- | | IsSuccess | bool | Whether successful | | Data | \*OrderResult | Returns order information | | Message | \*string | Returns error message when IsSuccess = false | ##### Order Information OrderResult Fields[​](#order-information-orderresult-fields "Direct link to Order Information OrderResult Fields") Return type : Object | Parameter | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | FunctionType | \*int64 | Function Type: `0` New Order, `10` Execute New Order, `15` Change Price, `20` Change Qty, `30` Cancel Order, `90` Fail | | Date | \*string | Transaction Date | | SeqNo | \*string | Order Sequence Number | | BranchNo | \*string | Branch Code | | Account | \*string | Account | | OrderNo | \*string | Order Number | | AssetType | \*int64 | Asset Type: `0` Securities | | Market | \*string | Market: `TAIEX` Listed Stocks, `TAISDAQ` OTC Stocks, `TAIEMG` Emerging Stocks | | MarketType | MarketType | Market Type Category: `MarketTypeCommon` Regular Stock, `MarketTypeFixing` Fixing, `MarketTypeIntradayOdd` Intraday Odd Lot, `MarketTypeOdd` Post-market Odd Lot, `MarketTypeEmg` Emerging, `MarketTypeEmgOdd` Emerging Odd Lot | | StockNo | \*string | Stock Symbol | | BuySell | \*BsAction | Buy/Sell Action: `BsActionBuy` Buy, `BsActionSell` Sell | | PriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | Price | \*string | Price | | Quantity | \*int64 | Original Order Quantity | | TimeInForce | \*TimeInForce | Order Condition: `TimeInForceRod` ROD, `TimeInForceFok` FOK, `TimeInForceIoc` IOC | | OrderType | \*OrderType | Order Type: `OrderTypeStock` Common, `OrderTypeMargin` Margin, `OrderTypeShort` Short Sell, `OrderTypeDayTrade` Day Trade, `OrderTypeSbl` SBL | | IsPreOrder | \*bool | Is Pre-order | | Status | \*int64 | Order Status: `0` Pre-order, `4` Sending to Backend, `9` Connection Timeout, `10` Order Success, `30` Cancelled Unfilled, `40` Partial Fill/Rest Cancelled, `50` Fully Filled, `90` Fail | | AfterPriceType | \*PriceType | Effective Price Type: `PriceTypeLimit` Limit, `PriceTypeLimitUp` Limit Up, `PriceTypeLimitDown` Limit Down, `PriceTypeMarket` Market, `PriceTypeReference` Reference | | AfterPrice | \*string | Effective Order Price | | Unit | \*int64 | Unit | | AfterQty | \*int64 | Effective Order Quantity (including filled part) | | FilledQty | \*int64 | Filled Quantity | | FilledMoney | \*int64 | Filled Amount | | BeforeQty | \*int64 | Effective Qty Before Change | | BeforePrice | \*string | Effective Price Before Change | | UserDef | \*string | User Defined Field | | LastTime | \*string | Last Modified Time | | Details | \*string | Order History (Value exists only when querying OrderResultDetail or OrderHistory) | | ErrorMessage | \*string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```go package main import ( "fmt" "fubon" ) func main() { // Initialize SDK sdk := fubon.NewSDK() orderPrice := "66.1" order := fubon.Order{ BuySell: fubon.BsActionBuy, Symbol: "2881", Price: &orderPrice, Quantity: 1000, MarketType: fubon.MarketTypeCommon, PriceType: fubon.PriceTypeLimit, TimeInForce: fubon.TimeInForceRod, OrderType: fubon.OrderTypeStock, } unblock := false result, err := sdk.Stock.PlaceOrder(account, order, &unblock) if err != nil { fmt.Printf("❌ Place Order Format/Parse Error: %v (Type: %T)\n", err, err) } else { fmt.Printf("✓ Order Placed", *result.IsSuccess) } } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go // OrderResult Structure Result{ IsSuccess: true, Message: nil, Data: &OrderResult{ FunctionType: 0, // Function Type Date: "2023/10/13", // Transaction Date SeqNo: "00000000007", // Order Sequence Number BranchNo: "6460", // Branch Code Account: "26", // Account OrderNo: "bA619", // Order Number AssetType: 0, // Asset Type Market: "TAIEX", // Market Type MarketType: MarketTypeCommon, // Market Type Category StockNo: "2888", // Stock Symbol BuySell: BsActionBuy, // Buy/Sell Action PriceType: PriceTypeLimit, // Original Price Type Price: "9.1", // Price Quantity: 3000, // Original Order Quantity TimeInForce: TimeInForceRod, // Order Condition OrderType: OrderTypeStock, // Order Type IsPreOrder: false, // Is Pre-order Status: 10, // Order Status AfterPriceType: PriceTypeLimit, // Effective Price Type AfterPrice: "9.1", // Effective Order Price Unit: 1000, // Unit AfterQty: 3000, // Effective Order Quantity FilledQty: 0, // Filled Quantity FilledMoney: 0, // Filled Amount BeforeQty: 0, // Effective Qty Before Change BeforePrice: "9.1", // Effective Price Before Change UserDef: "", // User Defined Field LastTime: "12:10:12.546", // Last Modified Time Details: nil, // Order History ErrorMessage: "", // Error Message }, } ``` --- ### Query Symbol Quote (Single) query\_symbol\_quote #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | symbol | String | Stock Symbol | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market Type: Supports `Common` (Regular Stock), `IntradayOdd` (Intraday Odd Lot), `Fixing` (Fixing) | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ----------- | -------------------------------------------- | | isSuccess | bool | Whether successful | | data | SymbolQuote | Returns quote information | | message | string | Returns error message when isSuccess : false | ##### Symbol Information SymbolQuote Fields[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information SymbolQuote Fields") Return type : Object | Parameter | Type | Description | | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Market | \*string | Market | | Symbol | \*string | Stock Symbol | | IsTibOrPsb | \*bool | Whether it is TIB (Taiwan Innovation Board) or PSB (Pioneer Stock Board) | | MarketType | \*string | Market Type | | Status | \*int64 | Status (bitmask sum): `0`: All Disabled, `1`: Short selling allowed below flat, `2`: SBL selling allowed below flat, `4`: Day trade allowed (Buy then Sell), `8`: Day trade allowed (Sell then Buy) | | ReferencePrice | \*string | Reference Price | | Unit | \*int64 | Trading Unit | | UpdateTime | \*string | Update Time | | LimitupPrice | \*string | Limit Up Price | | LimitdownPrice | \*string | Limit Down Price | | OpenPrice | \*string | Open Price | | HighPrice | \*string | High Price | | LowPrice | \*string | Low Price | | LastPrice | \*string | Last Price | | TotalVolume | \*int64 | Total Volume | | TotalTransaction | \*int64 | Total Transactions | | TotalValue | \*string | Total Value | | LastSize | \*int64 | Last Size | | LastTransaction | \*int64 | Last Transaction Count | | LastValue | \*string | Last Value | | BidPrice | \*string | Bid 1 Price | | BidVolume | \*int64 | Bid 1 Volume | | AskPrice | \*string | Ask 1 Price | | AskVolume | \*int64 | Ask 1 Volume | Supported Scope Listed and OTC securities info Status Example Explanation: If Status = 15, it is the decomposition of 1 (Short selling allowed below flat) + 2 (SBL selling allowed below flat) + 4 (Day trade buy-sell) + 8 (Day trade sell-buy). If Status = 3, it is 1 + 2. Others follow the same logic. #### Request Example[​](#request-example "Direct link to Request Example") ```go quote, err := sdk.Stock.QuerySymbolQuote(account, "2330", nil) if err != nil { fmt.Printf("❌ Quote Format/Parse Error: %v (Type: %T)\n", err, err) } else { s, _ := json.MarshalIndent(quote, "", " ") fmt.Println("Quote Data ", string(s)) } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go { isSuccess : true, message : , data : SymbolQuote{ market : TAIEX, // string - Market symbol : 2330, // string - Stock Symbol istibOrPsb : false, // bool - Whether TIB or PSB marketType : Common, // string - Market Type (Common Stock) status : 15, // int - Status (bitmask sum: 1+2+4+8 : Short sell + SBL sell + Day trade buy-sell + Day trade sell-buy) referencePrice : 780, // double - Reference Price (Previous close) unit : 1000, // int - Trading Unit updateTime : , // string - Update Time limitupPrice : 858, // double - Limit Up Price limitdownPrice : 702, // double - Limit Down Price openPrice : 1155, // double - Open Price highPrice : 1160, // double - High Price lowPrice : 1145, // double - Low Price lastPrice : 1145, // double - Last Price totalVolume : 20501, // int - Total Volume totalTransaction : 0, // int - Total Transactions totalValue : 23551095000, // int - Total Value lastSize : 6673, // int - Last Size lastTransaction : 0, // int - Last Transaction Count lastValue : 7640585000, // int - Last Value bidPrice : 1145, // double - Bid 1 Price bidVolume : 1549, // int - Bid 1 Volume askPrice : 1150, // double - Ask 1 Price askVolume : 4169 // int - Ask 1 Volume } } ``` --- ### Query Symbol Snapshot (Batch) query\_symbol\_snapshot #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#account) | Account | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#markettype) (Optional)(default = Common) | Market Type: Supports `Common` (Regular Stock), `IntradayOdd` (Intraday Odd Lot), `Fixing` (Fixing) | | stock\_type | List [StockType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/cpp/EnumMatrix.md#stocktype) (Optional)(default = Stock) | Stock Category: `Stock` (Stocks), `ConvertBond` (Convertible Bonds), `ETF_and_ETN` (ETF and ETN) | #### Result Return[​](#result-return "Direct link to Result Return") | Parameter | Type | Description | | --------- | ---------------------- | -------------------------------------------- | | isSuccess | bool | Whether successful | | data | SymbolSnapshotResponse | Returns quote information | | message | string | Returns error message when isSuccess : false | ##### Symbol Information SymbolQuote Fields[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information SymbolQuote Fields") Return type : Object | Parameter | Type | Description | | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Market | \*string | Market | | Symbol | \*string | Stock Symbol | | IsTibOrPsb | \*bool | Whether it is TIB (Taiwan Innovation Board) or PSB (Pioneer Stock Board) | | MarketType | \*string | Market Type | | Status | \*int64 | Status (bitmask sum): `0`: All Disabled, `1`: Short selling allowed below flat, `2`: SBL selling allowed below flat, `4`: Day trade allowed (Buy then Sell), `8`: Day trade allowed (Sell then Buy) | | ReferencePrice | \*string | Reference Price | | Unit | \*int64 | Trading Unit | | UpdateTime | \*string | Update Time | | LimitupPrice | \*string | Limit Up Price | | LimitdownPrice | \*string | Limit Down Price | | OpenPrice | \*string | Open Price | | HighPrice | \*string | High Price | | LowPrice | \*string | Low Price | | LastPrice | \*string | Last Price | | TotalVolume | \*int64 | Total Volume | | TotalTransaction | \*int64 | Total Transactions | | TotalValue | \*string | Total Value | | LastSize | \*int64 | Last Size | | LastTransaction | \*int64 | Last Transaction Count | | LastValue | \*string | Last Value | | BidPrice | \*string | Bid 1 Price | | BidVolume | \*int64 | Bid 1 Volume | | AskPrice | \*string | Ask 1 Price | | AskVolume | \*int64 | Ask 1 Volume | Supported Scope Listed and OTC securities info Status Example Explanation: If Status = 15, it is the decomposition of 1 (Short selling allowed below flat) + 2 (SBL selling allowed below flat) + 4 (Day trade buy-sell) + 8 (Day trade sell-buy). If Status = 3, it is 1 + 2. Others follow the same logic. #### Request Example[​](#request-example "Direct link to Request Example") ```go snaps, err := sdk.Stock.QuerySymbolSnapshot(account, nil, nil) if err != nil { fmt.Printf("❌ Quote Format/Parse Error: %v (Type: %T)\n", err, err) } else { s, _ := json.MarshalIndent(snaps, "", " ") fmt.Println("Quote Data ", string(s)) } ``` #### Response Example[​](#response-example "Direct link to Response Example") ```go { isSuccess : true, message : , data : SymbolQuote{ market : TAIEX, // string - Market symbol : 2330, // string - Stock Symbol istibOrPsb : false, // bool - Whether TIB or PSB marketType : Common, // string - Market Type (Common Stock) status : 15, // int - Status (bitmask sum: 1+2+4+8 : Short sell + SBL sell + Day trade buy-sell + Day trade sell-buy) referencePrice : 780, // double - Reference Price (Previous close) unit : 1000, // int - Trading Unit updateTime : , // string - Update Time limitupPrice : 858, // double - Limit Up Price limitdownPrice : 702, // double - Limit Down Price openPrice : 1155, // double - Open Price highPrice : 1160, // double - High Price lowPrice : 1145, // double - Low Price lastPrice : 1145, // double - Last Price totalVolume : 20501, // int - Total Volume totalTransaction : 0, // int - Total Transactions totalValue : 23551095000, // int - Total Value lastSize : 6673, // int - Last Size lastTransaction : 0, // int - Last Transaction Count lastValue : 7640585000, // int - Last Value bidPrice : 1145, // double - Bid 1 Price bidVolume : 1549, // int - Bid 1 Volume askPrice : 1150, // double - Ask 1 Price askVolume : 4169 // int - Ask 1 Volume }, { market : TAIEX, // string - Market symbol : 2330, // string - Stock Symbol ... } } ``` --- ### Query bank remains bankRemain #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | BankRemain list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### BankRemain Parameter[​](#bankremain-parameter "Direct link to BankRemain Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ------ | ----------------- | | branchNo | string | Branch Number | | account | string | Account | | currency | string | Currency | | balance | int | Balance | | availableBalance | int | Available Balance | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.bankRemain(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { isSuccess: true, data:{ branch_no: "6460", // Branch Number (string) account: "26", // Account (string) currency: "TWD", // Currency (string) balance: 666666, // Balance (int) available_balance: 123456 // Available Balance (int) } } ``` --- ### Inventories inventories ##### Reqeust Parameter[​](#reqeust-parameter "Direct link to Reqeust Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Inventory list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Inventory Parameter[​](#inventory-parameter "Direct link to Inventory Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | > date | string | Query date(Today) | | > account | string | Account | | > branchNo | string | Branch number | | > stockNo | string | Symbol | | > orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | > lastdayQty | number | Yesterday Share balacne | | > buyQty | number | Total volume purchased today | | > buyFilledQty | number | Total purchased filled today | | > buyValue | number | Total value purchased today | | > todayQty | number | Today share balacne | | > tradableQty | number | Available quantity | | > sellQty | number | Total volume sell today | | > sellFilledQty | number | Total sell filled today | | > sellValue | number | Total value sell today | | > odd | InventoryOdd | Object | | >> lastdayQty | nuber | Yesterday odd lot balacne | | >> buyQty | number | Total volume purchased today | | >> buyFilledQty | number | Total purchased filled today | | >> buyValue | number | Total value purchased today | | >> todayQty | number | Today odd lot balacne | | >> tradableQty | number | Available quantity | | >> sellQty | number | Total volume sell today | | >> sellFilledQty | number | Total sell filled today | | >> sellValue | number | Total value sell today | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.inventories(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/10/05', // Query date (Today) (string) account: '26', // Account (string) branchNo: '6460', // Branch number (string) stockNo: '1101', // Symbol (string) orderType: 'Stock', // Order Type (string) lastdayQty: 2000, // Yesterday Share balance (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total value purchased today (number) todayQty: 2000, // Today share balance (number) tradableQty: 2000, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0, // Total value sell today (number) odd: { lastdayQty: 0, // Yesterday odd lot balance (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total value purchased today (number) todayQty: 0, // Today odd lot balance (number) tradableQty: 0, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0 // Total value sell today (number) } }, { date: '2023/10/05', // Query date (Today) (string) account: '26', // Account (string) branchNo: '6460', // Branch number (string) stockNo: '1101', // Symbol (string) orderType: 'Margin', // Order Type (string) lastdayQty: 8000, // Yesterday Share balance (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total value purchased today (number) todayQty: 8000, // Today share balance (number) tradableQty: 8000, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0, // Total value sell today (number) odd: { lastdayQty: 0, // Yesterday odd lot balance (number) buyQty: 0, // Total volume purchased today (number) buyFilledQty: 0, // Total purchased filled today (number) buyValue: 0, // Total value purchased today (number) todayQty: 0, // Today odd lot balance (number) tradableQty: 0, // Available quantity (number) sellQty: 0, // Total volume sell today (number) sellFilledQty: 0, // Total sell filled today (number) sellValue: 0 // Total value sell today (number) } }, ... ] } ``` --- ### Maintenance maintenance #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | MaintenanceData list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### MaintenanceData Parameter[​](#maintenancedata-parameter "Direct link to MaintenanceData Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | > date | string | Query Date | | > branchNo | string | Branch Number | | > account | string | Account | | > maintenanceSummary | list | Object | | >> marginValue | number | Total Margin Value | | >> shortsellValue | number | Total Short Sell Value | | >> shortsellMargin | number | Total Short sell Margin Amount | | >> collateral | number | Collateral | | >> marginLoanAmt | number | Total Margin Loan Amount | | >> maintenanceRatio | number | Account Maintenance Ratio | | > MaintenanceDetail | list | Object | | >> stockNo | string | Symbol | | >> orderNo | string | Order Number | | >> orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | >> quantity | number | Hoding Share | | >> price | number | Calculated Price | | >> costPrice | number | Cost Price | | >> shortsellMargin | number | Short Sell Margin | | >> collateral | number | Collateral | | >> marginLoanAmt | number | Margin Loan Amount | | >> maintenanceRatio | number | Maintenance Ratio | | >> collateralInterest | number | Collateral Interest | | >> marginInterest | number | Margin Interest | | >> shortsellInterest | number | Short Sell Interest | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.maintenance(target_user); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: { date: '2024/02/27', // Query Date (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) maintenanceSummary: { marginValue: 1015000, // Total Margin Value (number) shortsellValue: 99750, // Total Short Sell Value (number) shortsellMargin: 154000, // Total Short Sell Margin Amount (number) collateral: 154300, // Collateral (number) marginLoanAmt: 723000, // Total Margin Loan Amount (number) maintenanceRatio: 160.8387, // Account Maintenance Ratio (number) }, maintenanceDetail: [ { stockNo: '2303', // Symbol (string) orderNo: 'x4580', // Order Number (string) orderType: 'Stock', // Order Type (string) quantity: 10000, // Holding Share (number) price: 152.5, // Calculated Price (number) costPrice: 119, // Cost Price (number) shortsellMargin: 0, // Short Sell Margin (number) collateral: 0, // Collateral (number) marginLoanAmt: 0, // Margin Loan Amount (number) maintenanceRatio: 213.58, // Maintenance Ratio (number) collateralInterest: 0, // Collateral Interest (number) marginInterest: 20818, // Margin Interest shortsellInterest: 0 // Short Sell Interest }, ... ] } } ``` --- ### Query Settlemet querySettlement #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | range | string | Query range, currently valid values are "0d" (today) and "3d". | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Settlement list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### SettlementData Parameter[​](#settlementdata-parameter "Direct link to SettlementData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | ------- | --------------------------------- | | > AccountRes | list | Object | | >> account | string | Account | | >> branchNo | string | Branch number | | > details | list | Object | | >> date | string | Query Date | | >> settlementDate | string? | Settlement Date | | >> buyValue | int? | Buying Value | | >> buyFee | int? | Buying Fee | | >> buySettlement | int? | Buying Payable / Received Amount | | >> buyTax | int? | Buying Tax | | >> sellValue | int? | Selling Value | | >> sellFee | int? | Selling Fee | | >> sellSettlement | int? | Selling Payable / Received Amount | | >> sellTax | int? | Selling Tax | | >> totalBsValue | int? | Total Buying & Selling Value | | >> totalFee | int? | Total Fee | | >> totalTax | int? | Total Tax | | >> totalSettlementAmount | int? | Total Payable & Received Amount | | >> currency | string? | Currency | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.querySettlement(target_user,"3d"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ account: { branchNo: '6460', account: '26' }, details:[ { date: "2024/03/04", settlementDate: "2024/03/06", buyValue: 735500, buyFee: 313, buySettlement: -1429513, buyTax: 0, sellValue: 770500, sellFee: 320, sellSettlement: 0, sellTax: 2309, totalBsValue: 1506000, totalFee: 633, totalSettlementAmount: -1429513, totalTax: 2309, currency: "TWD" }, { date: "2024/03/05", settlementDate: "2024/03/07", buyValue: 2261470, buyFee: 1065, buySettlement: -3895335, buyTax: 0, sellValue: 2488170, sellFee: 1137, sellSettlement: 677626, sellTax: 7412, totalBsValue: 4749640, totalFee: 2202, totalSettlementAmount: -3217709, totalTax: 7412, currency: "TWD" }, { date: "2024/03/06" } ] } } ``` --- ### Realized Gains and Loses(Detail) realizedGainsAndLoses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Realized list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Realized Parameter[​](#realized-parameter "Direct link to Realized Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | date | string | Data date | | branchNo | string | Branch number | | account | string | Account | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | filledQty | number | Filled Quantity | | filledPrice | number | Filled Price | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` Security Landing | | realizedProfit | number | Realized profit | | realizedLoss | number | Realized loss | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.realizedGainsAndLoses(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/08/29', // Data date (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) filledQty: 1000, // Filled Quantity (number) filledPrice: 35.3, // Filled Price (number) orderType: 0, // Order Type (number) realizedProfit: 0, // Realized profit (number) realizedLoss: 906 // Realized loss (number) }, ... ] } ``` --- ### Realized Gains and Loses Summary realizedGainsAndLosesSummary #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | RealizedSummary list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### RealizedSummary Parameter[​](#realizedsummary-parameter "Direct link to RealizedSummary Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | startDate | string | Query Start Date | | endDate | string | Query End Date | | branchNo | string | Branch Number | | account | string | Account | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` Security Landing | | filledQty | number | Filled Quantity | | filledAvgPrice | number | Filled Average Price | | realizedProfitAndLoss | number | Realized Profit and Loss | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.RealizedGainsAndLosesSummary(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { startDate: '20230808', // Query Start Date (string) endDate: '20230830', // Query End Date (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) orderType: 0, // Order Type (number) filledQty: 3000, // Filled Quantity (number) filledAvgPrice: 35.7, // Filled Average Price (number) realizedProfitAndLoss: 34026 // Realized Profit and Loss (number) }, ... ] } ``` --- ### Unrealized Gains and Loses unrealizedGainsAndLoses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | UnrealizedData list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### UnrealizedData Parameter[​](#unrealizeddata-parameter "Direct link to UnrealizedData Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | date | string | Date of inquiry | | account | string | Account | | branchNo | string | Branch number | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` (**Note**. Please refer to the infomation block below the table) | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` Security Landing | | costPrice | number | Holding cost | | tradableQty | number | Available quantity | | todayQty | number | Today Share balacne | | unrealizedProfit | number | Unrealized profit | | unrealizedLoss | number | Unrealized loss | info For spot trades, buySell is always `Buy` and quantity could be positive or negative to denote the net position. For margin trades,buySell could be `Buy` or `Sell` depends on the trade direction. #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.accounting.unrealizedGainsAndLoses(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2021/08/09', // Date of inquiry (string) account: '26', // Account (string) branchNo: '6460', // Branch number (string) stockNo: '2303', // Symbol (string) buySell: 'Buy', // Buy / Sell Type (string) orderType: 'Margin', // Order Type (string) costPrice: 50, // Holding cost (number) tradableQty: 1000, // Available quantity (number) todayQty: 1000, // todayQty (number) unrealizedProfit: 47000, // Unrealized profit (number) unrealizedLoss: 0 // Unrealized loss (number) }, ... ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | ------------------ | ----------- | -------------------------------------------------------------------------------------------------- | | buySell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price (use ***null*** if priceType is not `Limit`) | | quantity | int | Order Quantity | | marketType | MarketType | [Trading Session](#markettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd`、`Emg` 、`EmgOdd` | | priceType | PriceType | [Price Type](#pricetype) valid in `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | orderType | OrderType | [Order Type](#ordertype) valid in `Stock`、`Margin`、`Short`、`DayTrade`、`SBL` | | userDef (optional) | string | Customer Field (Up to 10 characters, no special characters supported 、 Not applicable to Emg) | caution The units and ranges for 'quantity' vary for different MarketTypes. Please refer to the [MarketType](#markettype) description for details caution When marketType is one of MarketType.Common, MarketType.Odd, MarketType.IntradayOdd, MarketType.Emg, and priceType is PriceType.Limit, the 'price' field must be filled; otherwise, the 'price' field should be empty or null Spot Short Selling When spot short selling common stocks, orderType should be DayTrade, buySell is Sell, and marketType is Commonn
(For other spot day trading operations, orderType = Stock) ##### OrderResult[​](#orderresult "Direct link to OrderResult") OrderResult; You can use [getOrderResults](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/trade/GetOrderResults.md) to get data. | Parameter | Type | Meaning | | --------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:MarketType | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:PriceType | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:TimeInForce | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:OrderType | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | unit | number | Trading Unit | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time (see below for the format) | | errorMessage | string | Error Message | | details | list | Order Process (The following fields will only appear in the query details) | | >> functionType | number | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time (see below for the format) | | >> beforeQty | number | Original Order Quantity | | >> afterQty | number | Valid Order Quantity (filled quantity included) | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> status | number | Order Status | | >> errMsg | string | Error Message | Time Format lastTime and modifiedTime format: **HH:MM:SS.fff** or **HH:MM:SS** (that is, if .fff = .000, .fff will be ommitted). ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult; You can use [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/trade/batchOrder/BatchOrderList.md) to get data. | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | ##### ModifyPriceObj[​](#modifypriceobj "Direct link to ModifyPriceObj") Modified Price Object | Parameter | Type | Default Value | Meaning | | ----------- | --------- | ------------- | ------------------------------------------------------------------------------------------ | | OrderResult | Object | - | [OrderResult](#orderresult) | | price | number | - | The price after modification | | PriceType | PriceType | - | The price type after modification : `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | About Price Type The Co-lo version **has** enabled the use of PriceType. ##### ModifyQuantityObj[​](#modifyquantityobj "Direct link to ModifyQuantityObj") Modified Quantity Object | Parameter | Type | Default Value | Meaning | | ----------- | ------ | ------------- | ------------------------------- | | OrderResult | Object | - | [OrderResult](#orderresult) | | quantity | int | - | The quantity after modification | ##### FilledData[​](#filleddata "Direct link to FilledData") Filled Data Object | Parameter | Type | Meaning | | -------------- | ------------------------------------------------ | ----------------------------------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | stockNo | string | Symbol | | buySell | js:string / ts:BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | orderType | js:string / ts:OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | filledNo | string | Filled Serial Number | | filledAvgPrice | number | Filled Average Price | | filledQty | number | Filled Share | | filledPrice | number | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ----------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branchNo | string | Branch Number | | accountType | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### MarketType[​](#markettype "Direct link to MarketType") Trading Session Type | Name | Meaning | | ----------- | ----------------------------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | | Emg | Emerging Stock Market | | EmgOdd | Emerging Stock Market ( Share Unit) | When using different MarketTypes, the corresponding units and ranges represented by Quantity may also vary. Details are as follows | Name | Quantity Unit | Quantity Ranges | | ----------- | --------------- | --------------- | | Common | Thousand Shares | 1000 ~ 499000 | | Fixing | Thousand Shares | 1000 ~ 499000 | | IntradayOdd | Share | 1 ~ 999 | | Odd | Share | 1 ~ 999 | | Emg | Thousand Shares | 1000 ~ 499000 | | EmgOdd | Share | 1 ~ 999 | When using different MarketTypes, the available PriceType and TimeInForce as below. | 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") Price Type | Name | Meaning | | --------- | ------------------------------------------------ | | Limit | Limit | | LimitUp | Limit Up | | LimitDown | Limit Down | | Market | Market | | Reference | Reference Price (Fixing Price at Fixing Session) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### OrderType[​](#ordertype "Direct link to OrderType") Order Type | Name | Meaning | | -------- | -------------------------------------- | | Stock | Common Stock | | Margin | Margin | | Short | Margin Short Selling | | DayTrade | Spot Short Selling (day trading) | | SBL | Short Selling (with security borrowed) | ##### StockType[​](#stocktype "Direct link to StockType") Stock Category | Name | Meaning | | ------------- | ---------------- | | Stock | Common Stock | | ConvertBond | Convertible Bond | | ETF\_and\_ETN | ETF and ETN | ##### functionType[​](#functiontype "Direct link to functionType") Function Type | Name | Value | | -------------------------------------- | ----- | | New Order | 0 | | New Order Executed | 10 | | Change Price | 15 | | Change Quantity | 20 | | Cancel Order | 30 | | Fully Filled (for OrderResult details) | 50 | | Order Failed | 90 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | ----------------------------- | ------- | | Listed stocks | TAIEX | | Over-the-Counter (OTC) stocks | TAISDAQ | | Emerging Stock | TAIEMG | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | Reservation | 0 | | Sending to the system backend | 4 (Using GetOrderResult to retrieve the latest status) | | Processing by the backend | 8 (Using GetOrderResult to retrieve the latest status) | | Timeout | 9 (Please wait a moment and use GetOrderResult to retrieve the latest status ; or contact your broker agent) | | Active order | 10 | | Canceled | 30 | | Partially filled, others canceled | 40 | | Fully filled | 50 | | Order not valid | 90 | | Flags for order result details | 14 - ACK of modifing price、24 - ACK of modifing quantity、34 - ACK of canceling | | Modify price successfully (for history order inquiry) | 15 | | Modify quantity successfully (for history order inquiry) | 20 | | Fail to modify order price (for callback) | 19 | | Fail to modify order quantity (for callback) | 29 | | Fail to cancel (for callback) | 39 | --- ### API Key Login apikeyLogin Version Info. Available since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------ | ---------------------- | | personalId | String | Login ID | | key | String | API Key | | certPath | String | Certification Path | | certPass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Account list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.apikeyLogin("Your ID", "API Key","Your Cert Path","Your Cert Password"); Console.log(accounts); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ name: '富邦Bill', // Account Name (string) account: '28', // Account Number (string) branchNo: '6460', // Branch Number (string) accountType: 'stock' // Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------ | ---------------------- | | personalId | String | Login ID | | Password | String | Login Password | | certPath | String | Certification Path | | certPass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Account list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password","Your Cert Path","Your Cert Password"); Console.log(accounts); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ name: '富邦Bill', // Account Name (string) account: '28', // Account Number (string) branchNo: '6460', // Branch Number (string) accountType: 'stock' // Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ---- | ---------------- | | isSuccess | bool | Interface result | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); sdk.logout(); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js true ``` --- ### Batch Cancel Order batchCancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | Account | Account | | orderResult | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult)(list of object) | The intended order result object to be cancel | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch cancel( using the content returned by batch detail) cancel_object = [ batch_results_detail.data[0], batch_results_detail.data[1], ] sdk.stock.batchCancelOrder(account, cancel_object) // Batch cancel( Using different individual orders) cancel_object = [ orders[37], orders[35], ] sdk.stock.batchCancelOrder(account, cancel_object) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 30, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000308998', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0028', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Order Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 30, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (string) afterPrice: 41.2, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 0, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 5000, // Before the Quantity Modification (number) beforePrice: 41.2, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '12:53:57.536', // Last Modification Time (string) }, { functionType: 30, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '0000030899', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0029', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Order Price (double) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (TimeInforce) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 30, // Order Status (number) ... } } ``` --- ### Batch Modify Price batchModifyPrice ##### First, using 'makeModifyPriceObj' create a 'ModifyPriceObj' object[​](#first-using-makemodifypriceobj-create-a-modifypriceobj-object "Direct link to First, using 'makeModifyPriceObj' create a 'ModifyPriceObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string? | The price after modification | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype)? | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'batchModifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#modifypriceobj) (list of object) | The object for price modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch price modification ( modifying orders using the content returned by batch detail ) modify_orders = [ sdk.stock.makeModifyPriceObj(batch_res.data[0], "41.1"), sdk.stock.makeModifyPriceObj(batch_res.data[1], "41.1") ] sdk.stock.batchModifyPrice(account, modify_orders); // Batch price modification ( Using different individual orders ) modify_orders = [ sdk.stock.makeModifyPriceObj(orderResult.data[20], "41.1"), sdk.stock.makeModifyPriceObj(orderResult.data[21], "41.1"), sdk.stock.makeModifyPriceObj(orderResult.data[28], "41.1") ] sdk.stock.batchModifyPrice(account, modify_orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ // Batch price modification (modifying orders using the content returned by batch detail) { functionType: 15, // Function Type (number) date: '2023/11/22', // Transaction Date (string) seqNo: '00000322356', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0018', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (OrderType) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (string) afterPrice: 41.1, // Valid Order Price (number) unit: 1000, // Unit (number) afterQty: 2000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforePrice: 41.3, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '13:56:57.713', // Last Modification Time (string) errorMessage: '', // Error Message (string) }, { functionType: 15, // Function Type (number) date: '2023/11/22', // Transaction Date (string) seqNo: '00000322355', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0017', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) ... } ] } Below example only extract data content [ // Batch price modification( Using different individual orders ) { functionType: 15, // Function Type (number) date: '2023/11/22', // Transaction Date (string) seqNo: '00000322388', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0033', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (TimeInForce) orderType: 'Stock', // Order Type (OrderType) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (string) afterPrice: 41.1, // Valid Order Price (number) unit: 1000, // Unit (number) afterQty: 2000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforePrice: 41.3, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '10:56:57.713', // Last Modification Time (string) }, { functionType: 15, // Function Type (number) date: '2023/11/22', // Transaction Date (string) seqNo: '00000322386', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0031', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) ... }, ... ] ``` --- ### Batch Modify Quantity batchModifyQuantity ##### First, using 'makeModifyQuantityObj' create a 'ModifyQuantityObj' object[​](#first-using-makemodifyquantityobj-create-a-modifyquantityobj-object "Direct link to First, using 'makeModifyQuantityObj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) | The intended order result object to be modified | | quantity | number | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | Put the returned object into the 'batchModifyQuantity' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | ModifyQuantityObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#modifyquantityobj) (list of object) | The object for Quantity modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch quantity modification ( modifying orders using the content returned by batch detail ) modify_orders = [ sdk.stock.makeModifyQuantityObj(batch_res.data[0], 1000), sdk.stock.makeModifyQuantityObj(batch_res.data[1], 1000) ] sdk.stock.batchModifyQuantity(account, modify_orders); // Batch quantity modification ( Using different individual orders ) modify_orders = [ sdk.stock.makeModifyQuantityObj(orderResult.data[22], 1000), sdk.stock.makeModifyQuantityObj(orderResult.data[40], 1000) ] sdk.stock.batchModifyQuantity(account, modify_orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ // Batch quantity modification ( modifying orders using the content returned by batch detail ) { functionType: 20, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000000042', // Order Serial Number (string) branchNo: '20112', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0026', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '2881', // Symbol (string) buySell: 'Buy', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 66, // Order Price (number) quantity: 2000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPrice: 66, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 1000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 2000, // Before the Quantity Modification (number) userDef: 'batch 2', // Custom Fields (string) lastTime: '12:21:51.023', // Last Modification Time (string) }, { functionType: 20, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000000041', // Order Serial Number (string) branchNo: '20112', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0025', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '2881', // Symbol (string) buySell: 'Buy', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 66, // Order Price (number) quantity: 2000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPrice: 66, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 1000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 2000, // Before the Quantity Modification (number) userDef: 'batch 1', // Custom Fields (string) lastTime: '12:21:51.023', // Last Modification Time (string) } ] } Below example only extract data content [ // Batch quantity modification ( Using different individual orders ) { functionType: 20, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000000043', // Order Serial Number (string) branchNo: '20112', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0027', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '2881', // Symbol (string) buySell: 'Buy', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 66, // Price (number) quantity: 2000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPrice: 66, // Valid Order Price (number) unit: 1000, // Unit (number) afterQty: 1000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 2000, // Before the Quantity Modification (number) userDef: 'Test', // Custom Fields (string) lastTime: '12:21:53.023', // Last Modification Time (string) }, { functionType: 20, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000000044', // Order Serial Number (string) branchNo: '20112', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0028', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '2881', // Symbol (string) buySell: 'Buy', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 66, // Price (number) quantity: 2000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (TimeInForce) orderType: 'Stock', // Order Type (OrderType) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPrice: 66, // Valid Order Price (number) unit: 1000, // Unit (number) afterQty: 1000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 2000, // Before the Quantity Modification (number) userDef: 'Test', // Custom Fields (string) lastTime: '12:21:53.023', // Last Modification Time (string) } ] ``` --- ### Get Batch Order Detail batchOrderDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | BatchOrderList | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#batchresult) | Batch order list | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```js const batch_order_list = sdk.stock.batchOrderLists(account) sdk.stock.batchOrderDetail(account, batch_order_list.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/10/23', // Trading Date (string) seqNo: '00000000023', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (number) stockNo: '1101', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 35, // Order Price (number) quantity: 1000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 90, // Order Status (number) afterPriceType: 'Limit', // Valid order price type (string) afterPrice: 35, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 0, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 0, // Before the quantity modification (number) beforePrice: 35, // Before the price modification (number) userDef: 'batch 1', // Custom fields (string) lastTime: '16:24:28.732' // Last modification time (string) }, ... ] } ``` --- ### Get Batch Order List batchOrderLists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | BatchResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Query Date (today) | | branchNo | string | Branch number | | account | string | Account | | batchSeqNo | string | Serial number | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.batchOrderLists(target_user) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: 0, // Type of function (number) date: '2023/10/24', // Query Date (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) batchSeqNo: '11EE72270B4D79F48000000C29304663' // serial number (string) }, ... ] } ``` --- ### Place Batch Order batchPlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------ | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderobject) (list of object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = [{ buySell: BSAction.Buy, symbol: "2888", price: "8.90", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "batch1" },{ buySell: BSAction.Buy, symbol: "2888", price: "9.00", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "batch2" } ]; const batch_order_results = sdk.stock.batchPlaceOrder(account,orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: 0, // Function Type (number) date: '2023/10/24', // Trading Date (string) seqNo: '00000000002', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA720', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 8.9, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid order price type (string) afterPrice: 8.9, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 0, // Before the quantity modification (number) beforePrice: 9, // Before the price modification (number) userDef: 'batch1', // Custom fields (string) lastTime: '11:02:27.599' // Last modification time (string) }, { functionType: 0, // Function Type (number) date: '2023/10/24', // Trading Date (string) seqNo: '00000000003', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA720', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 9.0, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid order price type (string) afterPrice: 9.0, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 0, // Before the quantity modification (number) beforePrice: 9, // Before the price modification (number) userDef: 'batch2', // Custom fields (string) lastTime: '11:02:27.599' // Last modification time (string) } ] } ``` --- ### Cancel Order cancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | orderResult | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) | The intended order result object to be cancel | | unblock | bool? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.CancelOrder(account, cancel_order, true) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 30, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000308948', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0023', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Order Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation Order Flag (bool) status: 30, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (string) afterPrice: 41.2, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 0, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 5000, // Before the Quantity Modification (number) beforePrice: 41.2, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '12:53:57.536', // Last Modification Time (string) } } ``` --- ### Get Daytrade Quota and Precollect Information daytradeAndStockInfo #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | stockNo | string | Symbol | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | DayTradeStockInfo list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### DayTradeStockInfo Parameter[​](#daytradestockinfo-parameter "Direct link to DayTradeStockInfo Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | stockNo | string | Symbol | | date | string | Query Date | | daytradeOrigQuota | number | Original Short Daytrade Quota | | daytradeTradableQuota | number | Available Short Daytrade Quota | | precollectSingle | number | Pre-collected for single order | | precollectAccumulate | number | Pre-collected for accumulate order | | status | number | Status (bitmask type ) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | dispositionStatus | string | Disposition Status `{ SETTYPE : 1}` : Full-Cash-Delivery、 `{ MARK-W : 1}` : Warning、`{ MARK-P : 1}` : Attention、`{ MARK-L : 1}` : Order Placement Restricted 【**New field for version >=2.2.5**】 | info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.daytradeAndStockInfo(account, "2330") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { stockNo: '3264', // Stock symbol (string) date: '2023/10/04', // Query date (string) daytradeOrigQuota: 0, // Original short daytrade quota (number) daytradeTradableQuota: 0, // Available short daytrade quota (number) precollectSingle: , // Precollect for single order (number) precollectAccumulate: , // Precollect for accumulate order (number) status: 0 // Status (number) } ] } ``` --- ### Get Historical Filled filledHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Query Start Date | | endDate | string? (null or empty will equals startDate) | Query End Date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FilledData list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FilledData Parameter[​](#filleddata-parameter "Direct link to FilledData Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | filledNo | string | Filled Serial Number | | filledAvgPrice | number | Filled Average Price | | filledQty | number | Filled Share | | filledPrice | number | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```js const filledHistory = sdk.stock.filledHistory(account,"20230921","20230922"); console.log(filledHistory) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/08/29', // Filled Date (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA047', // Order number (string) stockNo: '1101', // Symbol (string) buySell: 1, // Buy/Sell Type (number) orderType: 0, // Order Type (number) filledNo: '00000000001', // Filled Transaction number (string) filledAvgPrice: 35.3, // Filled Average Price (number) filledQty: 1000, // Filled Share (number) filledPrice: 35.3, // Filled Price (number) filledTime: '10:14:36.549' // Filled Time (string) }, { date: '2023/08/29', // Filled Date (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA052', // Order number (string) stockNo: '1101', // Symbol (string) buySell: 1, // Buy/Sell Type (number) orderType: 0, // Order Type (number) filledNo: '00000000002', // Filled Transaction number (string) filledAvgPrice: 35.3, // Filled Average Price (number) filledQty: 1000, // Filled Share (number) filledPrice: 35.2, // Filled Price (number) filledTime: '10:31:00.931' // Filled Time (string) }, ... ] } ``` --- ### Get Order Results getOrderResults #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (Optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = sdk.stock.getOrderResults(accounts.data[0]); console.log(orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/10/24', // Trading Date (string) seqNo: '00005000001', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA719', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 9, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 10, // Order Status (number) afterPrice: 9, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) userDef: 'from Js', // Custom fields (string) lastTime: '10:26:22.140' // Last modification time (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) getOrderResultsDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | unit | number | Trading Unit | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process | | >> functionType | number | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | number | Original Order Quantity | | >> afterQty | number | Valid Order Quantity (filled quantity included) | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> status | number | Order Status | | >> errMsg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = sdk.stock.getOrderResultsDetail(accounts.data[0]); console.log(orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/10/24', // Trading Date (string) seqNo: '00005000001', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA719', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 9, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 10, // Order Status (number) afterPrice: 9, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) userDef: 'from Js', // Custom fields (string) lastTime: '10:26:22.140' // Last modification time (string) details: [ { functionType: 10, // Function Type (number) modifiedTime: '10:26:22.140' // Order Modified Time (string) beforeQty: 0, // Original Order Quantity (number) afterQty: 2000, // Valid Order Quantity (number) beforePrice: 9, // Original Order Price (number) afterPrice: 9 // Valid Order Price (number) } ] }, ... ] } ``` --- ### Get Margin Quota marginQuota #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | stockNo | string | Symbol | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | MarginShortQuota list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### MarginShortQuota Parameter[​](#marginshortquota-parameter "Direct link to MarginShortQuota Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------- | -------- | ---------------------------- | | stock\_no | string | Symbol | | date | string | Query Date (today) | | shortsellOrigQuota | number ? | The Original Shortsell Quota | | shortsellTradableQuota | number ? | Available Shortsell Quota | | marginOrigQuota | number ? | The Original Margin Quota | | marginTradableQuota | number ? | Available Margin Quota | | marginRatio | number ? | Margin Ration | | shortRatio | number ? | Short Sell Ration | info Explanation of Quota: If the marginRatio not return, it means margin is halted. If the shorRatio not return, it means short selling is halted. Explanation of Returned Quota: 0 - No quota / Greater than 0 - Quota available / Not return - No restrictions / Both of ratio of and quota not return 0 - margin or short selling halted. #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.marginQuota(account, "2330") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ stockNo: '2330', // Stock symbol (string) date: '2024/01/24', // Query date (string) shortsellOrigQuota: 894, // The original short sell quota (number) shortsellTradableQuota: 894, // Available short sell quota (number) marginRatio: 60, // Margin ratio (number) shortRatio: 90 // Short sell ratio (number) } } ``` --- ### Modify Order Price modifyPrice ##### First, using 'makeModifyPriceObj' create a 'ModifyPriceObj' object[​](#first-using-makemodifypriceobj-create-a-modifypriceobj-object "Direct link to First, using 'makeModifyPriceObj' create a 'ModifyPriceObj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string? | The price after modification | | priceType | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype)? | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'modifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#modifypriceobj) | The object for price modification | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const modifyPriceObj = sdk.stock.makeModifyPriceObj(target_order, "41.1"); sdk.stock.modifyPrice(accounts.data[0], modifyPriceObj) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 15, // Function Type (number) date: '2023/11/22', // Transaction Date (string) seqNo: '00000308866', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0011', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (MarketType) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (BSAction) priceType: 'Limit', // Original Order Price Type (PriceType) price: 41.2, // Order Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (TimeInForce) orderType: 'Stock', // Order Type (OrderType) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (PriceType) afterPrice: 41.1, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 2000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforePrice: 41.3, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '10:56:57.713', // Last Modification Time (string) } } ``` --- ### Modify Order Quantity modifyQuantity ##### First, using 'makeModifyQuantityObj' create a 'ModifyQuantityObj' object[​](#first-using-makemodifyquantityobj-create-a-modifyquantityobj-object "Direct link to First, using 'makeModifyQuantityObj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | ----------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | orderResult | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | The intended order result object to be modified | | quantity | numbe | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | Put the returned object into the 'modifyQuantity' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | account | [account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | modifiedQtyObj | [ModifyQuantityObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#modifyquantityobj) | The object for Quantity modification | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const modifyQtyObj = sdk.stock.makeModifyPriceObj(target_order, 1000); sdk.stock.modifyQuantity(accounts.data[0], modifyQtyObj, false) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 20, // Function Type (number) date: '2024/03/08', // Transaction Date (string) seqNo: '00000308866', // Order Serial Number (string) branchNo: '6460', // Branch Number (string) account: '26', // Account (string) orderNo: 'x0011', // Order Number (string) assetType: 0, // Asset Type (number) market: 'TAIEX', // Market Type (string) marketType: 'Common', // Trading Session Type (string) stockNo: '1101', // Symbol (string) buySell: 'Sell', // Buy/Sell Type (string) priceType: 'Limit', // Original Order Price Type (string) price: 41.2, // Order Price (number) quantity: 5000, // Original Order Quantity (number) timeInForce: 'ROD', // Time In Force (string) orderType: 'Stock', // Order Type (OrderType) isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number) afterPriceType: 'Limit', // Valid Order Price Type (string) afterPrice: 41.3, // Valid Order Price (number) unit: 1000, // Trading Unit (number) afterQty: 1000, // Valid Order Quantity (number) filledQty: 0, // Filled Quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 3000, // Before the Quantity Modification (number) beforePrice: 41.2, // Before the Price Modification (number) userDef: '12345678', // Custom Fields (string) lastTime: '12:56:28.966', // Last Modification Time (string) } } ``` --- ### Get Historical Order orderHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Query Start Date | | endDate | string? (null or empty will equals startDate) | Query End Date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int ? (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | unit | number | Trading Unit | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process | | >> functionType | number | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | number | Original Order Quantity | | >> afterQty | number | Valid Order Quantity (filled quantity included) | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> status | number | Order Status | | >> errMsg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orderHistory = sdk.stock.orderHistory(account,"20230921","20231020"); console.log(orderHistory); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2023/10/11', // Trading Date (string) seqNo: '00005000001', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA586', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 8.9, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (bool) status: 10, // Order Status (number) afterPrice: 8.51, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) userDef: 'From Js', // Custom fields (string) lastTime: '11:25:08.761' // Last modification time (string) details: [ { functionType: 10, // Function Type (number) modifiedTime: '11:25:08.761' // Order Modified Time (string) beforeQty: 0, // Original Order Quantity (number) afterQty: 2000, // Valid Order Quantity (number) beforePrice: 8.51, // Original Order Price (number) afterPrice: 8.51 // Valid Order Price (number) } ] }, ... ] } ``` --- ### PlaceOrder placeOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#orderobject) | Order Object | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | OrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `0` Stock | | market | string | Market type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | marketType | js:string / ts:[MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) | Trading session type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg`、 `EmgOdd` | | stockNo | string | Symbol | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Original order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | number | Order Price | | quantity | number | Original order quantity | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` Short sale 、 `DayTrade` 、 `SBL` | | isPreOrder | bool | Reservation Flag | | status | number | Order status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#status) | | afterPriceType | js:string / ts:[PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#pricetype) | Valid order price type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | afterPrice | number | Valid order price | | afterQty | number | Valid Order Quantity (filled quantity included) | | filledQty | number | Filled Quantity | | filledMoney | number | Filled Value | | beforeQty | number | Before the Quantity Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```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, userDef: "from Js" }; sdk.stock.placeOrder(accounts.data[0],order,false); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 0, // Function Type (number) date: '2023/10/23', // Trading Date (string) seqNo: '00000000016', // Order serial number (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) orderNo: 'bA716', // Order number (string) assetType: 0, // Asset Category (number) market: 'TAIEX', // Market Category (string) marketType: 'Common', // Trading session type (string) stockNo: '2888', // Symbol (string) buySell: 'Buy', // Transaction direction (string) priceType: 'Limit', // Order price type (string) price: 9, // Order Price (number) quantity: 2000, // Order quantity (number) timeInForce: 'ROD', // Time in force (string) orderType: 'Stock', // Order Type (string) isPreOrder: false, // Reservation flag (boolean) status: 10, // Order Status (number) afterPriceType: Limit, // Valid order price type (PriceType) afterPrice: 9, // Valid order price (number) unit: 1000, // Share Unit (number) afterQty: 2000, // Valid order quantity (number) filledQty: 0, // Filled quantity (number) filledMoney: 0, // Filled Value (number) beforeQty: 0, // Before the quantity modification (number) beforePrice: 9, // Before the price modification (number) userDef: 'from Js', // Custom fields (string) lastTime: '13:36:38.317' // Last modification time (string) } } ``` --- ### Query Stock Quote Information (Single) querySymbolQuote info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | symbol | String | Symbol | | marketType | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | --------- | ----------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | SymbolQuote | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | market | string | Market | | symbol | string | Symbol | | istibOrPsb | bool | Whether it is TIB or PSB board | | marketType | string | Market type | | status | number | Status (bitmask) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | referencePrice | number | Reference price | | unit | number | Trading unit | | updateTime | string | Update time | | limitupPrice | number | Upper price limit | | limitdownPrice | number | Lower price limit | | openPrice | number | Opening price | | highPrice | number | Highest price | | lowPrice | number | Lowest price | | lastPrice | number | Latest traded price | | totalVolume | number | Total traded volume | | totalTransaction | number | Total number of trades (Reserved field, not currently in use) | | totalValue | number | Total traded value | | lastSize | number | Latest traded volume | | lastTransaction | number | Latest number of trades (Reserved field, not currently in use) | | lastValue | number | Latest traded value | | bidPrice | number | Best bid price | | bidVolume | number | Best bid volume | | askPrice | number | Best ask price | | askVolume | number | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.stock.querySymbolQuote(accounts.data[0],"2330") Console.WriteLine(quote.data) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, message : , data : { market : TAIEX, // string - Market symbol : 2330, // string - Symbol istibOrPsb : false, // bool - Whether it is TIB or PSB board marketType : Common, // string - Market type status : 15, // number - Status (bitmask sum) referencePrice : 780, // double - Reference price unit : 1000, // number - Trading unit updateTime : , // string - Update time limitupPrice : 858, // number - Upper price limit limitdownPrice : 702, // number - Lower price limit openPrice : 1155, // number - Opening price highPrice : 1160, // number - Highest price lowPrice : 1145, // number - Lowest price lastPrice : 1145, // number - Latest traded price totalVolume : 20501, // number - Total traded volume totalTransaction : 0, // number - Total number of trades (Reserved field, not currently in use) totalValue : 23551095000, // number - Total traded value lastSize : 6673, // number - Latest traded volume lastTransaction : 0, // number - Latest number of trades (Reserved field, not currently in use) lastValue : 7640585000, // number - Latest traded value bidPrice : 1145, // number - Best bid price bidVolume : 1549, // number - Best bid volume askPrice : 1150, // number - Best ask price askVolume : 4169 // number - Best ask volume } } ``` --- ### Query Stock Quote Information (Batch) querySymbolSnapshot info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Account | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#account) | Account | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | | stock\_type | List [StockType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/EnumMatrix.md#stocktype) (Optional)(default = Stock) | Product category: `Stock` (stocks), `ConvertBond` (convertible bonds), `ETF_and_ETN` (ETFs and ETNs) | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | --------- | ---------------------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | SymbolSnapshotResponse | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | market | string | Markets | | symbol | string | Symbol | | istibOrPsb | bool | Whether it is TIB or PSB board | | marketType | string | Market type | | status | number | Status (bitmask sum) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | referencePrice | number | Reference price | | unit | number | Trading unit | | updateTime | string | Update time | | limitupPrice | number | Upper price limit | | limitdownPrice | number | Lower price limit | | openPrice | number | Opening price | | highPrice | number | Highest price | | lowPrice | number | Lowest price | | lastPrice | number | Latest traded price | | totalVolume | number | Total traded volume | | totalTransaction | number | Total number of trades (Reserved field, not currently in use) | | totalValue | number | Total traded value | | lastSize | number | Latest traded volume | | lastTransaction | number | Latest number of trades (Reserved field, not currently in use) | | lastValue | number | Latest traded value | | bidPrice | number | Best bid price | | bidVolume | number | Best bid volume | | askPrice | number | Best ask price | | askVolume | number | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```js const { StockType } = require('fubon-neo'); sdk.stock.querySymbolSnapshot(accounts.data[0]) // Default sdk.stock.querySymbolSnapshot(accounts.data[0], MarketType.Common, [StockType.Stock]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess : true, message : , data : { market : TAIEX, // string - Market symbol : 2330, // string - Symbol istibOrPsb : false, // bool - Whether it is TIB or PSB board marketType : Common, // string - Market type status : 15, // number - Status (bitmask sum) referencePrice : 780, // double - Reference price unit : 1000, // number - Trading unit updateTime : , // string - Update time limitupPrice : 858, // number - Upper price limit limitdownPrice : 702, // number - Lower price limit openPrice : 1155, // number - Opening price highPrice : 1160, // number - Highest price lowPrice : 1145, // number - Lowest price lastPrice : 1145, // number - Latest traded price totalVolume : 20501, // number - Total traded volume totalTransaction : 0, // number - Total number of trades (Reserved field, not currently in use) totalValue : 23551095000, // number - Total traded value lastSize : 6673, // number - Latest traded volume lastTransaction : 0, // number - Latest number of trades (Reserved field, not currently in use) lastValue : 7640585000, // number - Latest traded value bidPrice : 1145, // number - Best bid price bidVolume : 1549, // number - Best bid volume askPrice : 1150, // number - Best ask price askVolume : 4169 // number - Best ask volume }, { market : TAIEX, // string - Market symbol : 2881, // string - Symbol ... } } ``` --- ### Query bank remains bank\_remain #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ---------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | BankRemain | BankRemain is returned | | message | string | is\_success = False error description is returned | ##### BankRemain Parameter[​](#bankremain--parameter "Direct link to BankRemain Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------ | ----------------- | | branch\_no | string | Branch Number | | account | string | Account | | currency | string | Currency | | balance | int | Balance | | available\_balance | int | Available Balance | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.bank_remain(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data : BankRemain{ branch_no: "6460", # Branch Number (string) account: "26", # Account (string) currency: "TWD", # Currency (string) balance: "666666", # Balance (int) available_balance: "123456" # Available Balance (int) } } ``` --- ### Inventories inventories #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Inventory list is returned | | message | string | is\_success = False error description is returned | ##### Inventory Parameter[​](#inventory-parameter "Direct link to Inventory Parameter") Return type : Object | Parameter | Type | Meaning | | -------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | > date | string | Query date(Today) | | > account | string | Account | | > branch\_no | string | Branch number | | > stock\_no | string | Symbol | | > order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | > lastday\_qty | int | Yesterday Share balacne | | > buy\_qty | int | Total volume purchased today | | > buy\_filled\_qty | int | Total purchased filled today | | > buy\_value | int | Total amount purchased today | | > today\_qty | int | Today Share balacne | | > tradable\_qty | int | Available quantity | | > sell\_qty | int | Total volume sell today | | > sell\_filled\_qty | int | Total sell filled today | | > sell\_value | int | Total amount sell today | | > odd | list | Object | | >> lastday\_qty | int | Yesterday odd lot balacne | | >> buy\_qty | int | Total volume purchased today | | >> buy\_filled\_qty | int | Total purchased filled today | | >> buy\_value | int | Total amount purchased today | | >> today\_qty | int | Today odd lot balacne | | >> tradable\_qty | int | Available quantity | | >> sell\_qty | int | Total volume sell today | | >> sell\_filled\_qty | int | Total sell filled today | | >> sell\_value | int | Total amount sell today | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.inventories(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ Inventory{ date: "2023/10/16", # Query date(Today) (string) account: "26", # Account (string) branch_no: "6460", # Branch number (string) stock_no: "1101", # Symbol (string) order_type: Stock, # Order Type (OrderType) lastday_qty: 2000, # Yesterday Share balacne (int) buy_qty: 0, # Total volume purchased today (int) buy_filled_qty: 0, # Total purchased filled today (int) buy_value: 0, # Total amount purchased today (int) today_qty: 2000, # Today Share balacne (int) tradable_qty: 2000, #Available quantity (int) sell_qty: 0, # Total volume sell today (int) sell_filled_qty: 0, # Total sell filled today (int) sell_value: 0, # Total amount sell today (int) odd: InventoryOdd{ # odd lot lastday_qty: 0, # Yesterday odd lot balacne (int) buy_qty: 0, # Total volume purchased today (int) buy_filled_qty: 0, # Total purchased filled today (int) buy_value: 0, # Total amount purchased today (int) today_qty: 0, # Today odd lot balacne (int) tradable_qty: 0, # Available quantity (int) sell_qty: 0, # Total volume sell today (int) sell_filled_qty: 0,# Total sell filled today (int) sell_value: 0 # Total amount sell today (int) } }, ... ] } ``` --- ### Maintenance maintenance #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | --------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | MaintenanceData | MaintenanceData is returned | | message | string | is\_success = False error description is returned | ##### MaintenanceData Parameter[​](#maintenancedata-parameter "Direct link to MaintenanceData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------------ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | > date | string | Query Date | | > branch\_no | string | Branch Number | | > account | string | Account | | > maintenance\_summary | list | Object | | >> margin\_value | int | Total Margin Value | | >> shortsell\_value | int | Total Short Sell Value | | >> shortsell\_margin | int | Total Short Sell Margin Amount | | >> collateral | int | Collateral | | >> margin\_loan\_amt | int | Total Margin Loan Amount | | >> maintenance\_ratio | float | Account Maintenance Ratio | | >> maintenance\_detail | list | Object | | >>> stock\_no | string | Symbol | | >>> order\_no | string | Order Number | | >>> order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | >>> quantity | int | Hoding Share | | >>> price | float | Calculated Price | | >>> cost\_price | float | Cost Price | | >>> shortsell\_margin | int | Short Sell Margin | | >>> collateral | int | Collateral | | >>> margin\_loan\_amt | int | Margin Loan Amount | | >>> maintenance\_ratio | float | Maintenance Ratio | | >>> collateral\_interest | float | Collateral Interest | | >>> margin\_interest | float | Margin Interest | | >>> shortsell\_interest | float | Shortsell Interest | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.maintenance(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data: MaintenanceData { date: "2024/02/27", # Date (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) maintenance_summary: MaintenanceSummary { # Account Summary margin_value: 3135000, # Total Margin Value (int) shortsell_value: 0, # Total Short Sell Value (int) shortsell_margin: 0, # Total Short Sell Margin Amount (int) collateral: 0, # Collateral (int) margin_loan_amt: 1494000, # Total Margin Loan Amount (int) maintenance_ratio: 209.83, # Maintenance Ratio (float) }, maintenance_detail: [ # Stock Summary MaintenanceSummary { stock_no: "2603", # Symbol (string) order_no: "x4580", # Order Number (string) order_type: Stock, # Order Type (OrderType) quantity: 10000, # Holding Quantity (int) price: 152.5, # Calculated Price (float) cost_price: 119, # Cost Price (float) shortsell_margin: 0, # Short Sell Margin (int) collateral: 0, # Collateral (int) margin_loan_amt: 0, # Margin Loan Amount (int) maintenance_ratio: 213.58, # Maintenance Ratio (float) collateral_interest: 0, # Collateral Interest (float) margin_interest: 20818, # Margin Interest (float) shortsell_interest: 0, # Shortsell Interest (float) } ], } } ``` --- ### Query Settlemet query\_settlement #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | range | string | Query range, currently valid values are "0d" (today) and "3d". | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | -------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | SettlementData | Settlement is returned | | message | string | is\_success = False error description is returned | ##### SettlementData Parameter[​](#settlementdata-parameter "Direct link to SettlementData Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------------------- | ----------------- | ------------------------------------------------------------------ | | > account | list | Object | | >> branch\_no | string | Branch Number | | >> account | string | Account | | > details | list | Object | | >> date | string | Query Date | | >> settlement\_date | string (Optional) | Settlement Date (If no data will return None ) | | >> buy\_value | int (Optional) | Buying Value (If no data will return None ) | | >> buy\_fee | int (Optional) | Buying Fee (If no data will return None ) | | >> buy\_settlement | int (Optional) | Buying Payable / Receivable Amount (If no data will return None ) | | >> buy\_tax | int (Optional) | Buying Tax (If no data will return None ) | | >> sell\_value | int (Optional) | Selling Value (If no data will return None ) | | >> sell\_fee | int (Optional) | Selling Fee (If no data will return None ) | | >> sell\_settlement | int (Optional) | Selling Payable / Receivable Amount (If no data will return None ) | | >> sell\_tax | int (Optional) | Selling Tax (If no data will return None ) | | >> total\_bs\_value | int (Optional) | Total Buying & Selling Value (If no data will return None ) | | >> total\_fee | int (Optional) | Total Fee (If no data will return None ) | | >> total\_tax | int (Optional) | Total Tax (If no data will return None ) | | >> total\_settlement\_amount | int (Optional) | Total Payable & Receivable Amount (If no data will return None ) | | >> currency | string (Optional) | Currency (If no data will return None ) | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.query_settlement(account,"3d") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : SettlementData{ account: AccountRes { branch_no: "6460", # Branch Number (string) account: "26" # Account (string) }, details: [ Settlement{ date: "2023/10/16", # Query Date (string) settlement_date: "2023/10/18", # Settlement Date (string) buy_value: 12, # Buying Value (int) buy_fee: 12, # Buying Fee (int) buy_settlement: 0, # Buying Payable / Receivable Amount (int) buy_tax: 0, # Buying Tax (int) sell_value: 4, # Selling Value (int) sell_fee: 4, # Selling Fee (int) sell_settlement: 0, # Selling Payable / Receivable Amount (int) sell_tax: 4, # Selling Tax (int) total_bs_value: 16, # Total Buying & Selling Value (int) total_fee: 16, # Total Fee (int) total_tax: 4, # Total Tax (int) total_settlement_amount: 0, # Total Payable & Receivable Amount (int) currency: TWD, # Currency (string) }, Settlement{ date: "2023/10/17", # Query Date (string) settlement_date: "2023/10/19", # Settlement Date (string) buy_value: 735500, # Buying Value (int) buy_fee: 313, # Buying Fee (int) buy_settlement: -1429513, # Buying Payable / Receivable Amount (int) buy_tax: 0, # Buying Tax (int) sell_value: 770500, # Selling Value (int) sell_fee: 320, # Selling Fee (int) sell_settlement: 0, # Selling Payable / Receivable Amount (int) sell_tax: 2309, # Selling Tax (int) total_bs_value: 1506000, # Total Buying & Selling Value (int) total_fee: 633, # Total Fee (int) total_tax: 2309, # Total Tax (int) total_settlement_amount: -1429513, # Total Payable & Receivable Amount (int) currency: "TWD", # Currency (string) }, Settlement{ date: "2023/10/18", # Query Date (string) settlement_date: None, # Settlement Date (string) buy_value: None, # Buying Value (int) buy_fee: None, # Buying Fee (int) buy_settlement: None, # Buying Payable / Receivable Amount (int) buy_tax: None, # Buying Tax (int) sell_value: None, # Selling Value (int) sell_fee: None, # Selling Fee (int) sell_settlement: None, # Selling Payable / Receivable Amount (int) sell_tax: None, # Selling Tax (int) total_bs_value: None, # Total Buying & Selling Value (int) total_fee: None, # Total Fee (int) total_tax: None, # Total Tax (int) total_settlement_amount: None, # Total Payable & Receivable Amount (int) currency: None, # Currency (string) } ] } } ``` --- ### Realized Gains and Loses(Detail) realized\_gains\_and\_loses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Realized list is returned | | message | string | is\_success = False error description is returned | ##### Realized Example[​](#realized-example "Direct link to Realized Example") Return type : Object | Parameter | Type | Meaning | | ---------------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | | date | string | Data date | | branch\_no | string | Branch number | | account | string | Account | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | filled\_qty | int | Filled quantity | | filled\_price | float | Filled price | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` Security Landing | | realized\_profit | int | Realized profit | | realized\_loss | int | Realized loss | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.realized_gains_and_loses(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : Realized{ date: "2023/10/17", # Data date (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell type (BSAction) filled_qty: 1000, # Filled quantity (int) filled_price: 35.0, # Filled price (float) order_type: Stock, # Order type (OrderType) realized_profit: 0, # Realized profit (int) realized_loss: 203 # Realized loss (int) } } ``` --- ### Realized Gains and Loses Summary realized\_gains\_and\_loses\_summary #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | RealizedSummary list is returned | | message | string | is\_success = False error description is returned | ##### RealizedSummary Parameter[​](#realizedsummary-parameter "Direct link to RealizedSummary Parameter") Return type : Object | Parameter | Type | Meaning | | --------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | start\_date | string | Query start date | | end\_date | string | Query end date | | branch\_no | string | Branch number | | account | string | Account | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、`SBL` Security Landing | | filled\_qty | int | Filled quantity | | filled\_avg\_price | float | Filled average price | | realized\_profit\_and\_loss | int | Realized profit and loss | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.realized_gains_and_loses_summary(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ RealizedSummary{ start_date: "20231011", # Query start date (string) end_date: "20231011", # Query end date (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) stock_no: "1101", # Symbol (string) buy_sell: Buy, # Buy/Sell type (BSAction) order_type: Stock, # Order Type (int) filled_qty: 1000, # Filled quantity (int) filled_avg_price: 35.0, # Filled average price (float) realized_profit_and_loss: -203 # Realized profit and loss (int) }, ... ] } ``` --- ### Unrealized Gains and Loses unrealized\_gains\_and\_loses #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | UnrealizedData list is returned | | message | string | is\_success = False error description is returned | ##### UnrealizedData Parameter[​](#unrealizeddata-parameter "Direct link to UnrealizedData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | date | string | Date of inquiry | | branch\_no | string | Branch number | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` (**Note**. Please refer to the infomation block below the table) | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` Security Landing | | cost\_price | float | Hoding price | | tradable\_qty | int | Available quantity | | today\_qty | int | Today Share balacne | | unrealized\_profit | int | Unrealized profit | | unrealized\_loss | int | Unrealized loss | info For spot trades, buy\_sell is always `Buy` and quantity could be positive or negative to denote the net position. For margin trades,buy\_sell could be `Buy` or `Sell` depends on the trade direction. #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.accounting.unrealized_gains_and_loses(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ UnrealizedData{ date: "2021/08/09", # Date of inquiry (string) account: "26", # Account (string) branch_no: "6460", # Branch number (string) stock_no: "2303", # Symbol (string) buy_sell: Buy, # Buy/Sell type (BSAction) order_type: Margin, # Order type (OrderType) cost_price: 50.0, # Cost price (float) tradable_qty: 1000, # Tradable quantity (int) today_qty: 1000, # Today's balance (int) unrealized_profit: 48650, # Unrealized profit (int) unrealized_loss: 0 # Unrealized loss (int) }, ... ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | -------------------- | ----------- | --------------------------------------------------------------------------------------------------- | | buy\_sell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | price | string | Order Price (use ***None*** if priceType is not `Limit`) | | quantity | int | Order Quantity | | market\_type | MarketType | [Trading Session](#markettype) valid in `Common`、`Fixing`、`IntradayOdd`、`Odd`、`Emg` 、 `EmgOdd` | | price\_type | PriceType | [Price Type](#pricetype) valid in `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | order\_type | OrderType | [Order Type](#ordertype) valid in `Stock`、`Margin`、`Short`、`DayTrade`、 `SBL` | | user\_def (optional) | string | Customer Field (Up to 10 characters, no special characters supported、Not applicable to Emg) | caution The units and ranges for 'quantity' vary for different MarketTypes. Please refer to the [market\_type](#markettype) description for details caution When market\_type is one of MarketType.Common, MarketType.Odd, MarketType.IntradayOdd, MarketType.Emg, and priceType is PriceType.Limit, the 'price' field must be filled; otherwise, the 'price' field should be empty or None Spot Short Selling When spot short selling common stocks, orderType should be DayTrade, buySell is Sell, and marketType is Commonn
(For other spot day-trading operations, orderType = Stock) ##### OrderResult[​](#orderresult "Direct link to OrderResult") OrderResult; You can use [get\_order\_result(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/trade/GetOrderResults.md) to get data. | Parameter | Type | Meaning | | ------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | MarketType | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | PriceType | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | TimeInForce | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | PriceType | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time (see below for the format) | | error\_message | string | Error Message | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | >> function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modified\_time | string | Order Modified Time (see below for the format) | | >> before\_qty | int | Original Order Quantity | | >> after\_qty | int | Valid Order Quantity (filled quantity included) | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> status | int | Order Status | | >> err\_msg | string | Error Message | Time Format last\_time and modified\_time format: **HH:MM:SS.fff** or **HH:MM:SS** (that is, if .fff = .000, .fff will be ommitted). ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult; You can use [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/trade/batchOrder/BatchOrderList.md) to get data. | Parameter | Type | Meaning | | -------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Date | | branch\_no | string | Branch Number | | account | string | Account | | batch\_seq\_no | string | Batch Serial Number | ##### ModifyPriceObj[​](#modifypriceobj "Direct link to ModifyPriceObj") Modified Price Object | Parameter | Type | Meaning | | ----------- | --------- | ------------------------------------------------------------------------------------------ | | OrderResult | Object | [OrderResult](#orderresult) | | price | string | The price after modification | | Price\_type | PriceType | The price type after modification : `Limit`、`LimitUp`、`LimitDown`、`Market`、`Reference` | About Price Type The Co-lo version **has** enabled the use of PriceType. ##### ModifyQuantityObj[​](#modifyquantityobj "Direct link to ModifyQuantityObj") Modified Quantity Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------- | | OrderResult | Object | [OrderResult](#orderresult) | | quantity | int | The quantity after modification | ##### FilledData[​](#filleddata "Direct link to FilledData") Filled Data Object | Parameter | Type | Meaning | | ------------------ | --------- | ------------------------------------------------------------------ | | date | string | Filled Date | | branch\_no | string | Branch Number | | account | string | Account | | seq\_no | string | Order Serial Number (only display on filled callback) | | order\_no | string | Order Number | | stock\_no | string | Symbol | | buy\_sell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | order\_type | OrderType | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | filled\_no | string | Filled Serial Number | | filled\_avg\_price | float | Filled Average Price | | filled\_qty | int | Filled Share | | filled\_price | float | Filled Price | | filled\_time | string | Filled Time | | user\_def | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ------------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branch\_no | string | Branch Number | | account\_type | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### MarketType[​](#markettype "Direct link to MarketType") Trading Session Type | Name | Meaning | | ----------- | ----------------------------------- | | Common | Regular Session | | Fixing | Fixing Session | | IntradayOdd | Intraday Odd Lot | | Odd | Odd | | Emg | Emerging Stock Market | | EmgOdd | Emerging Stock Market (share Unit ) | When using different MarketTypes, the corresponding units and ranges represented by Quantity may also vary. Details are as follows | Name | Quantity Unit | Quantity Ranges | | ----------- | --------------- | ------------------------------------------------------------------ | | Common | Thousand Shares | 1000 ~ 499000 | | Fixing | Thousand Shares | 1000 ~ 499000 | | IntradayOdd | Share | 1 ~ 999 | | Odd | Share | 1 ~ 999 | | Emg | Share | 1 ~ 999 ; 1000 ~ 499000 (Over 1000 ,minimum tick size is 1000) | When using different MarketTypes, the available PriceType and TimeInForce as below. | 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") Price Type | Name | Meaning | | --------- | ------------------------------------------------ | | Limit | Limit | | LimitUp | Limit Up | | LimitDown | Limit Down | | Market | Market | | Reference | Reference Price (Fixing Price at Fixing Session) | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### OrderType[​](#ordertype "Direct link to OrderType") Order Type | Name | Meaning | | -------- | -------------------------------------- | | Stock | Common Stock | | Margin | Margin | | Short | Margin Short Selling | | DayTrade | Spot Short Selling (day trading) | | SBL | Short Selling (with security borrowed) | ##### StockType[​](#stocktype "Direct link to StockType") Stock Category | Name | Meaning | | ------------- | ---------------- | | Stock | Common Stock | | ConvertBond | Convertible Bond | | ETF\_and\_ETN | ETF and ETN | ##### function\_type[​](#function_type "Direct link to function_type") Function Type | Name | Value | | -------------------------------------- | ----- | | New Order | 0 | | New Order Executed | 10 | | Change Price | 15 | | Change Quantity | 20 | | Cancel Order | 30 | | Fully Filled (for OrderResult details) | 50 | | Order Failed | 90 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | ----------------------------- | ------- | | Listed stocks | TAIEX | | Over-the-Counter (OTC) stocks | TAISDAQ | | Emerging Stock | TAIEMG | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | Reservation | 0 | | Sending to the system backend | 4 (Using GetOrderResult to retrieve the latest status) | | Processing by the backend | 8 (Using GetOrderResult to retrieve the latest status) | | Timeout | 9 (Please wait a moment and use GetOrderResult to retrieve the latest status ; or contact your broker agent) | | Active order | 10 | | Canceled | 30 | | Partially filled, others canceled | 40 | | Fully filled | 50 | | Order not valid | 90 | | Flags for order result details | 14 - ACK of modifing price、24 - ACK of modifing quantity、34 - ACK of canceling | | Modify price successfully (for history order inquiry) | 15 | | Modify quantity successfully (for history order inquiry) | 20 | | Fail to modify order price (for callback) | 19 | | Fail to modify order quantity (for callback) | 29 | | Fail to cancel (for callback) | 39 | --- ### API Key Login apikey\_login Version Info. Available since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ------ | ---------------------- | | personal\_id | String | Login ID | | Key | String | API Key | | cert\_path | String | Certification Path | | cert\_pass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Account list is returned | | message | string | is\_success = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ------------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branch\_no | String | Branch Number | | account\_type | String | Account Type: value in `stock` and `futopt` | ##### Reqeust Example[​](#reqeust-example "Direct link to Reqeust Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.apikey_login("Your ID", "API Key","Your Cert Path","Your Cert Password") print(accounts) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : Account{ name: "富邦Bill", # Account Name (string) account: "28", # Account Number (string) branch_no: "6460", # Branch Number (string) account_type: "stock" # Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ------ | ---------------------- | | personal\_id | String | Login ID | | password | String | Login Password | | cert\_path | String | Certification Path | | cert\_pass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Account list is returned | | message | string | is\_success = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ------------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branch\_no | String | Branch Number | | account\_type | String | Account Type: value in `stock` and `futopt` | ##### Reqeust Example[​](#reqeust-example "Direct link to Reqeust Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password","Your Cert Path","Your Cert Password") print(accounts) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : Account{ name: "富邦Bill", # Account Name (string) account: "28", # Account Number (string) branch_no: "6460", # Branch Number (string) account_type: "stock" # Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ---- | ---------------- | | is\_success | bool | Interface result | #### Request Example[​](#request-example "Direct link to Request Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() sdk.logout() ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py True ``` --- ### Batch Cancel Order batch\_cancel\_Order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | cancel\_object | [orderResults(List)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) (list of object) | The object list for cancel | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch Cancel( Using the content returned by batch detail ) cancel_object = [ batch_results_detail.data[0], batch_results_detail.data[1], ] sdk.stock.batch_cancel_order(account, cancel_object) # Batch Cancel ( Using different individual orders ) cancel_object = [ orders.data[37], orders.data[35], ] sdk.stock.batch_cancel_order(account, cancel_object) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ OrderResult{ # Batch Cancel( Using the content returned by batch detail ) function_type: 30, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000308998", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0028", # Order Number (string) asset_type: 0, # Asset Type: `0` Stock (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 30, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.2, # Valid Order Price (float) unit: 1000, # Unit (int) after_qty: 0, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 5000, # Before the Quantity Modification (int) before_price: 41.2, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "16:53:57.536", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, OrderResult{ function_type: 30, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "0000030899", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0029", # Order Number (string) asset_type: 0, # Asset Type: `0` Stock (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (string) is_pre_order: False, # Reservation Order Flag (bool) status: 30, # Order Status (int) ... }] } Below example only extract data content [OrderResult({ # Batch Cancel ( Using different individual orders ) function_type: 30, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000307789", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0033", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInforce) order_type: Stock, # Order Type (string) is_pre_order: False, # Reservation Order Flag (bool) status: 30, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.2, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 0, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 5000, # Before the Quantity Modification (int) before_price: 41.2, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "16:53:58.536", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }), OrderResult({ function_type: 30, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000307785", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0031", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInforce) order_type: Stock, # Order Type (string) is_pre_order: False, # Reservation Order Flag (bool) status: 30, # Order Status (int) ... })] ``` --- ### Batch Modify Price batch\_modify\_price ##### First, using 'make\_modify\_price\_obj' create a 'make\_modify\_price\_obj' object[​](#first-using-make_modify_price_obj-create-a-make_modify_price_obj-object "Direct link to First, using 'make_modify_price_obj' create a 'make_modify_price_obj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | order | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string | The price after modification | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or None ; otherwise, the 'price' field should be empty or None Put the returned object into the 'modify\_price' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------- | | account | Account | Account | | orders | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#modifypriceobj) (list of object) | The object for price modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch price modification ( modifying orders using the content returned by batch detail ) modify_objects = [ sdk.stock.make_modify_price_obj(batch_results_detail.data[0], "41.1"), sdk.stock.make_modify_price_obj(batch_results_detail.data[1], "41.2"), ] sdk.stock.batch_modify_price(target_user, modify_objects) # Batch price modification ( Using different individual orders ) modify_objects = [ sdk.stock.make_modify_price_obj(orders.data[37], "41.1"), sdk.stock.make_modify_price_obj(orders.data[35], "41.2"), ] sdk.stock.batch_modify_price(target_user, modify_objects) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data :[ OrderResult{ # Batch price modification ( modifying orders using the content returned by batch detail ) function_type: 15, # Function Type (int) date: "2023/11/22", # Transaction Date (string) seq_no: "00000322356", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0018", # Order Number (string) asset_type: 0, # Asset Type: `0` Stock (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Order Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.1, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: None, # Before the Quantity Modification (int) before_price: 41.3, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "13:56:57.713", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, OrderResult{ function_type: 15, # Function Type (int) date: "2023/11/22", # Transaction Date (string) seq_no: "00000322355", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0017", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Order Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) }] } Below example only extract data content [OrderResult({ # Batch price modification ( Using different individual orders ) function_type: 15, # Function Type (int) date: "2023/11/22", # Transaction Date (string) seq_no: "00000322388", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: x0033, # Order Number (string) asset_type: 0, # Asset Type (int) market: TAIEX, # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: 1101, # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Order Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.1, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: None, # Before the Quantity Modification (int) before_price: 41.3, # Before the Price Modification (float) user_def: 12345678, # Custom Fields (string) last_time: "10:56:57.713", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }), OrderResult({ function_type: 15, # Function Type (int) date: "2023/11/22", # Transaction Date (string) seq_no: "00000322386", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: x0031, # Order Number (string) asset_type: 0, # Asset Type (int) market: TAIEX, # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: 1101, # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Order Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) ... })] ``` --- ### Batch Modify Quantity batch\_modify\_quantity ##### First, using 'make\_modify\_quantity\_obj' create a 'ModifyQuantityObj' object[​](#first-using-make_modify_quantity_obj-create-a-modifyquantityobj-object "Direct link to First, using 'make_modify_quantity_obj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | order | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) | The intended order result object to be modified | | quantity | int | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | Put the returned object into the 'modify\_quantity' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | account | Account | Account | | orders | [ModifyQtyObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#modifyquantityobj) (list of object ) | The object for Quantity modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch quantity modification ( modifying orders using the content returned by batch detail ) modify_objects = [ sdk.stock.make_modify_quantity_obj(batch_results_detail.data[0], 1000), sdk.stock.make_modify_quantity_obj(batch_results_detail.data[1], 1000), ] sdk.stock.batch_modify_quantity(target_user, modify_objects) # Batch quantity modification ( Using different individual orders ) modify_objects = [ sdk.stock.make_modify_quantity_obj(orders.data[37], 1000), sdk.stock.make_modify_quantity_obj(orders.data[35], 1000), ] sdk.stock.batch_modify_quantity(target_user, modify_objects) ``` ##### Response[​](#response "Direct link to Response") ```py Result { is_success: True, message: None, data :[ OrderResult{ # Batch quantity modification ( modifying orders using the content returned by batch detail ) function_type: 20, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000000042", # Order Serial Number (string) branch_no: "20112", # Branch Number (string) account: "26", # Account (string) order_no: x0026, # Order Number (string) asset_type: 0, # Asset Type (int) market: TAIEX, # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: 2881, # Symbol (string) buy_sell: Buy, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 66, # Price (float) quantity: 2000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInforce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: None, # Valid Order Price Type (PriceType) after_price: 66, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 1000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 2000, # Before the Quantity Modification (int) before_price: None, # Before the Price Modification (string) user_def: "batch 2", # Custom Fields (string) last_time: "12:21:51.023", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, OrderResult{ function_type: 20, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000000041", # Order Serial Number (string) branch_no: "20112", # Branch Number (string) account: "26", # Account (string) order_no: x0025, # Order Number (string) asset_type: 0, # Asset Type: Stock (int) market: TAIEX, # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: 2881, # Symbol (string) buy_sell: Buy, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 66, # Price (float) quantity: 2000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInforce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: None, # Valid Order Price Type (PriceType) after_price: 66, # Valid Order Price (float) ... }] } Below example only extract data content [OrderResult({ # Batch quantity modification ( Using different individual orders ) function_type: 20, # Function Type (int) date: "2024/03/08", # Transaction date (string) seq_no: "00000000043", # Order sequence number (string) branch_no: "20112", # Branch Number (string) account: "26", # Account number (string) order_no: "x0027", # Order number (string) asset_type: 0, # Asset type (int) market: "TAIEX", # Market type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2881", # Stock code (string) buy_sell: Buy, # Buy/sell type (BSAction) price_type: Limit, # Original order price type (PriceType) price: 66, # Price (float) quantity: 2000, # Original order quantity (int) time_in_force: ROD, # Time in force (TimeInForce) order_type: Stock, # Order type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order status (int) after_price_type: None, # Valid Order Price Type (PriceType) after_price: 66, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 1000, # Valid Order Quantity (int) filled_qty: 0, # Filled quantity (int) filled_money: 0, # Filled amount (int) before_qty: 2000, # Before the Quantity Modification (int) before_price: None, # Before the Price Modification (string) user_def: "Test", # Custom Fields (string) last_time: "12:21:53.023", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error message (string) }), OrderResult({ function_type: 20, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000000044", # Order Serial Number (string) branch_no: "20112", # Branch Number (string) account: "26", # Account (string) order_no: "x0028", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: 2881, # Symbol (string) buy_sell: Buy, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 66, # Order Price (float) quantity: 2000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) ... })] ``` --- ### Get Batch Order Detail batch\_order\_detail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | batch\_order\_list | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#batchresult) | Batch order list | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | OrderResult list is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```py batch_results = sdk.stock.batch_order_lists(account) sdk.stock.batch_order_detail(account, batch_results.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ OrderResult{ function_type: None, # Function Type (int) date: "2023/10/16", # Trading date (string) seq_no: "00000000005", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "bA632", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2888", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Order Price Type (PriceType) price: 8.9, # Order Price (float) quantity: 2000, # Order Quantity (int) time_in_force: ROD, # Time in Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: false, # Reservation mark (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 8.9, # Valid Order Price (float) unit: 1000, # Share Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 0, # Before the Quantity Modification (int) before_price: 8.9, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "09:31:25.174", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, OrderResult{ function_type: None, # Function Type (int) date: "2023/10/16", # Trading date (string) seq_no: "00000000005", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "bA631", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2888", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Order Price Type (PriceType) price: 8.9, # Order Price (float) quantity: 2000, # Order Quantity (int) time_in_force: ROD, # Time in Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: false, # Reservation mark (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 8.9, # Valid Order Price (float) unit: 1000, # Share Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 0, # Before the Quantity Modification (int) before_price: 8.9, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "09:31:25.101", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }] } ``` --- ### Get Batch Order List batch\_order\_lists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | BatchResult list is returned | | message | string | is\_success = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Query Date (today) | | branch\_no | string | Branch number | | account | string | Account | | batch\_seq\_no | string | Serial number | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.batch_order_lists(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ BatchResult{ function_type: 0, # Function Type (int) date: "2023/10/16", # Trading Date (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) batch_seq_no: "11EE6BC3B85670DE8000000C29304663" # Batch Order Serial Number (string) }, BatchResult{ function_type: 15, # Function Type (int) date: "2023/10/16", # Trading Date (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) batch_seq_no: "11EE6BC3E189F02A8000000C29304663" # Batch Order Serial Number (string) }, ... ] } ``` --- ### Place Batch Order batch\_place\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | Order\_object | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderobject) (list of object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | OrderResult list is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py orders = [ Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "batch 1" # optional field ), Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66.1", quantity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "batch 2" # optional field ) ] sdk.stock.batch_place_order(target_user, orders) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ OrderResult{ function_type: 0, # Function Type (int) date: "2023/10/16", # Trading Date (string) seq_no: "00000000011", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: None, # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2881", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Order Price Type (PriceType) price: 66, # Order Price (float) quantity: 2000, # Order Quantity (int) time_in_force: ROD, # Time in Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: false, # Reservation Mark (bool) status: 4, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 66, # Valid Order Price (float) unit: 1000, # Share Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 0, # Before the Quantity Modification (int) before_price: 66, # Before the Price Modification (float) user_def: "batch 1", # Custom Fields (string) last_time: "13:33:21.817", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, OrderResult{ function_type: 0, # Function Type (int) date: "2023/10/16", # Trading Date (string) seq_no: "00000000012", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: None, # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2881", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Order Price Type (PriceType) price: 66.1, # Order Price (float) quantity: 2000, # Order Quantity (int) time_in_force: ROD, # Time in Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: false, # Reservation Mark (bool) status: 4, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 66.1, # Valid Order Price (float) unit: 1000, # Share Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 0, # Before the Quantity Modification (int) before_price: 66.1, # Before the Price Modification (float) user_def: "batch 2", # Custom Fields (string) last_time: "13:33:21.817", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }] } ``` --- ### Cancel Order cancel\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | order\_result | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) | The intended order result object to be cancel | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type: Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.cancel_order(account, cancel_order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : OrderResult{ function_type: 30, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000308948", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0023", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInforce) order_type: "Stock", # Order Type (string) is_pre_order: False, # Reservation Order Flag (bool) status: 30, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.2, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 0, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 5000, # Before the Quantity Modification (int) before_price: 41.2, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "16:53:57.536", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Get Daytrade Quota and Precollect Information daytrade\_and\_stock\_info #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | stock\_no | string | Symbol | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | DayTradeStockInfo | DayTradeStockInfo is returned | | message | string | is\_success = False error description is returned | ##### DayTradeStockInfo Paramter[​](#daytradestockinfo-paramter "Direct link to DayTradeStockInfo Paramter") Return type: Object | Parameter | Type | Meaning | | ------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | stock\_no | string | Symbol | | date | string | Query Date | | daytrade\_orig\_quota | int | Original short daytrade quota | | daytrade\_tradable\_quota | int | Available short daytrade quota | | precollect\_single | int | Pre-collected for single order | | precollect\_accumulate | int | Pre-collected for accumulate order | | status | int | Status (bitmask sum) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | disposition\_status | string | Disposition Status `{ SETTYPE : 1}` : Full-Cash-Delivery、 `{ MARK-W : 1}` : Warning、`{ MARK-P : 1}` : Attention、`{ MARK-L : 1}` : Order Placement Restricted 【**New field for version >=2.2.5**】 | info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.daytrade_and_stock_info(account, "2330") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ DayTradeStockInfo{ stock_no: "2330", # Symbol (string) date: "2023/10/16", # Query Date (string) daytrade_orig_quota: 0, # Original short daytrade quota (int) daytrade_tradable_quota: 0, # Available short daytrade quota (int) precollect_single: None, # Precollect for single order (int) precollect_accumulate: None, # Precollect for accumulate order (int) status: 0, # Status (int) disposition_status: None # Disposition Status (string)【New field for version >=2.2.5】 }] } ``` --- ### Get Historical Filled filled\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query start date | | end\_date | string (optional) ( None or empty will equals start\_date) | Query end date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FilledData list is returned | | message | string | is\_success = False error description is returned | ##### FilledData Parameter[​](#filleddata-parameter "Direct link to FilledData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | date | string | Filled Date | | branch\_no | string | Branch number | | account | string | Account | | seq\_no | string | Order Serial Number (only display on filled callback) | | order\_no | string | Order number | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | filled\_no | string | Filled Transaction number | | filled\_avg\_price | float | Filled Average Price | | filled\_qty | int | Filled Share | | filled\_price | float | Filled Price | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | filled\_time | string | Filled Time | | user\_def | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.filled_history(account,"20230921","20230922") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data :[ FilledData{ date: "2023/09/15", # Filled Date (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) seq_no: None, # Order Serial Number (string) order_no: "bA422", # Order number (string) stock_no: "1101", # Symbol (string) buy_sell: 2, # Buy/Sell Type (int) filled_no: "00000000001", # Filled Transaction number (string) filled_avg_price: 35.2, # Filled Average Price (float) filled_qty: 1000, # Filled Share (int) filled_price: 35.2, # Filled Price (float) order_type: "Stock", # Order Type (string) filled_time: "10:31:00.931" # Filled Time (string) user_def: None # Custom Fields (string) }, ... ] } ``` --- ### Get Order Results get\_order\_results #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | OrderResult list is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_order_results(accounts.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ OrderResult{ function_type: None, # Function Type (int) date: "2023/10/16", # Trading date (string) seq_no: "00000000001", # Order serial number (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) order_no: "bA628", # Order number (string) asset_type: 0, # Asset type (int) market: "TAIEX", # Market category (string) market_type: Common, # Trading session type (MarketType) stock_no: "2888", # Symbol (string) buy_sell: Buy, # Transaction direction (BSAction) price_type: Limit, # Order price type (PriceType) price: 9.1, # Order price (float) quantity: 2000, # Order quantity (int) time_in_force: ROD, # Time in force (TimeInForce) order_type: Stock, # Order type (OrderType) is_pre_order: false, # Reservation flag (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (PriceType) after_price: 9.1, # Valid order price (float) unit: 1000, # Share unit (int) after_qty: 2000, # Valid order quantity (int) filled_qty: 0, # Filled quantity (int) filled_money: 0, # Filled value (int) before_qty: None, # Before the quantity modification (int) before_price: None, # Before the price modification (float) user_def: None, # Custom fields (string) last_time: "08:30:05.157", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) get\_order\_results\_detail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | OrderResult list is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | error\_message | string | Error Message | | details | list | Order Process | | >> function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modified\_time | string | Order Modified Time | | >> before\_qty | int | Original Order Quantity | | >> after\_qty | int | Valid Order Quantity (filled quantity included) | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> status | int | Order Status | | >> err\_msg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.get_order_results_detail(accounts.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ OrderResult{ function_type: None, # Function Type (int) date: "2023/10/16", # Trading date (string) seq_no: "00000000001", # Order serial number (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) order_no: "bA628", # Order number (string) asset_type: 0, # Asset type (int) market: "TAIEX", # Market category (string) market_type: Common, # Trading session type (MarketType) stock_no: "2888", # Symbol (string) buy_sell: Buy, # Transaction direction (BSAction) price_type: Limit, # Order price type (PriceType) price: 9.1, # Order price (float) quantity: 2000, # Order quantity (int) time_in_force: ROD, # Time in force (TimeInForce) order_type: Stock, # Order type (OrderType) is_pre_order: false, # Reservation flag (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (PriceType) after_price: 9.1, # Valid order price (float) unit: 1000, # Share unit (int) after_qty: 2000, # Valid order quantity (int) filled_qty: 0, # Filled quantity (int) filled_money: 0, # Filled value (int) before_qty: None, # Before the quantity modification (int) before_price: None, # Before the price modification (float) user_def: None, # Custom fields (string) last_time: "08:30:05.157", # Last modification time (string) error_message: None # Error Message (string) details:[ OrderDetail{ function_type: 10, # Function Type (int) modified_time: "08:30:05.157", # Order Modified Time (string) before_qty: 0, # Original Order Quantity (int) after_qty: 2000, # Valid Order Quantity (int) before_price: 9.1, # Original Order Price (float) after_price: 9.1 # Valid Order Price (float) status: 10, # Order status (int) err_msg: None # Error Message (string) } ] }, ... ] } ``` --- ### Get Margin Quota margin\_quota #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | stock\_no | string | Symbol | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ---------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | MarginShortQuota | MarginShortQuota is returned | | message | string | is\_success = False error description is returned | ##### MarginShortQuota Parameter[​](#marginshortquota-parameter "Direct link to MarginShortQuota Parameter") Return type : Object | Parameter | Type | Meaning | | -------------------------- | ------ | ---------------------------- | | stock\_no | string | Symbol | | date | string | Query date (today) | | shortsell\_orig\_quota | int | The original shortsell quota | | shortsell\_tradable\_quota | int | Available shortsell quota | | margin\_orig\_quota | int | The original margin quota | | margin\_tradable\_quota | int | Available margin quota | | margin\_ratio | int | Margin Ration | | short\_ratio | int | Short Sell Ration | info Explanation of Quota: If the margin\_ratio is None, it means funding is halted. If the short\_ratio is None, it means short selling is halted. Explanation of Returned Quota: 0 - No quota / Greater than 0 - Quota available / None - No restrictions / Both of ratio of and quota return 0 - margin or short selling halted. #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.margin_quota(account, "2330") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data: [ MarginShortQuota { stock_no: 2330, date: "2024/01/24", shortsell_orig_quota: 894, shortsell_tradable_quota: 894, margin_orig_quota: None, margin_tradable_quota: None, margin_ratio: 60, short_ratio: 90, }] } ``` --- ### Modify Order Price modify\_price ##### First, using 'make\_modify\_price\_obj' create a 'make\_modify\_price\_obj' object[​](#first-using-make_modify_price_obj-create-a-make_modify_price_obj-object "Direct link to First, using 'make_modify_price_obj' create a 'make_modify_price_obj' object") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | order | [OrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) | The intended order result object to be modified | | price | string | The price after modification | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | The price type after modification (***Note.***: The Co-lo version **has** enabled the use of PriceType.) | caution When 'price' is filled, priceType should be empty or None ; otherwise, the 'price' field should be empty or None Put the returned object into the 'modify\_price' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | order\_res | [ModifyPriceObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#modifypriceobj) | The object for price modification | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py modify_price_obj = sdk.stock.make_modify_price_obj(order_result, "41.1") sdk.stock.modify_price(account, modify_price_obj) ``` ##### Response[​](#response "Direct link to Response") ```py Result { is_success: True, message: None, data : OrderResult{ function_type: 15, # Function Type (int) date: "2023/11/22", # Transaction Date (string) seq_no: "00000308866", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0011", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.1, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 2000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: None, # Before the Quantity Modification (int) before_price: 41.3, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "13:56:57.713", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Modify Order Quantity modify\_quantity ##### First, using 'make\_modify\_quantity\_obj' create a 'ModifyQuantityObj' object[​](#first-using-make_modify_quantity_obj-create-a-modifyquantityobj-object "Direct link to First, using 'make_modify_quantity_obj' create a 'ModifyQuantityObj' object") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | | order | [orderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderresult) | The intended order result object to be modified | | quantity | int | The quantity after modification ( The modified quantity includes the partially filled portion of this order ) | Put the returned object into the 'modify\_quantity' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | account | Account | Account | | order\_res | [ModifyQtyObj](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#modifyquantityobj) | The object for Quantity modification | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | OrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py modify_qty_obj = sdk.stock.make_modify_quantity_obj(target_order, 1000) sdk.stock.modify_quantity(account, modify_qty_obj) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : OrderResult{ function_type: 20, # Function Type (int) date: "2024/03/08", # Transaction Date (string) seq_no: "00000308866", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "x0011", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Type(string) market_type: Common, # Trading Session Type (MarketType) stock_no: "1101", # Symbol (string) buy_sell: Sell, # Buy/Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 41.2, # Order Price (float) quantity: 5000, # Original Order Quantity (int) time_in_force: ROD, # Time In Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order Flag (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid Order Price Type (PriceType) after_price: 41.3, # Valid Order Price (float) unit: 1000, # Trading Unit (int) after_qty: 1000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: 3000, # Before the Quantity Modification (int) before_price: 41.2, # Before the Price Modification (float) user_def: "12345678", # Custom Fields (string) last_time: "13:56:28.966", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Get Historical Order order\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ----------------------------------------------------------------------------------------------- | ---------------- | | accounts | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query start date | | end\_date | string ( optional ) ( None or empty will equals start\_date ) | Query end date | info Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days. #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | OrderResult list is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | error\_message | string | Error Message | | details | list | Order Process | | >> function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `50` Fully Filled 、 `90` Failed | | >> modified\_time | string | Order Modified Time | | >> before\_qty | int | Original Order Quantity | | >> after\_qty | int | Valid Order Quantity (filled quantity included) | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> status | int | Order Status | | >> err\_msg | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.order_history(account,"20230921","20230922") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data : [ OrderResult{ function_type: None, # Function Type (int) date: "2023/09/21", # Trading Date (date) seq_no: "00000221427", # Order Serial Number (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) order_no: "bA489", # Order Number (string) asset_type: 0, # Asset Type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading Session Type (MarketType) stock_no: "2888", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Original Order Price Type (PriceType) price: 9.1, # Price (float) quantity: 1000, # Original Order Quantity (int) time_in_force: ROD, # Time in Force (TimeInForce) order_type: Stock, # Order Type (OrderType) is_pre_order: False, # Reservation Order (bool) status: 10, # Order Status (int) after_price_type: , # Valid Order Price Type (PriceType) after_price: 9.1, # Valid Order Price (float) unit: 1000, # Share Unit (int) after_qty: 1000, # Valid Order Quantity (int) filled_qty: 0, # Filled Quantity (int) filled_money: 0, # Filled Value (int) before_qty: , # Before the Quantity Modification (int) before_price: , # Before the Price Modification (float) user_def: , # Custom Fields (string) last_time: "09:00:32.477", # Last Modification Time (string) details:[ OrderDetail{ function_type: 10, # Function Type (int) modified_time: "09:00:32.477", # Order Modified Time (string) before_qty: 0, # Original Order Quantity (int) after_qty: 1000, # Valid Order Quantity (int) before_price: 9.1, # Original Order Price (float) after_price: 9.1 # Valid Order Price (float) } ] error_message: None # Error Message (string) }, ... #More Result Reponse ] } ``` --- ### PlaceOrder place\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | order\_object | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#orderobject) | Order Object | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | OrderResult | OrderResult is returned | | message | string | is\_success = False error description is returned | ##### OrderResult Parameter[​](#orderresult-parameter "Direct link to OrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New Order 、 `10` New Order Executed 、 `15` Change Price 、 `20` Change Quantity 、 `30` Cancel 、 `90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `0` Stock | | market | string | Market Type : `TAIEX` Listed 、 `TAISDAQ` OTC 、 `TAIEMG` EMG | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) | Trading Session Type : `Common` 、 `Fixing` 、 `IntradayOdd` 、 `Odd` 、 `Emg` 、 `EmgOdd` | | stock\_no | string | Symbol | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Original Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | price | float | Order Price | | quantity | int | Original Order Quantity | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [OrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#ordertype) | Order Type : `Stock` 、 `Margin` 、 `Short` 、 `DayTrade` 、 `SBL` | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status, for details please refer to [STATUS](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#status) | | after\_price\_type | [PriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#pricetype) | Valid Order Price Type : `Limit` 、 `LimitUp` 、 `LimitDown` 、 `Market` 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_qty | int | Valid Order Quantity (filled quantity included) | | filled\_qty | int | Filled Quantity | | filled\_money | int | Filled Value | | before\_qty | int | Before the Quantity Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quantity = 1000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force = TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" # optional field ) sdk.stock.place_order(account, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : OrderResult{ function_type: 0, # Function Type (int) date: "2023/10/12", # Trading Date (string) seq_no: "00000000007", # Order serial number (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) order_no: "bA676", # Order number (string) asset_type: 0, # Asset type (int) market: "TAIEX", # Market Category (string) market_type: Common, # Trading session type (MarketType) stock_no: "2881", # Symbol (string) buy_sell: Buy, # Buy / Sell Type (BSAction) price_type: Limit, # Order price type (int) price: 66, # Order Price (float) quantity: 1000, # Order quantity (int) time_in_force: 0, # Time in force (int) order_type: Stock, # Order Type (OrderType) is_pre_order: false, # Reservation flag (bool) status: 10, # Order Status (int) after_price_type: Limit, # Valid order price type (PriceType) after_price: 66, # Valid order price (float) unit: 1000, # Share Unit (int) after_qty: 2000, # Valid order quantity (int) filled_qty: 0, # Filled quantity (int) filled_money: 0, # Filled Value (int) before_qty: 0, # Before the quantity modification (int) before_price: 8.9, # Before the price modification (float) user_def: "From_Py", # Custom fields (string) last_time: "14:05:12.085", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Query Stock Quote Information (Single) query\_symbol\_quote info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Type | Description | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | symbol | String | Symbol | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | --------- | ----------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | SymbolQuote | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ------------------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | market | str | Market | | symbol | str | Symbol | | is\_tib\_or\_psb | bool | Whether it is TIB or PSB board | | market\_type | str | Market type | | status | int | Status (bitmask sum) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | reference\_price | float | Reference price | | unit | int | Trading unit | | update\_time | str | Update time | | limitup\_price | float | Upper price limit | | limitdown\_price | float | Lower price limit | | open\_price | float | Opening price | | high\_price | float | Highest price | | low\_price | float | Lowest price | | last\_price | float | Latest traded price | | total\_volume | int | Total traded volume | | total\_transaction | int | Total number of trades (Reserved field, not currently in use) | | total\_value | float | Total traded value | | last\_size | int | Latest traded volume | | last\_transaction | int | Latest number of trades (Reserved field, not currently in use) | | last\_value | float | Latest traded value | | bid\_price | float | Best bid price | | bid\_volume | int | Best bid volume | | ask\_price | float | Best ask price | | ask\_volume | int | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.stock.query_symbol_quote(accounts.data[0],"2330", MarketType.IntradayOdd ) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data: SymbolQuote { market: "TAIEX", # str - Market symbol: "2330", # str - Symbol is_tib_or_psb: False, # bool - Whether it is TIB or PSB board market_type: "IntradayOdd", # str - Market type status: 1, # int - Status (bitmask sum) reference_price: 780, # float - Reference price unit: 1, # int - Trading unit update_time: "09:09:55.741", # str - Update time limitup_price: 858, # float - Upper price limit limitdown_price: 702, # float - Lower price limit open_price: None, # float | None - Opening price high_price: None, # float | None - Highest price low_price: None, # float | None - Lowest price last_price: None, # float | None - Latest traded price total_volume: None, # int | None - Total traded volume total_transaction: 0, # int - Total number of trades (Reserved field, not currently in use) total_value: None, # float | None - Total traded value last_size: None, # int | None - Latest traded volume last_transaction: 0, # int - Latest number of trades (Reserved field, not currently in use) last_value: 0, # float - Latest traded value bid_price: 1140, # float - Best bid price bid_volume: 47975, # int - Best bid volume ask_price: 1145, # float - Best ask price ask_volume: 23024, # int - Best ask volume } } ``` --- ### Query Stock Quote Information (Batch) query\_symbol\_snapshot info For version >=2.2.5 #### Input Parameters[​](#input-parameters "Direct link to Input Parameters") | Parameter | Account | Description | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | market\_type | [MarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#markettype) (Optional)(default = Common) | Market type: supports `Common` (regular lot), `IntradayOdd` (odd lot during trading hours), `Fixing` (closing auction) | | stock\_type | List [StockType](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#stocktype) (Optional)(default = Stock) | Product category: `Stock` (stocks), `ConvertBond` (convertible bonds), `ETF_and_ETN` (ETFs and ETNs) | #### Result[​](#result "Direct link to Result") | Parameter | Type | Description | | --------- | ---------------------- | ------------------------------------ | | isSuccess | bool | Whether the request was successful | | data | SymbolSnapshotResponse | Returned quote information | | message | string | Error message when isSuccess = false | ##### Symbol Information (SymbolQuote Fields)[​](#symbol-information-symbolquote-fields "Direct link to Symbol Information (SymbolQuote Fields)") Return type : Object | Parameter | Type | Description | | ------------------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | market | str | Markets | | symbol | str | Symbol | | is\_tib\_or\_psb | bool | Whether it is TIB or PSB board | | market\_type | str | Market type | | status | int | Status (bitmask sum) 0 :All forbidden 、 1:Exempted from margin short selling price constraint、2: Exempted from SBL short selling price constraint、 4: Available sale after buy day trading 、 8: Available buy after sale day trading | | reference\_price | float | Reference price | | unit | int | Trading unit | | update\_time | str | Update time | | limitup\_price | float | Upper price limit | | limitdown\_price | float | Lower price limit | | open\_price | float | Opening price | | high\_price | float | Highest price | | low\_price | float | Lowest price | | last\_price | float | Latest traded price | | total\_volume | int | Total traded volume | | total\_transaction | int | Total number of trades (Reserved field, not currently in use) | | total\_value | float | Total traded value | | last\_size | int | Latest traded volume | | last\_transaction | int | Latest number of trades (Reserved field, not currently in use) | | last\_value | float | Latest traded value | | bid\_price | float | Best bid price | | bid\_volume | int | Best bid volume | | ask\_price | float | Best ask price | | ask\_volume | int | Best ask volume | Supported Products TAIEX and TAISDAQ securities info Status Example : if Status = 15 : It represnet there is no constraint for this symbol ,15 eqauls 1+2+4+8 break down; if Status = 12 ,it represnet 4 + 8 break down。 #### Request Example[​](#request-example "Direct link to Request Example") ```py from fubon_neo.constant import StockType sdk.stock.query_symbol_snapshot(accounts.data[0]) #Default sdk.stock.query_symbol_snapshot(accounts.data[0], MarketType.Common, [StockType.Stock]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data: SymbolSnapshotResponse { symbols: [ SymbolQuote { market: "TAIEX", # str - Market symbol: "2330", # str - Symbol is_tib_or_psb: False, # bool - Whether it is TIB or PSB board market_type: "IntradayOdd", # str - Market type status: 1, # int - Status (bitmask sum) reference_price: 780, # float - Reference price unit: 1, # int - Trading unit update_time: "09:09:55.741", # str - Update time limitup_price: 858, # float - Upper price limit limitdown_price: 702, # float - Lower price limit open_price: None, # float | None - Opening price high_price: None, # float | None - Highest price low_price: None, # float | None - Lowest price last_price: None, # float | None - Latest traded price total_volume: None, # int | None - Total traded volume total_transaction: 0, # int - Total number of trades (Reserved field, not currently in use) total_value: None, # float | None - Total traded value last_size: None, # int | None - Latest traded volume last_transaction: 0, # int - Latest number of trades (Reserved field, not currently in use) last_value: 0, # float - Latest traded value bid_price: 1140, # float - Best bid price bid_volume: 47975, # int - Best bid volume ask_price: 1145, # float - Best ask price ask_volume: 23024, # int - Best ask volume }, SymbolQuote{ market: "TAIEX", # str - Market ... }, ... ] } } ``` --- ### Preparation Key takeaways * Complete account setup, certificate, and API agreement before using the Fubon Neo API. * Run the connection test before development. * Next step: [Quick Start](https://www.fbs.com.tw/TradeAPI/en/docs/trading/quickstart.md) or [SDK Download](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md). | Item | Details | | ------------ | ----------------------------------------------------- | | Product | Fubon Neo API | | Requirements | Account, certificate, API agreement + connection test | | Platforms | Windows (certificate tool / connection test helper) | | Login | Certificate login (API Key optional) | | Next step | SDK install and quick start | caution Before starting with the Fubon Neo API, you must complete the following steps: 1. Have your Fubon Securities account ready. (If you don't already have a Fubon Securities account, please click the link: [Open Account](https://www.fubon.com/securities/open-now/) 2. Apply the digital certificate 3. Sign the API agreements: [Guide to Signing API Agreements and Connection Test](https://www.fbs.com.tw/wcm/new_web/operate_manual/operate_manual_01/API-SignSOP_guide.pdf) + Complete the connection test: [Connection Test Helper](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/API_Sign_Test.zip) (Windows) #### Get Started[​](#get-started "Direct link to Get Started") If you already have a Fubon Securities account, please skip this step. If you don’t have a Fubon Securities account, please [open an account now](https://www.fubon.com/securities/open-now/). ![Your Fubon Securities account](/TradeAPI/en/assets/images/prepare_account-792b5d9a17005ebde0e7d7050b37bb5c.png) #### Apply the Digital Certificate[​](#apply-the-digital-certificate "Direct link to Apply the Digital Certificate") Go to the [apply certificate](https://www.fbs.com.tw/Certificate/Management/) page and download the CATool. ![Certificate apply](/TradeAPI/en/assets/images/catool_down-7656be110b8cad6d84a981986dc1c34b.png) After logging in and completing the authentication, enter your mobile number or email to receive OTP code and complete the OTP verification. ![OTP](/TradeAPI/en/assets/images/ca_cover-3de617d54b6dfac697be7cae07ea3260.png) After completing the application, the certificate by default will be stored in the folder C:\CAFubon\\(Your ID Number). The certificate filename is (Your ID Number).pfx. ![CertLocation](/TradeAPI/en/assets/images/ca_repo-829d506640c176e4a8fc1b84c13b2908.png) #### Sign the API Agreements and Connection Test[​](#sign-the-api-agreements-and-connection-test "Direct link to Sign the API Agreements and Connection Test") ###### Sign the API Aggreements Online[​](#sign-the-api-aggreements-online "Direct link to Sign the API Aggreements Online") Follow the example provided in the link below
[Guide to Signing API Agreements and Connection Test](https://www.fbs.com.tw/wcm/new_web/operate_manual/operate_manual_01/API-SignSOP_guide.pdf) [![Sign the agreements online](/TradeAPI/en/assets/images/signSOP-6ed1317bfe2fb019c87930735dfc0f7d.png)](https://www.fbs.com.tw/wcm/new_web/operate_manual/operate_manual_01/API-SignSOP_guide.pdf) ###### Connection Test[​](#connection-test "Direct link to Connection Test") Use the [connection test helper](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/API_Sign_Test.zip) (for Windows), or directly use Fubon Neo API for connection and login. [![Connection Test Helper](/TradeAPI/en/assets/images/connection_test-e62eafe09e327f83f55844591ea812af.png)](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/API_Sign_Test.zip) #### Install the SDK package[​](#install-the-sdk-package "Direct link to Install the SDK package") * Python * Node.js * C# Use the following console command to install the SDK (please be advised that modify the .whl filename to the corresponding version downloaded). ```python pip install fubon_neo--cp37-abi3-win_amd64.whl ``` Support Python version 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported) First, create a folder named 'project' and initialize it using the following command: ```bash npm init ``` The file downloaded from the official website will be named fubon-neo-\.tgz, and place it in the folder you just created Add a line to the package.json file inside the Node.js project. ```json "dependencies": { ... "fubon-neo": "file:///fubon-neo-.tgz", ... } ``` Then enter the following command in the command line ```bash npm install ``` Node.js version 16 and above are supported the downloaded filename should look like this FubonNeo.\.nupkg for Visual Studio user, please refer to below tutorial. * Method 1 : Visual Studio Nuget Package Manager( **Using .NET 7 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click `Tools` -> `Nuget Package Manager` -> `Manage Nuget Packages for Solution` ![nugetpackage](/TradeAPI/en/assets/images/nugetpackage-d71a41371e06f457ac161917ba1a0af6.png) Next, select 1. Package source, select the package name you named in the previous step 2. Click Browse 3. Click Package 4. Select Project 5. Install Package ![nugetinstall](/TradeAPI/en/assets/images/nugetinstall-1cce8168b9c84304d8a20eaf103da69d.png) Finish ! You can using Fubon Neo SDK。 *** * Method 2 : Visual Studio Nuget Package Manager( **Using .NETFrame 4.7.2 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click On the right-hand side in Solution Explorer`Switch between solutions and available views` ( Or you can open it by going to the 'View' menu at the top) , After opening the folder, locate the .csproj file ![csprojadd](/TradeAPI/en/assets/images/csprojadd-884ccdbfb9631160aff1fabfc80d6f80.png) Inside the .csproj file, add an SDK reference (fill in the version according to the version number). ```xml ... ... ... ``` Click on the `.sln` file in File Explorer, right-click on the project name, and select Reload Project ![csprojimport](/TradeAPI/en/assets/images/csprojimport-a4dfc02aa766b2640c3b75692978f535.png) caution The current package only supports 64-bit. If your development environment is set to 32-bit by default, you can adjust it following the steps below: 1. Click on the top menu `Project` 2. Select `Project Properties` 3. Click on 'Build' on the left side, and change the platform target to x64 ![64bit](/TradeAPI/en/assets/images/64bit-b5e0de53211506491860e4f017fef7e9.png) *** * If you're not using Visual Studio NuGet Package Manager, you can use the Command Line as follows: You can add a new nuget.config file under the project folder: ```bash cd /Your Project path/ cd .>nuget.config #Create nuget.config ``` And copy and paste below content in the nuget.config ```xml ``` and then add sdk reference in the .csproj file (Vsesion base on downloaded package) ```xml ... ... ``` and then restore the project in the command line ```cs dotnet restore ``` C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. #### Start Your Program Trading Journey[​](#start-your-program-trading-journey "Direct link to Start Your Program Trading Journey") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction # Connect and login sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password", "Your cert path", "Your cert password") ## accounts = sdk.login("Your ID", "Your Password", "Your cert path") # If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions acc = accounts.data[0] # Create order object order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = "66", quamtity = 2000, market_type = MarketType.Common, price_type = PriceType.Limit, time_in_force= TimeInForce.ROD, order_type = OrderType.Stock, user_def = "From_Py" ) # Place an order order_res = sdk.stock.place_order(acc, order) print(order_res[0]) ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```python Result { is_success: True, message: None, data : { date: "2023/10/13", seq_no: "00000000015", branch_no: "6460", account: "26", order_no: "bA626", asset_type: 0, market: "TAIEX", market_type: Common, stock_no: "2881", buy_sell: Buy, price_type: Limit, price: 66.0, quantity: 2000, time_in_force: ROD, order_type: Stock, is_pre_order: false, status: 10, after_price_type: Limit, after_price: 66.0, unit: 1000, after_qty: 2000, filled_qty: 0, filled_money: 0, before_qty: 0, before_price: 66.0, user_def: "From_Py", last_time: "16:48:09.247", error_message: None} } ``` ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); // Connect and login const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your cert path", "Your cert password"); // const accounts = sdk.login("Your ID", "Your Password", "Your cert path"); // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions const acc = accounts.data[0]; // Create order object const order = { buySell: BSAction.Buy, symbol: 2881, price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.Limit, timeInForce: TimeInForce.ROD, orderType: OrderType.DayTrade, userDef: "from Js" }; // Place an order sdk.stock.placeOrder(acc, order); ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```js { isSuccess: true, data: { date : "2023/10/13", seqNo : "00000000016", branchNo : "6460", account : "26", orderNo : "bA627", assetType : 0, market : "TAIEX", marketType : "Common", stockNo : "2881", buySell : "Buy", priceType : "Limit", price : 66, "quantity" : 2000, timeInForce : "ROD", orderType : "DayTrade", isPreOrder : false, "status" : 10, afterPriceType : "Limit", afterPrice : 66, unit : 1000, afterQty : 2000, filledQty : 0, filledMoney : 0, beforeQty : 0, beforePrice : 66, userDef : "From JS", lastTime : "17:19:06.048" } } ``` ```cs using FubonNeo.Sdk; // Connect and login var sdk = new FubonSDK(); var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path", "Your cert password"); /* // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path"); */ var acc = acc_obj.data[0]; // Create order object var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.Limit, TimeInForce.ROD, OrderType.DayTrade, "From C#" ); // Place an order var order_res = sdk.Stock.PlaceOrder(acc, order); Console.WriteLine(order_res.data[0]); ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```cs { isSuccess = True, message = , data = OrderResult{date = 2023/10/13, seqNo = 00000000016, branchNo = 6460, account = 26, orderNo = bA627, assetType = 0, market = TAIEX, marketType = Common, stockNo = 2881, buySell = 1, priceType = Limit, price = 66, quantity = 2000, timeInForce = ROD, orderType = DayTrade, isPreOrder = False, status = 10, afterPriceType = Limit, afterPrice = 66, unit = 1000, afterQty = 2000, filledQty = 0, filledMoney = 0, beforeQty = 0, beforePrice = 66, userDef = From C#, lastTime = 17:19:06.048, errorMessage = } } ``` --- ### Quick Start Key takeaways * This page shows how to install the SDK and begin using the Fubon Neo API. * Complete [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md) before installation. * SDK packages are available on the [SDK download page](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md). | Item | Details | | ------------- | ------------------------------------------------------------------------------------------------------- | | Prerequisites | Preparation completed | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Package types | `.whl` / `.tgz` / `.nupkg` | | Next step | Run login and order examples | Please refer to the [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md) first and complete the application for the API Agreements and certificate download。 If you haven't installed the SDK package yet, you can download it from [SDK download page](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md). Once you have the SDK package and know the installation path, use the following command to install it:" #### Install Package[​](#install-package "Direct link to Install Package") * Python * Node.js * C# ```py pip install fubon_neo--cp37-abi3-win_amd64.whl ``` First, create a folder named 'project' and initialize it using the following command: ```bash npm init ``` The file downloaded from the official website will be named fubon-neo-\.tgz, and place it in the folder you just created Add a line to the package.json file inside the Node.js project. ```json "dependencies": { ... "fubon-neo": "file:///fubon-neo-.tgz", ... } ``` Then enter the following command in the command line ```bash npm install ``` Node.js version 16 and above are supported the downloaded file name should look like this FubonNeo.\.nupkg for Visual Studio user, please refer to below tutorial. * Method 1 : Visual Studio Nuget Package Manager( **Using .NET 7 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click `Tools` -> `Nuget Package Manager` -> `Manage Nuget Packages for Solution` ![nugetpackage](/TradeAPI/en/assets/images/nugetpackage-d71a41371e06f457ac161917ba1a0af6.png) Next, select 1. Package source, select the package name you named in the previous step 2. Click Browse 3. Click Package 4. Select Project 5. Install Package ![nugetinstall](/TradeAPI/en/assets/images/nugetinstall-1cce8168b9c84304d8a20eaf103da69d.png) Finish ! You can using Fubon Neo SDK。 *** * Method 2 : Visual Studio Nuget Package Manager( **Using .NETFrame 4.7.2 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click On the right-hand side in Solution Explorer`Switch between solutions and available views` ( Or you can open it by going to the 'View' menu at the top) , After opening the folder, locate the .csproj file ![csprojadd](/TradeAPI/en/assets/images/csprojadd-884ccdbfb9631160aff1fabfc80d6f80.png) Inside the .csproj file, add an SDK reference (fill in the version according to the version number). ```xml ... ... ... ``` Click on the `.sln` file in File Explorer, right-click on the project name, and select Reload Project ![csprojimport](/TradeAPI/en/assets/images/csprojimport-a4dfc02aa766b2640c3b75692978f535.png) caution The current package only supports 64-bit. If your development environment is set to 32-bit by default, you can adjust it following the steps below: 1. Click on the top menu `Project` 2. Select `Project Properties` 3. Click on 'Build' on the left side, and change the platform target to x64 ![64bit](/TradeAPI/en/assets/images/64bit-b5e0de53211506491860e4f017fef7e9.png) *** * If you're not using Visual Studio NuGet Package Manager, you can use the Command Line as follows: You can add a new nuget.config file under the project folder: ```bash cd /Your Project path/ cd .>nuget.config #Create nuget.config ``` And copy and paste below content in the nuget.config ```xml ``` and then add sdk reference in the .csproj file (Vsesion base on downloaded package) ```xml ... ... ``` and then restore the project in the command line ```cs dotnet restore ``` ##### And you should place the certificate in your folder structure like this: ```text . └── XXXXXXXXXX.pfx ``` ###### [​](#-1 "Direct link to -1") * Python * Node.js * C# f you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.py` file in your folder and paste the following content into it, then execute it:: ```python from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password") #If there are account groupings, multiple account information will be returned ## accounts = sdk.login("Your ID", "Your Password", "Your cert path") # If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions acc = accounts.data[0] ``` If you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.js` file in your folder and paste the following content into it, then execute it:: ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password"); // const accounts = sdk.login("Your ID", "Your Password", "Your cert path"); // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions const acc = accounts.data[0]; ``` If you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.cs` file in your folder and paste the following content into it, then execute it:: ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var accounts = sdk.Login("Your ID", "Your Password", "Your cert path" , "Your cert password"); // If there are account groupings, multiple account information will be returned /* // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path"); */ var acc = accounts.data[0]; ``` #### Send Order[​](#send-order "Direct link to Send Order") Next, add the following example code to demonstrate how to use the Fubon API to place a limit order to buy 1 board lot of Fubon Financial Holding Co., Ltd. (2881) at the fall stop price. * Python * Node.js * C# ```py order = Order( buy_sell = BSAction.Buy, symbol = "2881", price = None, quamtity = 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: 2881, price: "66", quantity: 2000, marketType: MarketType.Common, priceType: PriceType.LimitDown, timeInForce: TimeInForce.ROD, orderType: OrderType.Stock, userDef: "from Js" }; // sdk.stock.placeOrder(acc, order); ``` ```cs var order = new Order( BsAction.Buy, "2881", "66", 2000, MarketType.Common, PriceType.LimitDown, TimeInForce.Rod, OrderType.Stock, null ); sdk.Stock.PlaceOrder(acc ,order); ``` --- ### Rate Limit Key takeaways * This page lists connection and order rate limits for the Fubon Neo API. * Connection limit is 10; order and query limits are per second. * Exceeding limits returns error messages shown below. | Item | Limit | | --------------- | -------- | | Connections | 10 | | Orders | 50 / sec | | Batch orders | 10 / sec | | Account queries | 5 / sec | ##### Connection Limit[​](#connection-limit "Direct link to Connection Limit") | Behavior | Upper Limit | | ---------- | ----------- | | Connection | 10 | When the connection exceeds the limit, you will receive the following message during login: ```json Result { is_success: False, message: Login Error, 超過本應用程式連線限制==>[10] data: None } ``` | Behavior | Upper Limit per Second | | ---------------- | ---------------------- | | Order | 50 | | Batch Order | 10 | | Query Accounting | 5 | When the limit for the number of times is exceeded, you will receive the following message: ```json Result { is_success: False, message: Login Error, 業務系統流量控管 data: None } ``` --- ### Accounting *** We can query profit and loss information through trade and Position inquiries. info The limit of queries is 5 times / sec. If it exceeds the limit, please wait a moment and try again. #### Inventory[​](#inventory "Direct link to Inventory") * Python * Node.js * C# ```python hybrid = sdk.futopt_accounting.query_hybrid_position(accounts.data[0]) print(hybrid) ``` ```py Result { is_success: True, message: None, data :[ HybridPosition { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : False, # Spread Order Flag (bool) position_kind : 1, # Position Kind : `1` Future 、`2` Option (int) symbol : "FITX", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : None, # Strike Price (int or None) call_put : None, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 20325.3333, # Cost Price (float) orig_lots : 3, # Original Lot (int) tradable_lots : 3, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "20351", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 0.0, # Option market value (float) opt_long_value : 0.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : 0.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : None, # Spread Detail (List[SpreadPosition]) }, ... ] } ``` ```js const hybrid = sdk.futoptAccounting.queryHybridPosition(accounts.data[0]) console.log(hybrid) ``` ```js { isSuccess: true, data:[ { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: false, // Spread Order Flag (bool) positionKind: 1, // Position Kind : `1` Future 、`2` Option (number) symbol: "FITX", // Symbol (str) expiryDate: 202404, // Expiry Date (number) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 20325.3333, // Cost Price (number) origLots: 3, // Original Lot (number) tradableLots: 3, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "20351", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 0.0, // Option market value (number) optLongValue: 0.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: 0.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, ... ] } ``` ```cs var hybrid = sdk.FutOptAccounting.QueryHybridPosition(accounts.data[0]); foreach (var detail in hybrid.data) { Console.WriteLine(detail); } ``` ```cs { isSuccess = True, message = , data = [ HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = false, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double or null) callPut = , // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 20325.3333, // Cost Price (double) origLots = 3, // Original Lot (int) tradableLots = 3, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 20351, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 0.0, // Option market value (double) optLongValue = 0.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = 0.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = , // Spread Detail (List[SpreadPosition]) }, ] } ``` #### Equity information[​](#equity-information "Direct link to Equity information") You can inquire about Equity information to confirm the margin amount. * Python * Node.js * C# ```python equity = sdk.futopt_accounting.query_margin_equity(accounts.data[0]) print(equity.data) ``` ```js const equity = sdk.futoptAccounting.queryMarginEquity(accounts.data[0]) console.log(equity.data) ``` ```cs var equity = sdk.FutOptAccounting.QueryMarginEquity(accounts.data[0]); Console.WriteLine(equity.data); ``` * Python * Node.js * C# ```py Equity({ date: "2024/04/08", # Query Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) currency: "NTD", # Currency (string) yesterday_balance: 22435152.4, # Yesterday Balance (float) today_balance: 22434910.4, # Today's Balance (float) initial_margin: 1114946.0, # Initial Margin (float) maintenance_margin: 939214.0, # Maintenance Margin (float) clearing_margin: 915760.0, # Clearing Margin (float) today_equity: 22694910.4, # Today's Equity (float) ... withhold: 126402.0, # Withhold (float) available_margin: 21453562.4, # Available Margin (float) risk_index: 0.0, # Risk Index (float) disgorgement: 0.0, # Disgorgement (float) opt_pnl: -248600.0, # Option Profit or Loss (float) opt_value: -193100.0, # Option Market Value (float) opt_long_value: 311900.0, # Long Option Market Value (float) opt_short_value: 505000.0, # Short Option Market Value (float) fut_realized_pnl: 0.0, # Future Realized Profit or Loss (float) fut_unrealized_pnl: 60700.0, # Future Unrealized Profit or Loss (float) yesterday_equity: 22634452.4, # Yesterday Equity (float) buy_lot: 22, # Buying Lot (int) sell_lot: 7 # Selling Lot (int) }) ``` ```js { isSuccess: true, data:[ { date: '2024/04/08', // Query Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) currency: 'NTD', // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance: 22435152.4, // Yesterday Balance (number) todayBalance: 22434910.4, // Today's Balance (number) initialMargin: 1114946.0, // Initial Margin (number) maintenanceMargin: 939214.0, // Maintenace Margin (number) clearingMargin: 915760.0, // Clearing Margin (number) todayEquity: 22694910.4, // Today's Equity (number) ... withhold: 126402.0, // Withhold (number) availableMargin: 21453562.4, // Available Margin (number) riskIndex: 0.0, // Risk Index (number) disgorgement: 0.0, // Disgorgement (number) optPnl: -248600.0, // Option Profit or loss (number) optValue: -193100.0, // Option Market Value (number) optLongValue: 311900.0, // Long Option Market Value (number) optShortValue: 505000.0, // Short Option Market Value (number) futRealizedPnl: 0.0, // Future Realized Profit or Loss (number) futUnrealizedPnl: 60700.0, // Future Unrealized Profit or Loss (number) yesterdayEquity: 22634452.4, // Yesterday Equity (number) buyLot: 22, // Buying Lot (number) sellLot: 7 // Selling Lot (number) } ] } ``` ```cs { isSuccess = True, data = [ { date = 2024/04/08, // Query Date (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) currency = NTD, // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance = 22435152.4, // Yesterday Balance (double) todayBalance = 22434910.4, // Today's Balance (double) initialMargin = 1114946.0, // Initial Margin (double) maintenanceMargin = 939214.0, // Maintenace Margin (double) clearingMargin = 915760.0, // Clearing Margin (double) todayEquity = 22694910.4, // Today's Equity (double) ... withhold = 126402.0, // Withhold (double) availableMargin = 21453562.4, // Available Margin (double) riskIndex = 0.0, // Risk Index (double) disgorgement = 0.0, // Disgorgement (double) optPnl = -248600.0, // Option Profit or loss (double) optValue = -193100.0, // Option Market Value (double) optLongValue = 311900.0, // Long Option Market Value (double) optShortValue = 505000.0, // Short Option Market Value (double) futRealizedPnl = 0.0, // Future Realized Profit or Loss (double) futUnrealizedPnl = 60700.0, // Future Unrealized Profit or Loss (double) yesterdayEquity = 22634452.4, // Yesterday Equity (double) buyLot = 22, // Buying Lot (int) sellLot = 7 // Selling Lot (int) } ] } ``` --- ### Unblock Order First, let's begin by understanding the concepts of block and unblock. Block and Unblock are two different ways used to describe events, operations, or communication methods. Here are their basic concepts and distinction: ##### Block(阻塞):[​](#block阻塞 "Direct link to Block(阻塞):") Block operations refer to events or operations that occur in a predetermined sequence, and one operation must be completed before another can begin. Block is typically used in queue processing, where one task must wait for another to finish before it can proceed。 ![block](/TradeAPI/en/assets/images/normal_e-81f260e5278b74675bb38d33bd04514d.png) ##### Unblock(非阻塞):[​](#unblock非阻塞 "Direct link to Unblock(非阻塞):") Unblock operations refer to events or operations that do not have to occur in a fixed sequence and can be executed in parallel. One operation does not need to wait for the completion of another. Unblock processing is typically used in multi-tasking environments where unblock operations are needed to improve efficiency and performance. ![unblock](/TradeAPI/en/assets/images/async_e-578400269af66ffd8ed45da413266f23.png) ##### Using Block[​](#using-block "Direct link to Using Block") After placing the order, the Order Response received will contain the complete data, including fields such as the order number. * Python * Node.js * C# ```py #Create Order Object order = FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXFD4", price = "20000", lot = 1, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) sdk.stock.place_order(accounts.data[0], order) #Place Order #Or Using #sdk.stock.place_order(accounts.data[0], order, False) ``` ```js //Create Order Object const order = { buySell: BSAction.Buy, symbol: "TXFD4", price: "20100", lot: 1, marketType: FutOptMarketType.Future, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutureOrderType.Auto, userDef: "from Js" }; sdk.futopt.placeOrder(accounts.data[0], order); // Or Using //sdk.stock.placeOrder(accounts.data[0], order, false); ``` ```cs //Create Order Object var order = new FutOptOrder( BsAction.Buy, "TXFD4", null, null, "20000", 1, FutOptMarketType.Future, FutOptPriceType.Limit, TimeInForce.Rod, FutureOrderType.Auto, null ); sdk.Stock.PlaceOrder(accounts.data[0] ,order); // Block mode //Or Using //sdk.Stock.PlaceOrder(accounts.data[0] ,order, false); ``` ##### Using Unblock[​](#using-unblock "Direct link to Using Unblock") After placing the order, the Order Response received will not contain the complete data, such as the order number. * Python * Node.js * C# ```py #Create Order Object order = FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXFD4", price = "20000", lot = 1, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) sdk.futopt.place_order(accounts.data[0], order, True) #Place Order ``` ```js //Create Order Object const order = { buySell: BSAction.Buy, symbol: "TXFD4", price: "20100", lot: 1, marketType: FutOptMarketType.Future, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutureOrderType.Auto, userDef: "from Js" }; sdk.futopt.placeOrder(accounts.data[0], order, true); ``` ```cs //Create Order Object var order = new FutOptOrder( BsAction.Buy, "TXFD4", null, null, "20000", 1, FutOptMarketType.Future, FutOptPriceType.Limit, TimeInForce.Rod, FutureOrderType.Auto, null ); sdk.FutOpt.PlaceOrder(accounts.data[0] ,order, true); // Place Order with unblock mode ``` The following are functions that support Unblock orders: * PlaceOrder - Plcae Order * ModifyPrice - Modify Order Price * ModifyQuantity - Modify Order Quantity * CancelOrder - Cancel Order --- ### Python Callback Exception Handling When using Python callback functions, because they run in a separate thread, if an error occurs during the execution, the error message will not be automatically thrown back, which may cause obstacles in debugging. To resolve this, you can add the following decorator to the callback function. When an error occurs in the code, the error will be displayed in the console as usual: ```python import os import sys import traceback import functools def handle_exceptions(func): @functools.wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except Exception as exp: # Extract the full traceback tb_lines = traceback.format_exc().splitlines() # Find the index of the line related to the original function func_line_index = next((i for i, line in enumerate(tb_lines) if func.__name__ in line), -1) # Highlight the specific part in the traceback where the exception occurred relevant_tb = "\n".join(tb_lines[func_line_index:]) # Include traceback from the function name error_text = f"{func.__name__} exception: {exp}\nTraceback (most recent call last):\n{relevant_tb}" print(error_text, file=sys.stderr) # If you want to terminate the program completely, add the following line (P.S. Don't use with Jupyter) # os._exit(-1) return wrapper def on_event(code, content): print("===event=====") print(code) print(content) print("========") @handle_exceptions def on_order(code, content): print("==Order==") print(code) print(content) print("========") # Add some code that would cause exceptions test = {} print(test["key"]) # This will throw exception ``` In the above sample code, we deliberately put a line `print(test["key"])` in on\_order. Because `"key"` is not in the dictionary `test`, an error will occur. At this time, because we have added the `@handle_exceptions` decorator, after receiving a new order callback message, the console will print out: ```python on_order exception: 'key' Traceback (most recent call last): File "xxx.py", line 47, in on_order print(test["key"]) ~~~~^^^^^^^ KeyError: 'key' ``` --- ### Reconnect The following is a simple demonstration that automatically reconnects the trading socket when a disconnection event is detected using a callback: * Python * Node.js * C# ```py # A callback to receive event def on_event(code, content): print("===event=====") print(code) print(content) if code == "300": print("Reconnect") try: accounts = sdk.login("Your ID","Your password", "Your cert path", "Your cert password") print("Reconnect successs") except Exception as e: print("Reconnect failed") print(e) print("========") sdk.set_on_event(on_event) ``` ```js sdk.setOnEvent(function(order, content) { console.log("===Event===\n",order, content) if(content[0] == "300"){ console.log("Reconnect") try{ accounts = sdk.login("Your ID","Your password", "Your cert path", "Your cert password"); console.log("Reconnect success") }catch(e){ console.log("Reconnect Failed") } }}); ``` ```cs public class MyCallback : Callback { public string response = ""; private FubonSDK _sdk; public MyCallback(ref FubonSDK sdk) { _sdk = sdk; } public void OnEvent(string code, string data) { Console.WriteLine(code); Console.WriteLine(data); if (code == "300") { Console.WriteLine("Reconnect"); try { _sdk.Login("Your ID","Your password", "Your cert path", "Your cert password"); Console.WriteLine("Reconnect success"); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("Reconnect Failed"); } } } } var callback = new MyCallback(ref sdk); sdk.RegisterCallback(callback); ``` --- ### Event/Notification Callback *** #### Subscribe Order Callback[​](#subscribe-order-callback "Direct link to Subscribe Order Callback") * Python * Node.js * C# ```py # A callback to receive order data def on_order(code, content): print("==Order==") print(code) print(content) # print(content.seq_no) # Print the filled serial number print("========") sdk.set_on_futopt_order(on_order) ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) ```js //Callback to receive order data sdk.setOnFutoptOrder(function(code, content) { console.log("====order===\n",code, content)}); ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) ```cs public void OnFutoptOrder(string code, FutOptOrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine("On Order" + response); } } or Using Below Function sdk.OnFutoptOrder += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); } ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) #### Subscribe Amend / Cancel Callback[​](#subscribe-amend--cancel-callback "Direct link to Subscribe Amend / Cancel Callback") * Python * Node.js * C# ```py def on_order_changed(code, content): print("=Modified==") print(code) print(content) # print(content.seq_no) # Print the filled serial number print("========") sdk.set_on_order_futopt_changed(on_order_changed) ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) ```js //Callback to receive Modified data sdk.setOnFutoptOrderChanged(function(code, content) { console.log("===Modified===\n", code, content)}); ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) ```cs public void OnFutoptOrderChanged(string code, FutOptOrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Modified" + response); } } or Using Below function sdk.OnFutoptOrderChanged += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); } ``` info For detailed return content, please refer to the [FutOptOrderResult Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) #### Subscribe Filled Callback[​](#subscribe-filled-callback "Direct link to Subscribe Filled Callback") * Python * Node.js * C# ```py def on_filled(code, content): print("==Filled==") print(code) print(content) # print(content.filled_no) # Print the filled serial number print("========") sdk.set_on_futopt_filled(on_filled) ``` info For detailed return content, please refer to the [FutOptFilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptfilleddata) ```js sdk.setOnFutoptFilled(function(code, content) { console.log("===Filled===\n",code, content)}) ``` info For detailed return content, please refer to the [FutOptFilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptfilleddata) ```cs public void OnFutoptFilled(string code, FutOptFilledData data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Filled" + response); } } or Using Below function sdk.OnFutoptFilled += (code, FutOptFilledData) => { Console.WriteLine(code + FutOptFilledData.ToString()); } ``` info For detailed return content, please refer to the [FutOptFilledData Object](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptfilleddata) #### Subscribe Events Callback[​](#subscribe-events-callback "Direct link to Subscribe Events Callback") * Python * Node.js * C# ```py def on_event(code, content): print("===event=====") print(code) print(content) print("========") sdk.set_on_event(on_event) ``` ```js sdk.setOnEvent(function(code, content) { console.log("===Event===\n",code, content)}) ``` ```cs public void OnEvent(String code, String data) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Event" + response); } or Using Below Function sdk.OnEvent += (code, msg) => { Console.WriteLine(code + msg ); }; ``` Events Include Returns in the Following: | Code | Meaning | | ---- | --------------------------------------------- | | 100 | Connect | | 200 | Log in | | 201 | Login Warning ( Password change alert) | | 300 | Disconnect | | 301 | Pong Missing | | 302 | Manually disconnected | | 304 | API Key Revoked, Forced Logout (since v2.2.7) | | 500 | Error | #### Example[​](#example "Direct link to Example") Users can subscribe to different callbacks to receive order and filled notifications * Python * Node.js * C# ```py # A callback to receive order data def on_order(code, content): print("==Order==") print(code) print(content) print("========") sdk.set_on_futopt_order(on_order) # A callback to receive Modified data def on_order_changed(code, content): print("=Modified==") print(code) print(content) print("========") sdk.set_on_order_futopt_changed(on_order_changed) def on_filled(code, content): print("==Filled==") print(code) print(content) print("========") sdk.set_on_futopt_filled(on_filled) # A callback to receive Event data def on_event(code, content): print("===event=====") print(code) print(content) print("========") sdk.set_on_event(on_event) ``` info For detailed return content, please refer to the [SDK Reference](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) ```js //Callback to receive order data sdk.setOnFutoptOrder(function(code, content) { console.log("====order===\n",code, content)}); //Callback to receive Modified data sdk.setOnFutoptOrderChanged(function(code, content) { console.log("===Modified===\n", code, content)}); //Callback to receive Filled data sdk.setOnFutoptFilled(function(code, content) { console.log("===Filled===\n",code, content)}) //Callback to receive Event data sdk.setOnEvent(function(code, content) { console.log("===Event===\n",code, content)}) ``` info For detailed return content, please refer to the [SDK Reference](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) ```cs public class MyCallback : Callback { public string code =""; public string response = ""; //Callback to receive order data public void OnFutoptOrder(string code, FutOptOrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine("On Order" + response); } } //Callback to receive Modified data public void OnFutoptOrderChanged(string code, FutOptOrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Modified" + response); } } //Callback to receive Filled data public void OnFutoptFilled(string code, FutOptFilledData data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Filled" + response); } } public void OnOrder(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine("On Order" + response); } } //Callback to receive Modified data public void OnOrderChanged(string code, OrderResult data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Modified" + response); } } //Callback to receive Filled data public void OnFilled(string code, FilledData data) { if(data != null) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Filled" + response); } } //Callback to receive Event data public void OnEvent(String code,String data) { response = data.ToString(); Console.WriteLine(code); Console.WriteLine("Event" + response); } } var callback = new MyCallback(); sdk.RegisterCallback(callback); or Using Below Function sdk.OnEvent += (code, msg) => { Console.WriteLine(code + msg ); }; sdk.OnFutoptOrder += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); } sdk.OnFutoptOrderChanged += (code, FutOptOrderResult) => { Console.WriteLine(code + FutOptOrderResult.ToString()); } sdk.OnFutoptFilled += (code, FutOptFilledData) => { Console.WriteLine(code + FutOptFilledData.ToString()); } ``` info For detailed return content, please refer to the [SDK Reference](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) --- ### Trade *** This tutorial will demonstrate how to complete the entire buying and selling process #### Place Order[​](#place-order "Direct link to Place Order") We want to buy 2 lot of TXF at a point of 20000, you can execute program as the example * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, FutOptOrder from fubon_neo.constant import TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your password", "Your Cert Path", "Your Cert Password") #If there is consolidation, multiple account information will be returned #Create order object order = FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXFD4", price = "20000", lot = 2, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force= TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) sdk.futopt.place_order(accounts.data[0], order) #place order ``` ```js const { FubonSDK, BSAction, TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID","Your password", "Your cert path", "Your cert password"); const order = { buySell: BSAction.Buy, symbol: "2881", price: "66", lot: 2000, marketType: FutOptMarketType.Future, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "from Js" }; sdk.futopt.placeOrder(accounts.data[0],order); ``` ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var accounts = sdk.Login("Your ID","Your password", "Your cert path", "Your cert password"); // If there is consolidation, multiple account information will be returned var order = new FutOptOrder( BsAction.Buy, "TXFD4", null, // Spread Order Buy / Sell null, // Spread Order Symbol "20000", 1, FutOptMarketType.Future, FutOptPriceType.Limit, TimeInForce.ROD, FutOptOrderType.Auto, null ); sdk.FutOpt.PlaceOrder(accounts.data[0],order); // To place an block order ``` #### Confirm the order and trade notifications[​](#confirm-the-order-and-trade-notifications "Direct link to Confirm the order and trade notifications") If you want to confirm the status of that order, you can query the specified order using the example below: ( Need to specify the market type for the query. : Future, Option, FutureNight, OptionNight ) * Python * Node.js * C# ```python orderResults = sdk.futopt.get_order_results(accounts.data[0], FutOptMarketType.Future) print(orderResults) ``` ```js const orderResults = sdk.futopt.getOrderResults(accounts.data[0], FutOptMarketType.Future) console.log(orderResults) ``` ```cs var orderResults = sdk.FutOpt.GetOrderResults(accounts.data[0], FutOptMarketType.Future); foreach (var results in orderResults) { Console.WriteLine(results); } ``` Based on the result, we can determine whether this order has been executed and the lot that has been filled: * Python * Node.js * C# ```py [ { ... buy_sell: Buy, #Transaction direction. (BSAction) price: 20000, #The original order price (float) lot: 2, #The original order lot (int) after_price: 20000, #The Valid order price (float) after_lot: 2, #The Valid order lot (int) filled_lot: 0, #Filled lot (int) filled_money: 0, #Filled Vaule (float) symbol: "TXFD4", #symbol (string) order_no: "bA888", #The order number(string) last_time: "10:10:10.123", #The last modification time (string) ... } ] ``` ```json [ { ... "buySell": "Buy", //Transaction direction. (string) "price": 20000, //The original order price (number) "lot": 2, //The original order lot (number) "afterPrice": 20000, //The Valid order price (number) "afterLot": 2, //The Valid order lot (number) "filledLot": 0, //Filled lot (number) "filledMoney": 0, //Filled Vaule (number) "symbol": "TXFD4", //symbol (string) "orderNo": "bA888", //The order number (string) "lastTime": "10:10:10.123", //The last modification time (string) ... } ] ``` ```cs { ... buySell = Buy, // Transaction direction. (BsAction) price = 20000, //The original order price (double) lot = 2, //The original order lot (int) afterPrice = 20000, //The Valid order price (double) afterLot = 2, //The Valid order lot (int) filledLot = 0, //Filled lot (int) filledMoney = 0, //Filled Vaule (float) symbol = "TXFD4", //symbol (string) orderNo = "bA888", //The order number(string) lastTime = "10:10:10.123", //The last modification time (string) ... } ``` #### Modified order price[​](#modified-order-price "Direct link to Modified order price") Since the original price was unable to execute, we adjusted the original order price and changed it to 20100 for the purchase: * Python * Node.js * C# ```python orderResults = sdk.futopt.get_order_results(accounts.data[0], FutOptMarketType.Future) modified_pirce = sdk.futopt.make_modify_price_obj(orderResults.data[0],"20100") sdk.futopt.modify_price(accounts.data[0], modified_pirce) ``` ```js orderResults = sdk.futopt.getOrderResults(accounts.data[0]) const modified_pirce = sdk.futopt.makeModifyPriceObj(orderResults.data[0],"20100") sdk.futopt.modifyPrice(accounts.data[0],modified_pirce) ``` ```cs orderResults = sdk.FutOpt.GetOrderResults(accounts.data[0]); var modified_pirce = sdk.FutOpt.MakeModifyPriceObj(orderResults.data[0],"20100", null); sdk.FutOpt.ModifyPrice(accounts.data[0],modified_pirce); ``` "A few minutes later, we queried the order status again and found that it had been executed. * Python * Node.js * C# ```python orderResults = sdk.futopt.get_order_results(accounts.data[0], FutOptMarketType.Future) print(orderResults.data[0]) ``` ```py [ { ... buy_sell: Buy, # Transaction direction. (BSAction) price: 20000, #The original order price (number) lot: 2, #The original order lot (number) after_price: 20100, #The Valid order price (number) after_lot: 2, #The Valid order lot (number) filled_lot: 1, #Filled lot (number) filled_money: 20100, #Filled Vaule (number) symbol: "TXFD4", #symbol (string) order_no: "bA888", #The order number (string) last_time: "10:13:12.123", #The last modification time (string) ... } ] ``` ```js orderResults = sdk.futopt.getOrderResults(accounts.data[0], FutOptMarketType.Future) console.log(orderResults.data[0]) ``` ```json { ... "buySell" : "Buy", // Transaction direction. (BSAction) "price" : 20000, //The original order price (number) "lot" : 2, //The original order lot (number) "afterPrice" : 20100, //The Valid order price (number) "afterLot" : 2, //The Valid order lot (number) "filledLot" : 1, //Filled lot (number) "filledMoney" : 20100, //Filled Vaule (number) "symbol" : "TXFD4", //symbol (string) "orderNo" : "bA888", //The order number (string) "lastTime" : "10:13:12.123", //The last modification time (string) ... } ``` ```cs orderResults = sdk.FutOpt.GetOrderResults(accounts.data[0], FutOptMarketType.Future); Console.WriteLine(orderResults.data[0]); ``` ```cs { ... buySell = Buy, // Transaction direction. (BsAction) price = 20000, //The original order price (double) lot = 2, //The original order lot (int) afterPrice = 20100, //The Valid order price (double) afterLot = 2, //The Valid order lot (int) filledLot = 1, //Filled lot (int) filledMoney = 20100, //Filled Vaule (double) symbol = "TXFD4", //symbol (string) orderNo = "bA888", //The order number (string) lastTime = "10:13:12.123", //The last modification time (string) ... } ``` #### Sell Position[​](#sell-position "Direct link to Sell Position") Before the close, we decided to Sell 1 lot of TXF. * Python * Node.js * C# ```python #Create order object order = FutOptOrder( buy_sell = BSAction.Sell, symbol = "TXFD4", price = "20100", lot = 1, market_type = FutOptMarketType.Future, price_type = FuturePriceType.Limit, time_in_force= TimeInForce.ROD, order_type = FutureOrderType.Auto, user_def = "From_Py" # optional field ) sdk.futopt.place_order(accounts.data[0], order) #Place Order ``` ```js order = { buySell: BSAction.Sell, symbol: "TXFD4", price: "20100", lot: 1, marketType: FutOptMarketType.Future, priceType: FuturePriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutureOrderType.Auto, userDef: "from Js" }; sdk.futopt.placeOrder(accounts.data[0],order) ``` ```cs order = new FutOptOrder( BsAction.Sell, "TXFD4", null, null, "20100", 1, FutOptMarketType.Common, FutOptPriceType.Limit, TimeInForce.ROD, FutOptOrderType.Auto, null ); sdk.FutOpt.PlaceOrder(accounts.data[0],order); // To place an block order ``` --- ### Fubon Neo API *** Key takeaways * Overview of Fubon Neo API futures trading and market services. * Supports multiple languages and cross-platform development. * Next step: [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/prepare.md). | Item | Details | | --------- | ------------------------------------------------------------------------------------------------------- | | Product | Fubon Neo API | | Services | Futures Trading / Market Data | | Platforms | Windows / macOS / Linux | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Login | Certificate login (API Key optional) | #### Overview[​](#overview "Direct link to Overview") Fubon Neo API provides comprehensive trading and market APIs for your programmatic trading needs, catering to every developer's quantitative and automated trading requirements. Our API allows users to freely choose from mainstream programming languages (Python, C#, JavaScript) and easily access the API during the process of creating programmatic trades, utilizing trading and market services. #### Features[​](#features "Direct link to Features") Cross-platform support: Fubon Neo API supports Windows, MacOS, and Linux.
It also supports mainstream languages like Python, C#, and JavaScript. Stable technical architecture for direct connectivity to exchanges. Customizable market data solutions. #### Key Functions[​](#key-functions "Direct link to Key Functions") Direct trade management: Create orders, modify or cancel orders, and inquire about order status, as well as access historical order records and trade details。
View account information: Retrieve stock gains and losses, realized gains and losses, unrealized gains and losses, maintenance margin。 Receive real-time market data: Various market data information, including stock prices, warrants, options prices。 #### Version Support[​](#version-support "Direct link to Version Support") Python support: 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported).
Node.js Support : 16 and above.
C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. --- ### Query Close Position QueryClosePosition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | CloseRecord list is returned | | message | string | isSuccess = False error description is returned | ##### CloseRecord Parameter[​](#closerecord-parameter "Direct link to CloseRecord Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | date | string | Date | | branchNo | string | Branch Number | | positionKind | int | Position Kind : `1` Future 、`2` Option | | account | string | Account | | orderNo | string | Order Number | | market | string | Market Type : `TAIMEX` Future 、 Option | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell : `Buy` Buy、`Sell` Sell | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | price | double | Deal Price | | origLots | int | Original Lots | | transactionFee | double | Transaction Fee | | tax | double | Tax | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOptAccounting.ClosePositionRecord(accounts,"20240310","20240410")); ``` #### Request Example[​](#request-example-1 "Direct link to Request Example") ```cs { isSuccess = True, message = , data =[ CloseRecord { date = 2024/04/10, // Date (string) branch_no = 15000, // Branch Number (string) account = 9974825, // Account (string) position_kind = 1, // Position Kind = `1` Futures, `2` Options (int) order_no = 15001-0000, // Order Number (string) market = TAIMEX, // Market : `TAIMEX` Futures, Options (string) symbol = FITX, // Symbol (string) expiry_date = 202404, // Expiry Date (string) strike_price = None, // Strike Price (double) call_put = None, // Call/Put Type : `Call` Call, `Put` Put (int) buy_sell = Buy, // Buy/Sell Type : `Buy`, `Sell` (int) price = 20847.0, // Deal Price (double) orig_lots = 1, // Original Lots (int) transaction_fee = 40.0, // Transaction Fee (double) tax = 83.0, // Tax (double) }, CloseRecord { date = 2024/04/10, // Date (string) branch_no = 15000, // Branch Number (string) account = 9974825, // Account (string) position_kind = 1, // Position Kind : `1` Futures, `2` Options (int) order_no = C0005-0000, // Order Number (string) market = TAIMEX, // Market : `TAIMEX` Futures, Options (string) symbol = FITX, // Symbol (string) expiry_date = 202405, // Expiry Date (string) strike_price = None, // Strike Price (double) call_put = None, // Call/Put Type : `Call` Call, `Put` Put (int) buy_sell = Buy, // Buy/Sell Type : `Buy`, `Sell` (int) price = 20890.0, // Deal Price (double) orig_lots = 1, // Original Lots (int) transaction_fee = 40.0, // Transaction Fee (double) tax = 84.0, // Tax (double) }, ... ] } ``` --- ### Hybrid Position QueryHybridPosition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | HybridPosition list is returned | | message | string | isSuccess = False error description is returned | ##### HybridPosition Parameter[​](#hybridposition-parameter "Direct link to HybridPosition Parameter") Return type : Object | Parameter | Type | Meaning | | -------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | > date | string | Transaction Date | | > branchNo | string | Branch Number | | > account | string | Account | | > isSpread | bool | Spread Order Flag | | > positionKind | int | Position Kind : `1` Future 、`2` Option | | > symbol | string | Symbol | | > expiryDate | string | Expiry Date | | > strikePrice | double | Strike Price | | > callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | > buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | > price | double | Cost Price | | > origLots | int | Original Lot | | > tradableLots | int | Available Lot | | > orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | > currency | string | Currency | | > marketPrice | string | Market Price | | > initialMargin | double | Initial Margin | | > maintenanceMargin | double | Maintenance Margin | | > clearingMargin | double | Clearing Margin | | > optValue | double | Option market value | | > optLongValue | double | Long Option market value | | > optShortValue | double | Short Option market value | | > profitOrLoss | double | Profit or Loss | | > premium | double | Premium | | > spread | object | Spread Detail | | >> date | string | Transaction Date | | >> branchNo | string | Branch Number | | >> account | string | Account | | >> isSpread | bool | Spread Order Flag | | >> positionKind | int | Position Kind : `1` Future 、`2` Option | | >> symbol | string | Symbol | | >> expiryDate | int | Expiry Date | | >> strikePrice | double | Strike Price | | >> callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | >> buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | >> price | double | Cost Price | | >> origLots | int | Original Lot | | >> tradableLots | double | Available Lot | | >> orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | >> currency | string | Currency | | >> marketPrice | string | Market Price | | >> initialMargin | double | Initial Margin | | >> maintenanceMargin | double | Maintenance Margin | | >> clearingMargin | double | Clearing Margin | | >> optValue | double | Option market value | | >> optLongValue | double | Long Option market value | | >> optShortValue | double | Short Option market value | | >> profitOrLoss | double | Profit or Loss | | >> premium | double | Premium | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOptAccounting.QueryHybridPosition(account)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = false, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double or null) callPut = , // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 20325.3333, // Cost Price (double) origLots = 3, // Original Lot (int) tradableLots = 3, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 20351, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 0.0, // Option market value (double) optLongValue = 0.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = 0.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = , // Spread Detail (List[SpreadPosition]) }, HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = false, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TX1, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20600, // Strike Price (double) callPut = Call, // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 10, // Cost Price (int) origLots = 4, // Original Lot (int) tradableLots = 4, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 4.6, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 920.0, // Option market value (double) optLongValue = 920.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = -1080.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = , // Spread Detail (List[SpreadPosition]) }, HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = false, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 19800, // Strike Price (double) callPut = Call, // Call / Put : `Call` 、`Put` (CallPut) buySell = Sell, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 243, // Cost Price (int) origLots = 2, // Original Lot (int) tradableLots = 2, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 46, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 4600.0, // Option market value (double) optLongValue = 4600.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = -19700.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = , // Spread Detail (List[SpreadPosition]) }, HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = false, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20000, // Strike Price (double) callPut = Put, // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 344, // Cost Price (int) origLots = 2, // Original Lot (int) tradableLots = 2, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 82, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 8200.0, // Option market value (double) optLongValue = 8200.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = -26200.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = , // Spread Detail (List[SpreadPosition]) }, HybridPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) isSpread = true, // Spread Order Flag (bool) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TXO20100D4:20000P4, // Symbol (string) expiryDate = 1, // Expiry Date (string) strikePrice = 1, // Strike Price (double) callPut = , // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = , // Cost Price (int) origLots = 2, // Original Lot (int) tradableLots = 2, // Available Lot (int) orderType = New, // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 0.0, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 0.0, // Option market value (double) optLongValue = 0.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = 0.0, // Profit or Loss (double) premium = 0.0, // Premium (double) spreads = [ // Spread Detail (List[SpreadPosition]) SpreadPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20100, // Strike Price (double) callPut = Call, // Call / Put : `Call` 、`Put` (CallPut) buySell = Buy, // Buy/Sell Type : `Buy` 、`Sell` (BsAction) price = 185, // Cost Price (int) origLots = 2, // Original Lot (int) tradableLots = 2, // Available Lot (int) orderType = , // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 365, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0,// Initial Margin (double) optValue = 36500.0, // Option market value (double) optLongValue = 36500.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = 18000.0, // Profit or Loss (double) premium = 0.0, // Premium (double) }, SpreadPosition{ date = 2024/04/08, // Transaction Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) positionKind = 2, // Position Kind : `1` Future 、`2` Option (int) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20100, // Strike Price (double) callPut = Put, // Call / Put : `Call` 、`Put` (int) buySell = Buy, // Buy/Sell Type : `Buy`、`Sell` (BsAction) price = 0, // Cost Price (int) origLots = 2, // Original Lot (int) tradableLots = 2, // Available Lot (int) orderType = , // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 0.0, // Market Price (string) initialMargin = 0.0, // Initial Margin (double) maintenanceMargin = 0.0, // Maintenance Margin (double) clearingMargin = 0.0, // Clearing Margin (double) initialMarginAllSingle = 0.0, // Initial Margin (double) optValue = 0.0, // Option market value (double) optLongValue = 0.0, // Long Option market value (double) optShortValue = 0.0, // Short Option market value (double) profitOrLoss = 0.0, // Profit or Loss (double) premium = 0.0, // Premium (double) } ], } ] } ``` --- ### Query Equity QueryMarginEquity #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Equity | Equity is returned | | message | string | isSuccess = False error description is returned | ##### Equity Parameter[​](#equity-parameter "Direct link to Equity Parameter") Return type : Object | Parameter | Type | Meaning | | ----------------- | ------ | -------------------------------- | | date | string | Query Date | | branchNo | string | Branch double | | account | string | Account | | currency | string | Currency | | yesterdayBalance | double | Yesterday Balance | | todayBalance | double | Today's Balance | | initialMargin | double | Initial Margin | | maintenanceMargin | double | Maintenace Margin | | clearingMargin | double | Clearing Margin | | todayEquity | double | Today's Equity | | todayDeposit | double | Today's Deposit | | todayWithdrawal | double | Today's Withdrawal | | todayTradingFee | double | Today's Trading Fee | | todayTradingTax | double | Today's Trading Tax | | receivablePremium | double | Receivable Premium | | payablePremium | double | Payable Premium | | excessMargin | double | Excess Margin | | availableMargin | double | Available Margin | | disgorgement | double | Disgorgement | | optPnl | double | Option Profit or loss | | optValue | double | Option Market Value | | optLongValue | double | Long Option Market Value | | optShortValue | double | Short Option Market Value | | futRealizedPnl | double | Future Realized Profit or Loss | | futUnrealizedPnl | double | Future Unrealized Profit or Loss | | buyLot | int | Buying Lot | | sellLot | int | Selling Lot | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOptAccounting.QueryMarginEquity(target_user)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, data = [ { date = 2024/04/08, // Query Date (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) currency = NTD, // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance = 22435152.4, // Yesterday Balance (double) todayBalance = 22434910.4, // Today's Balance (double) initialMargin = 1114946.0, // Initial Margin (double) maintenanceMargin = 939214.0, // Maintenace Margin (double) clearingMargin = 915760.0, // Clearing Margin (double) todayEquity = 22694910.4, // Today's Equity (double) todayDeposit= 0.0, // Today's Deposit (double) todayWithdrawal= 2102.0, // Today's Withdrawal (double) todayTradingFee= 16.0, // Today's Trading Fee (double) todayTradingTax= 0.0, // Today's Trading Tax (double) receivablePremium= 0.0, // Receivable Premium (double) payablePremium= 9250.0, // Payable Premium (double) excessMargin= 28744525.0, // Excess Margin (double) availableMargin = 21453562.4, // Available Margin (double) disgorgement = 0.0, // Disgorgement (double) optPnl = -248600.0, // Option Profit or loss (double) optValue = -193100.0, // Option Market Value (double) optLongValue = 311900.0, // Long Option Market Value (double) optShortValue = 505000.0, // Short Option Market Value (double) futRealizedPnl = 0.0, // Future Realized Profit or Loss (double) futUnrealizedPnl = 60700.0, // Future Unrealized Profit or Loss (double) buyLot = 22, // Buying Lot (int) sellLot = 7 // Selling Lot (int) }, { date = 2024/04/08, // Query Date (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) currency = TWD, // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance = 19880310.0, // Yesterday Balance (double) todayBalance = 19880068.0, // Today's Balance (double) initialMargin = 1114946.0, // Initial Margin (double) maintenanceMargin = 939214.0, // Maintenace Margin (double) clearingMargin = 915760.0, // Clearing Margin (double) todayEquity = 20140068.0, // Today's Equity (double) todayDeposit= 0.0, // Today's Deposit (double) todayWithdrawal= 2102.0, // Today's Withdrawal (double) todayTradingFee= 16.0, // Today's Trading Fee (double) todayTradingTax= 0.0, // Today's Trading Tax (double) receivablePremium= 0.0, // Receivable Premium (double) payablePremium= 9250.0, // Payable Premium (double) excessMargin= 28744525.0, // Excess Margin (double) availableMargin = 18898720.0, // Available Margin (double) disgorgement = 0.0, // Disgorgement (double) optPnl = -248600.0, // Option Profit or loss (double) optValue = -193100.0, // Option Market Value (double) optLongValue = 311900.0, // Long Option Market Value (double) optShortValue = 505000.0, // Short Option Market Value (double) futRealizedPnl = 0.0, // Future Realized Profit or Loss (double) futUnrealizedPnl = 60700.0, // Future Unrealized Profit or Loss (double) buyLot = 22, // Buying Lot (int) sellLot = 7 // Selling Lot (int) } ] } ``` --- ### Query Single Position QuerySinglePosition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | -------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Position | Position is returned | | message | string | isSuccess = False error description is returned | ##### Position Parameter[​](#position-parameter "Direct link to Position Parameter") Return type : Object | Parameter | Type | Meaning | | ----------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | date | string | Transaction Date | | branchNo | string | Branch Number | | account | string | Account | | isSpread | bool | Spread Order Flag | | positionKind | int | Position Kind : `1` Future 、`2` Option | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | price | double | Cost Price | | origLots | int | Original Lot | | tradableLots | int | Available Lot | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | currency | string | Currency | | marketPrice | string | Market Price | | initialMargin | double | Initial Margin | | maintenanceMargin | double | Maintenance Margin | | clearingMargin | double | Clearing Margin | | optValue | double | Option market value | | optLongValue | double | Long Option market value | | optShortValue | double | Short Option market value | | profitOrLoss | double | Profit or Loss | | premium | double | Premium | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOptAccounting.QuerySinglePosition(target_user)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = [ Position{ dataDate = 2024/04/08, // Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l0001-0000, // Order Number (string) positionKind = 1, // Position Kind (int) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = null, // Strike Price (double) callPut = null, // Call/Put Type (CallPut) buySell = Buy, // Buy/Sell Type (BsAction) price = 20362, // Cost Price (double) origLots = 2, // Original Lot (int) tradableLot = 2, // Tradable Lot (int) orderType = 0, // Order Type (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 20521.0000, // Market Price (string) initialMargin = 358000.0, // Initial Margin (double) maintenanceMargin = 274000.0, // Maintenance Margin (double) clearingMargin = 264000.0, // Clearing Margin (double) profitOrLoss = 63600.0, // Profit or Loss (double) premium = 0.0, // Premium (double) }, Position{ dataDate = 2024/03/29, // Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l0007-0000, // Order Number (string) positionKind = 2, // Position Kind (int) symbol = TX1, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20600, // Strike Price (int) callPut = Call, // Call/Put Type (CallPut) buySell = Buy, // Buy/Sell Type (BsAction) price = 10, // Cost Price (double) origLots = 2, // Original Lot (int) tradableLot = 2, // Tradable Lot (int) orderType = New, // Order Type (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 4.6000, // Market Price (string) initialMargin = 52660.0, // Initial Margin (double) maintenanceMargin = 36460.0, // Maintenance Margin (double) clearingMargin = 34460.0, // Clearing Margin (double) profitOrLoss = -540.0, // Profit or Loss (double) premium = -1000.0, // Premium (double) }, Position{ dataDate = 2024/03/29, // Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l0007-0001, // Order Number (string) positionKind = 2, // Position Kind (int) symbol = TX1, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20600, // Strike Price (int) callPut = Call, // Call/Put Type (CallPut) buySell = Buy, // Buy/Sell Type (BsAction) price = 10, // Cost Price (double) origLots = 2, // Original Lot (int) tradableLot = 2, // Tradable Lot (int) orderType = New, // Order Type (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 4.6000, // Market Price (string) initialMargin = 52660.0, // Initial Margin (double) maintenanceMargin = 36460.0, // Maintenance Margin (double) clearingMargin = 34460.0, // Clearing Margin (double) profitOrLoss = -540.0, // Profit or Loss (double) premium = -1000.0, // Premium (double) }, Position{ dataDate = 2024/03/01, // Date (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l0002-0000, // Order Number (string) positionKind = 2, // Position Kind (int) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 18500, // Strike Price (int) callPut = Call, // Call/Put Type (CallPut) buySell = Sell, // Buy/Sell Type (BsAction) price = 625, // Cost Price (double) origLots = 5, // Original Lot (int) tradableLot = 4, // Tradable Lot (int) orderType = New, // Order Type (FutOptOrderType) currency = TWD, // Currency (string) marketPrice = 2020.0000, // Market Price (string) initialMargin = 584000.0, // Initial Margin (double) maintenanceMargin = 544000.0, // Maintenance Margin (double) clearingMargin = 536000.0, // Clearing Margin (double) profitOrLoss = -279000.0, // Profit or Loss (double) premium = 125000.0, // Premium (double) } ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | ------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------- | | buySell | BsAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | buySell2 (optional) | BsAction | Spread Order [Buy/Sell Type](#bsaction) | | symbol2 (optional) | string | Spread Order Symbol | | price | string | Order Price | | lot | int | Order Lot | | marketType | FutOptMarketType | [Trading Session](#futoptmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` | | priceType | FutOptPriceType | [Price Type](#futoptpricetype) valid in `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `Rod`、`Fok`、`Ioc` | | orderType | FutOptOrderType | [Order Type](#futoptordertype) valid in `New`、`Close`、`Auto` 、`FdayTrade` | | userDef (optional) | string | Customer Field (Up to 10 characters, no special characters supported) | ##### FutOptOrderResult[​](#futoptorderresult "Direct link to FutOptOrderResult") OrderResult,You can using [GetOrderResult(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/trade/GetOrderResults.md) get data. | Parameter | Type | Meaning | | --------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | int | Asset Type : `1` Future、 `2` Option | | market | string | Market Type : `TAIMEX` Future 、Option | | marketType | FutOptMarketType | Trading Session Type : `Future`、`Option`、`FutureNight`、`OptionNight` | | symbol | string | Symbol | | buySell | BsAction | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | FutOptPriceType | Original OPrder Price Type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original Order Lot | | timeInForce | TimeInForce | Time In Force : `Rod` 、 `Fok` 、 `Ioc` | | orderType | FutOptOrderType | Order Type : `New` 、 `Close` 、 `Auto` | | isPreOrder | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` InQueue、 `9` TimeOut 、 `10` New Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | FutOptPriceType | Valid Order Price Type :`Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid Order Price | | unit | int | Trading Unit | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | >> functionType | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeLot | int | Original Order Lot | | >> afterLot | int | Valid Order Lot | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> errorMessage | string | Error Message | ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult,You can using [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/csharp/trade/batchOrder/BatchOrderList.md) get data. | Parameter | Type | Meaning | | ------------ | ------ | ---------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | ##### FutOptModifyPrice[​](#futoptmodifyprice "Direct link to FutOptModifyPrice") Modified Price Object | Parameter | Type | Meaning | | ----------------- | --------------- | --------------------------------------------------------------------------------------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | price | double | The price after modification | | PriceType | FutOptPriceType | The price type after modification : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | ##### FutOptModifyLot[​](#futoptmodifylot "Direct link to FutOptModifyLot") Modified Lot Object | Parameter | Type | Meaning | | ----------------- | ------ | --------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | lot | int | The lot after modification | ##### FutOptFilledData[​](#futoptfilleddata "Direct link to FutOptFilledData") Filled Data Object | Parameter | Type | Meaning | | --------------- | -------- | ----------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | CallPut | Call / Put : `Call`、`Put` | | buySell | BsAction | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Spread Symbol | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | CallPut | Call / Put : `Call`、`Put` | | buySellLeg2 | BsAction | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | filledNo | string | Filled Serial Number | | filledAvgPrice | double | Filled Average Price | | filledLot | int | Filled Share | | filledPrice | double | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ----------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branchNo | string | Branch Number | | accountType | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### CallPut[​](#callput "Direct link to CallPut") Call / Put Type | Name | Meaning | | ---- | ------- | | Call | Call | | Put | Put | ##### FutOptMarketType[​](#futoptmarkettype "Direct link to FutOptMarketType") Trading Session Type | Name | Meaning | | ----------- | ---------------------- | | Future | Future Regular Session | | Option | Option Regular Session | | FutureNight | Future After-Hours | | OptionNight | Option After-Hours | ##### FutOptPriceType[​](#futoptpricetype "Direct link to FutOptPriceType") Price Type | Name | Meaning | | ----------- | ----------------------------- | | Limit | Limit | | Market | Market | | RangeMarket | Market with Protection Orders | | Reference | Reference Price | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | Rod | Rest of Day | | Fok | Fill-or-Kill | | Ioc | Immediate-or-Cancel | ##### FutOptOrderType[​](#futoptordertype "Direct link to FutOptOrderType") Order Type | Name | Meaning | | --------- | ------------ | | New | Common Stock | | Close | Margin | | Auto | Short sale | | FdayTrade | DayTrade | ##### functionType[​](#functiontype "Direct link to functionType") Function Type | Name | Value | | ----------------- | ----- | | New Order | 0 | | Execute New Order | 10 | | Amend Price | 15 | | Amend Lot | 20 | | Cancel Order | 30 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | -------------- | ------ | | Future、Option | TAIMEX | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ------------------------ | ---------------------------------------------------------------------------------------------------- | | Reservation | 0 | | InQueue | 4 (Using GetOrderResult retrieve the latest status) | | TimeOut | 9 (Please wait a moment and use GetOrderResult retrieve the latest status ; or connect your agency) | | New Order | 10 | | Cancel | 30 | | Fully filled | 50 | | Modified Price Failed | 19 | | Modified Quantity Failed | 29 | | Cancel Order Failed | 39 | | Failed | 90 | #### Month[​](#month "Direct link to Month") Month Code ##### Future[​](#future "Direct link to Future") | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | ##### Option[​](#option "Direct link to Option") Call | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | Put | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | M | N | O | P | Q | R | | Jul | Aug | Sep | Oct | Nov | Dec | | S | T | U | V | W | X | --- ### Login ApikeyLogin Version Info. Available since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------ | ---------------------- | | ID | String | Login ID | | Key | String | Your API Key | | Cert Path | String | Certification Path | | Cert Password | String | Certification password | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Account list is returned | | message | string | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `Stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.ApikeyLogin("Your ID", "Your Key","Your Cert Path","Your Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = Account{ name = 富邦Bill, // Account Name (string) account = 28, // Account Number (string) branchNo = 6460, // Branch Number (string) accountType = stock // Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------ | ---------------------- | | ID | String | Login ID | | Password | String | Login Password | | Cert Path | String | Certification Path | | Cert Password | String | Certification password | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Account list is returned | | message | string | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `Stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Login("Your ID", "Your Password","Your Cert Path","Your Cert Password"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = Account{ name = 富邦Bill, // Account Name (string) account = 28, // Account Number (string) branchNo = 6460, // Branch Number (string) accountType = stock // Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ---- | ---------------- | | isSuccess | bool | Interface result | #### Resquest Example[​](#resquest-example "Direct link to Resquest Example") ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var result = sdk.Logout(); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs True ``` --- ### Batch Cancel Order BatchCancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) (list of object) | The object list for cancel | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | 參數 | 類別 | 說明 | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch cancel ( modifying orders using the content returned by batch detail ) var cancel_object = new List{ batch_detail.data[0], batch_detail.data[1], }; sdk.FutOpt.BatchCancelOrder(account, cancel_object); // Batch cancel ( Using different individual orders ) var cancel_object = new List{ order_res.data[0], order_res.data[1], }; sdk.FutOpt.BatchCancelOrder(account, cancel_object); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptOrderResult { functionType = 30, // Function type (int) date = 2024/03/25, // Transaction date (string) seqNo = 00110212617, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0001, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Market type category (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order lot (int) timeInForce = ROD, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 30, // Order status (int) afterPriceType = , // Valid order price type (FutOptPriceType) afterPrice = 1822.6, // Valid order price (double) afterLot = 0, // Valid order lot (int) filledLot = 0, // Filled lot (int) filledMoney = 0, // Filled amount (int) beforeLot = , // Lot before amendment (int) beforePrice = , // Price before amendment (double) userDef = , // User-defined field (string) lastTime = 13:21:34, // Last modification time (string) errorMessage = // Error message (string) }, FutOptOrderResult { functionType = 30, // Function type (int) date = 2024/03/25, // Transaction date (string) seqNo = 00110212618, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0002, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Market type category (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order lot (int) timeInForce = ROD, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 30, // Order status (int) ... } ] } ``` --- ### Batch Modify Price BatchModifyPrice ##### First, using 'MakeModifyPriceObj' create a 'FutOptModifyPrice' object[​](#first-using-makemodifypriceobj-create-a-futoptmodifyprice-object "Direct link to First, using 'MakeModifyPriceObj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | The price type after modification | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'BatchModifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmodifyprice) (list of object) | The object list for price modification | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | 參數 | 類別 | 說明 | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch price modification ( modifying orders using the content returned by batch detail ) var modified_orders = new List { sdk.FutOpt.MakeModifyPriceObj(batch_result.data[0], "19900", null), sdk.FutOpt.MakeModifyPriceObj(batch_result.data[1], "19900", null) }; var batch_modify_price = sdk.FutOpt.BatchModifyPrice(account, modified_orders); Console.WriteLine(batch_modify_price); // Batch price modification ( Using different individual orders ) var modified_orders = new List { sdk.FutOpt.MakeModifyPriceObj(orderResults.data[37], "19900", null), sdk.FutOpt.MakeModifyPriceObj(orderResults.data[35], "19900", null) }; var batch_modify_price = sdk.FutOpt.BatchModifyPrice(account, modified_orders); Console.WriteLine(batch_modify_price); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ // Batch price modification (modifying orders using the content returned by batch detail) FutOptOrderResult{ functionType = 15, // Function Type (int) date = 2024/03/25, // Transaction Date (string) seqNo = 00310212663, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = Q0005, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 0, // Strike Price (float) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (float) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (float) lot = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `Rod`, `Fok`, `Ioc` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 19900, // Valid Order Price (float) afterLot = 1, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (float) userDef = , // Custom Fields (string) lastTime = 13:39:05, // Last Modification Time (string) errorMessage = // Error Message (string) }, FutOptOrderResult{ functionType = 15, // Function Type (int) date = 2024/03/25, // Transaction Date (string) seqNo = 00310212664, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = Q0006, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 0, // Strike Price (float) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (float) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (float) lot = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `Rod`, `Fok`, `Ioc` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] } Below example only extract data content [ // Batch price modification( Using different individual orders ) FutOptOrderResult{ functionType = 15, // Function Type (int) date = 2024/03/25, // Transaction Date (string) seqNo = 00110212763, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = CA004, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 0, // Strike Price (float) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (float) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (float) lot = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `Rod`, `Fok`, `Ioc` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 19900, // Valid Order Price (float) afterLot = 1, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (float) userDef = , // Custom Fields (string) lastTime = 13:39:05, // Last Modification Time (string) errorMessage = // Error Message (string) }, FutOptOrderResult{ functionType = 15, // Function Type (int) date = 2024/03/25, // Transaction Date (string) seqNo = 00110212762, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = CA005, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 0, // Strike Price (float) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (float) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BSAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (float) lot = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `Rod`, `Fok`, `Ioc` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] ``` --- ### Batch Modify Lot BatchModifyPrice ##### First, using 'MakeModifyLotObj' create a 'FutOptModifyLot' object[​](#first-using-makemodifylotobj-create-a-futoptmodifylot-object "Direct link to First, using 'MakeModifyLotObj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lot | int | The lot after modification ( The modified lot includes the partially filled portion of this order ) | #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | ModifyLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmodifylot) (list of object) | The object list for lot modification | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | Modified content list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Batch lot modification ( modifying orders using the content returned by batch detail ) var modified_orders = new List { sdk.FutOpt.MakeModifyLotObj(batch_result.data[0], 2), sdk.FutOpt.MakeModifyLotObj(batch_result.data[1], 2) }; var batch_modify_qty = sdk.FutOpt.BatchModifyLot(account, modified_orders); Console.WriteLine(batch_modify_qty); // Batch lot modification ( Using different individual orders ) var modified_orders = new List { sdk.FutOpt.MakeModifyLotObj(orderResults.data[0], 2), sdk.FutOpt.MakeModifyLotObj(orderResults.data[1], 2) }; var batch_modify_qty = sdk.FutOpt.BatchModifyLot(account, modified_orders); Console.WriteLine(batch_modify_qty); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ // Batch lot modification ( modifying orders using the content returned by batch detail ) FutOptOrderResult{ functionType= 20, // Function Type (int) date= 2024/03/25, // Transaction Date (string) seqNo = 03100161319, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l001D, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FIMTX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (string) buySell = Buy, // Buy/Sell Type (string): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (string) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (double) lot = 3, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 20000, // Valid Order Price (double) afterLot = 2, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 3, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 18:24:40, // Last Modification Time (string) errorMessage = // Error Message (string) }, FutOptOrderResult{ functionType= 20, // Function Type (int) date= 2024/03/25, // Transaction Date (string) seqNo = 03100161320, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l001E, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FIMTX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (string) buySell = Buy, // Buy/Sell Type (string): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (string) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (double) lot = 3, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] } Below example only extract data content [ // Batch lot modification ( Using different individual orders ) FutOptOrderResult{ functionType= 20, // Function Type (int) date= 2024/03/25, // Transaction Date (string) seqNo = 03100161419, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l003D, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FIMTX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (string) buySell = Buy, // Buy/Sell Type (string): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (string) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (double) lot = 3, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 20000, // Valid Order Price (double) afterLot = 2, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 3, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 18:24:40, // Last Modification Time (string) errorMessage = // Error Message (string) }, FutOptOrderResult{ functionType = 20, // Function Type (int) date= 2024/03/25, // Transaction Date (string) seqNo = 03100161420, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l003E, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FIMTX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (string) buySell = Buy, // Buy/Sell Type (string): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (string) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (double) lot = 3, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] ``` --- ### Get Batch Order Detail BatchOrderDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | BatchOrderList | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#batchresult) | Batch order list | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```cs var batch_order_list = sdk.FutOpt.BatchOrderLists(account); Console.WriteLine(sdk.FutOpt.BatchOrderDetail(account, batch_order_list.data[0])); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ OrderResult{ functionType = , // Function type (int) date = 2024/03/05, // Transaction date (string) seqNo = 00110212608, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0201, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Trading Session Type (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Symbol - Spread Order (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order Lot (int) timeInForce = Rod, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 10, // Order status (int) afterPriceType = , // Valid order price type (FutOptPriceType) afterPrice = 1822.6, // Valid order price (double) afterLot = 2, // Valid order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled amount (int) beforeLot = , // Lot before amendment (int) beforePrice = , // Price before amendment (double) userDef = , // User-defined field (string) lastTime = 10:20:27, // Last modification time (string) errorMessage = // Error message (string) }, ... ] } ``` --- ### Get Batch Order List BatchOrderLists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | BatchResult list is returned | | message | string | isSuccess = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------ | ------ | ----------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`90` Failed | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOpt.BatchOrderLists(account)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ BatchResult{ functionType = 0, // Type of function (int) date = 2023/10/04, // Query Date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) batchSeqNo = 11EE626533D072228000000C29304663 // Serial number (string) }, ... ] } ``` --- ### Place Batch Order BatchPlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#orderobject)(list of object) | Order Object | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orders = new FutOptOrder[]{ new FutOprOrder( BsAction.Buy, "TXO20000D4", "530", 1, FutOptMarketType.Option, FutOptPriceType.Limit, TimeInForce.Rod, FutOptOrderType.Auto, From CS ), new FutOptOrder( BsAction.Buy, "TXO20000D4", "530", 1, FutOptMarketType.Option, FutOptPriceType.Limit, TimeInForce.Rod, FutOptOrderType.Auto, From CS )}; sdk.FutOpt.BatchPlaceOrder(account,orders.ToList()); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptOrderResult{ functionType = 0, // Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date = 2024/03/25, // Transaction Date (string) seqNo = 00230177010, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = C0002, // Order Number (string) assetType = 2, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = 1, // Unit (int) currency = TWD, // Trading Currency (string) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20000, // Strike Price (double) callPut = Call, // Call / Put (CallPut): `Call`, `Put` buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 530, // Order Price (double) lots = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInforce): `Rod`, `Fok`, `Ioc` orderType = Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 530, // Valid Order Price (double) afterLot = 1, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 530, // Before the Price Modification (double) userDef = From CS, // Custom Fields (string) lastTime = 11:50:08, // Last Modification Time (string) errorMessage = // Error Message (string) }, FutOptOrderResult{ functionType = 0, // Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date = 2024/03/25, // Transaction Date (string) seqNo = 00230177011, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = C0003, // Order Number (string) assetType = 2, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = 1, // Unit (int) currency = TWD, // Trading Currency (string) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20000, // Strike Price (double) callPut = Call, // Call / Put (CallPut): `Call`, `Put` buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 530, // Order Price (double) lots = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInforce): `Rod`, `Fok`, `Ioc` orderType = Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] } ``` --- ### Cancel Order CancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) | The intended order result object to be cancel | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOpt.CancelOrder(account, cancel_order)); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = FutOptOrderResult{ functionType = 30, // Function type (int) date = 2024/03/25, // Transaction date (string) seqNo = 00110212608, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0001, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Market type category (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order lot (int) timeInForce = ROD, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 30, // Order status (int) afterPriceType = , // Valid order price type (FutOptPriceType) afterPrice = 1822.6, // Valid order price (double) afterLot = 0, // Valid order lot (int) filledLot = 0, // Filled lot (int) filledMoney = 0, // Filled amount (int) beforeLot = , // Lot before amendment (int) beforePrice = , // Price before amendment (double) userDef = , // User-defined field (string) lastTime = 13:21:34, // Last modification time (string) details = , // Order Process (list) errorMessage = // Error message (string) } } ``` --- ### Convert Symbol ConverSymbol #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | | symbol | string | Symbol from accounting | | expiryDate | string | Expiry Date | | strikePrice | double ( Optional ) | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) ( Optional ) | Call / Put : `Call` Call 、 `Put` Put | #### Response Parameter[​](#response-parameter "Direct link to Response Parameter") | Parameter | Type | Meaning | | --------- | ------ | ---------------------------------------- | | symbol | string | Symbol for Order or Subscribe MarketData | info You can refer to the [Enumerations table](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#month) for month codes. #### Request Example[​](#request-example "Direct link to Request Example") ```cs //Future sdk.FutOpt.ConvertSymbol("FITX","202404") //Option sdk.FutOpt.ConvertSymbol("TXO","202404",20000,CallPut.Call) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs //Future "TXFD4" //Option "TXO20000D4" ``` --- ### Query Estimate Margin QueryEstimateMargin #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#orderobject) | Order Object | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | -------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | EstimateMargin | EstimateMargin is returned | | message | string | isSuccess = False error description is returned | ##### EstimateMargin Parameter[​](#estimatemargin-parameter "Direct link to EstimateMargin Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------ | --------------- | | date | string | Query Date | | currency | string | Currency | | estimateMargin | double | Estimate Margin | #### Request Example[​](#request-example "Direct link to Request Example") ```cs order = FutOptOrder( BsAction.Buy, "TXFE4", "20890", 1, MarketType.Future, PriceType.Limit, TimeInForce.Rod, OrderType.Auto, "From csharp" // optional field ) var estimate = sdk.FutOpt.QueryEstimateMargin(account, order); Console.WriteLine(estimate.data); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = EstimateMargin{ date = 2024/04/10, // Query Date (string) currency = TWD, // Currency (string) estimateMargin = 179000 // Estimate Margin (double) } } ``` --- ### Get Historical Filled FilledHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Query start date | | endDate | string ( or empty will equals startDate ) | Query end date | info Support historical data for the past two days #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptFilledData list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptFilledData Parameter[​](#futoptfilleddata-parameter "Direct link to FutOptFilledData Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | date | date | Filled Date | | branchNo | string | Branch number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order number | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Spread Symbol | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | filledNo | string | Filled Transaction number | | filledAvgPrice | double | Filled Average Price | | filledLot | int | Filled Lot | | filledPrice | double | Filled Price | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOpt.FilledHistory(account,"20230921","20230922")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptFilledData{ date = 2023/09/21, // Filled Date (string) branchNo = 6460, // Branch number (string) account = 26, // Account (string) seqNo = , // Order Serial Number (string) orderNo = bA422, // Order number (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy / Sell (BsAction) symbolLeg2 = , // Symbol - Spread Order(string) expiryDateLeg2 = , // Expiry Date - Spread Order(string) strikePriceLeg2 = , // Strike Price - Spread Order(double) callPutLeg2 = , // Call / Put - Spread Order(CallPut) buySellLeg2 = , // Buy / Sell - Spread Order(BsAction) filledNo = 00000000001, // Filled Transaction number (string) filledAvgPrice = 20890.0, // Filled Average Price (double) filledLots = 1, // Filled Lot (int) filledPrice = 20890.0, // Filled Price (double) orderType = New, // Order Type (string) filledTime = 10:31:00.931, // Filled Time (string) userDef = // Custom Fields (string) }, ... ] } ``` --- ### Get Order Results GetOrderResult #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orderResults = sdk.FutOpt.GetOrderResults(accounts.data[0]); Console.WriteLine(orderResults); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptOrderResult{ functionType = , // Function type (int) date = 2024/03/25, // Transaction date (string) seqNo = 00110212608, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0001, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Trading Session Type (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Symbol - Spread Order (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order Lot (int) timeInForce = Rod, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 10, // Order status (int) afterPriceType = , // Valid order price type (FutOptPriceType) afterPrice = 1822.6, // Valid order price (double) afterLot = 2, // Valid order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled amount (int) beforeLot = , // Lot before amendment (int) beforePrice = , // Price before amendment (double) userDef = , // User-defined field (string) lastTime = 10:20:27, // Last modification time (string) details = , // Order Process (list) errorMessage = // Error message (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) GetOrderResultDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process | | >> functionType | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | int | Original Order Quantity | | >> afterQty | int | Valid Order Quantity (filled quantity included) | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var orderResults = sdk.FutOpt.GetOrderResults(accounts.data[0]); Console.WriteLine(orderResults); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptOrderResult{ functionType = , // Function type (int) date = 2024/03/25, // Transaction date (string) seqNo = 00110212608, // Order sequence number (string) branchNo = 15901, // Branch number (string) account = 1234567, // Account (string) orderNo = C0001, // Order number (string) assetType = 1, // Asset type (int) market = TAIMEX, // Market type (string) marketType = Future, // Trading Session Type (FutOptMarketType) unit = 1, // Unit (int) currency = TWD, // Currency (string) symbol = FITF, // Symbol (string) expiryDate = 202404, // Expiry date (string) strikePrice = , // Strike price (double) callPut = , // Call or put (CallPut) buySell = Buy, // Buy or sell (BsAction) symbolLeg2 = , // Symbol - Spread Order (string) expiryDateLeg2 = , // Expiry date - Spread Order (string) strikePriceLeg2 = , // Strike price - Spread Order (double) callPutLeg2 = , // Call or put - Spread Order (CallPut) buySellLeg2 = , // Buy or sell - Spread Order (BsAction) priceType = Limit, // Original order price type (FutOptPriceType) price = 1822.6, // Price (double) lot = 2, // Original order Lot (int) timeInForce = Rod, // Time in force (TimeInforce) orderType = Auto, // Order type (FutOptOrderType) isPreOrder = false, // Is pre-order (bool) status = 10, // Order status (int) afterPriceType = , // Valid order price type (FutOptPriceType) afterPrice = 1822.6, // Valid order price (double) afterLot = 2, // Valid order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled amount (int) beforeLot = , // Lot before amendment (int) beforePrice = , // Price before amendment (double) userDef = , // User-defined field (string) lastTime = 10:20:27, // Last modification time (string) errorMessage = // Error message (string) details = [ // Order Process (list) OrderDetail{ functionType = 10, // Function Type (int) modifiedTime = 10:20:27, // Order Modified Time (string) beforeLot = 0, // Original Order Lot (int) afterLot = 2, // Valid Order Lot (int) beforePrice = 1822.6, // Original Order Price (double) afterPrice = 1822.6 // Valid Order Price (double) errorMessage = // Error Message (string) } ] }, ... ] } ``` --- ### Modify Order Price ModifyPrice ##### First, using 'MakeModifyPriceObj' create a 'FutOptModifyPrice' object[​](#first-using-makemodifypriceobj-create-a-futoptmodifyprice-object "Direct link to First, using 'MakeModifyPriceObj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | The price type after modification | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'modifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmodifyprice) | The object for price modification | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var modify_price_obj = sdk.FutOpt.MakeModifyPriceObj(order_result, "19900", null); var modify_price = sdk.FutOpt.ModifyPrice(account, modify_price_obj); Console.WriteLine(modify_price); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = FutOptOrderResult{ functionType = 15, // Function Type (int) date = 2024/03/25, // Transaction Date (string) seqNo = 00110212663, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = C0005, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FITX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 0, // Strike Price (float) callPut = , // Call / Put (CallPut) buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (float) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (float) lot = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `Rod`, `Fok`, `Ioc` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 19900, // Valid Order Price (float) afterLot = 1, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (float) userDef = , // Custom Fields (string) lastTime = 13:39:05, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Modify Order Lot ModifyLot ##### First, using 'MakeModifyLotObj' create a 'FutOptModifyLot' object[​](#first-using-makemodifylotobj-create-a-futoptmodifylot-object "Direct link to First, using 'MakeModifyLotObj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lot | int | The lot after modification ( The modified lot includes the partially filled portion of this order ) | Put the returned object into the 'ModifyLot' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | ModifyLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmodifylot) | The object for Lot modification | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs var modify_lot_obj = sdk.FutOpt.MakeModifyLotObj(order_result, 2); var modify_lot = sdk.FutOpt.ModifyLot(account, modify_lot_obj); Console.WriteLine(modify_lot); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = FutOptOrderResult{ functionType= 20, // Function Type (int) date= 2024/03/25, // Transaction Date (string) seqNo = 03100161319, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = l001D, // Order Number (string) assetType = 1, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = TWD, // Trading Currency (string) symbol = FIMTX, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = , // Strike Price (double) callPut = , // Call / Put (string) buySell = Buy, // Buy/Sell Type (string): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (string) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 20000, // Order Price (double) lot = 3, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 20000, // Valid Order Price (double) afterLot = 2, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 20000, // Before the Price Modification (double) userDef = , // Custom Fields (string) lastTime = 18:24:40, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Get Historical Order OrderHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | Account | | startDate | string | Query start date | | endDate | string | Query end date | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | info Support historical data for the past two days #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ------ | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process | | >> functionType | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | int | Original Order Quantity | | >> afterQty | int | Valid Order Quantity (filled quantity included) | | >> beforePrice | double | Original Order Price | | >> afterPrice | double | Valid Order Price | | >> filledMoney | double | Filled Value | | >> errorMessage | string | Error Message | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs Console.WriteLine(sdk.FutOpt.OrderHistory(account, FutOptMarketType.Option, "20230921", "20230922")); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data =[ FutOptOrderResult{ function_type = 0, // Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date = 2024/04/11, // Transaction Date (string) seq_no = 00230177314, // Order Serial Number (string) branch_no = 15000, // Branch Number (string) account = 9974825, // Account (string) order_no = C0020, // Order Number (string) asset_type = 2, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) market_type = Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = , // Unit (int) currency = , // Trading Currency (string) symbol = TXO, // Symbol (string) expiry_date = 202404, // Expiry Date (string) strike_price = 18600, // Strike Price ( double) call_put = Call, // Call / Put (CallPut): `Call`, `Put` buy_sell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbol_leg2 = , // Spread Symbol (string) expiry_date_leg2 = , // Expiry Date - Spread Order (string) strike_price_leg2 = , // Strike Price - Spread Order ( double) call_put_leg2 = , // Call / Put - Spread Order (CallPut) buy_sell_leg2 = , // Buy/Sell Type - Spread Order (BsAction) price_type = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 2100, // Order Price ( double) lot = 1, // Original Order Lot (int) time_in_force = ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type = New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order = false, // Reservation Order Flag (bool) status = 50, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type = , // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price = 2100, // Valid Order Price ( double) after_lot = 1, // Valid Order Lot (int) filled_lot = 1, // Filled Lot (int) filled_money = 2100, // Filled Value ( double) before_lot = , // Before the Lot Modification (int) before_price = , // Before the Price Modification ( double) user_def = , // Custom Fields (string) last_time = 10:41:46.760, // Last Modification Time (string) error_message = // Error Message (string) }, ... ] } ``` --- ### PlaceOrder PlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#account) | account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#orderobject) | Order Object | | unblock | bool (optional) (default = false) | unblock | #### Result Reponse[​](#result-reponse "Direct link to Result Reponse") | Parameter | Type | Meaning | | --------- | ----------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | FutOptOrderResult | FutOptOrderResult is returned | | message | string | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | int | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | int | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | double | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | double | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | [BsAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | double | Order Price | | lot | int | Original order lot | | timeInForce | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#timeinforce) | Time In Force `Rod` 、 `Fok` 、 `Ioc` | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/csharp/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | double | Valid order price | | afterLot | int | Valid Order Lot | | filledLot | int | Filled Lot | | filledMoney | double | Filled Value | | beforeLot | int | Before the Lot Modification | | beforePrice | double | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query OrderResultDetail or OrderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs // Single var order = new FutOptOrder( BsAction.Buy, "TXO20000E4", null, null, "500", 1, FutOptMarketType.Option, FutOptPriceType.Limit, TimeInForce.Rod, FutOptOrderType.Auto, "From csharp" // optional field ) sdk.FutOpt.PlaceOrder(account, order) // Spread var order = new FutOptOrder( BsAction.Sell, "TXO20000E4", BsAction.Buy, // optional field "TXO19900E4", // optional field "90", 1, FutOptMarketType.Option, FutOptPriceType.Limit, TimeInForce.Ioc, FutOptOrderType.Auto, "From csharp" // optional field ) sdk.FutOpt.PlaceOrder(account, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```cs { isSuccess = True, message = , data = FutOptOrderResult{ functionType = 0, // Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date = 2024/03/25, // Transaction Date (string) seqNo = 00230177010, // Order Serial Number (string) branchNo = 15901, // Branch Number (string) account = 1234567, // Account (string) orderNo = C0002, // Order Number (string) assetType = 2, // Asset Type (int): `1` Future, `2` Option market = TAIMEX, // Market Type (string) marketType = Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit = 1, // Unit (int) currency = TWD, // Trading Currency (string) symbol = TXO, // Symbol (string) expiryDate = 202404, // Expiry Date (string) strikePrice = 20000, // Strike Price (double) callPut = Call, // Call / Put (CallPut): `Call`, `Put` buySell = Buy, // Buy/Sell Type (BsAction): `Buy`, `Sell` symbolLeg2 = , // Spread Symbol (string) expiryDateLeg2 = , // Expiry Date - Spread Order (string) strikePriceLeg2 = , // Strike Price - Spread Order (double) callPutLeg2 = , // Call / Put - Spread Order (CallPut) buySellLeg2 = , // Buy/Sell Type - Spread Order (BsAction) priceType = Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price = 530, // Order Price (double) lots = 1, // Original Order Lot (int) timeInForce = Rod, // Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` orderType = Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder = false, // Reservation Order Flag (bool) status = 10, // Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType = Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice = 530, // Valid Order Price (double) afterLot = 1, // Valid Order Lot (int) filledLot = 0, // Filled Lot (int) filledMoney = 0, // Filled Value (int) beforeLot = 0, // Before the Lot Modification (int) beforePrice = 530, // Before the Price Modification (double) userDef = From CS, // Custom Fields (string) lastTime = 11:50:08, // Last Modification Time (string) details = , // Order Process (list) errorMessage = // Error Message (string) } } ``` --- ### Close Position Record closePositionRecord #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | RealizedSummary list is returned | | message | string ? (optional) | isSuccess : False error description is returned | ##### CloseRecord Parameter[​](#closerecord-parameter "Direct link to CloseRecord Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | date | string | Date | | branchNo | string | Branch Number | | positionKind | number | Position Kind : `1` Future 、`2` Option | | account | string | Account | | orderNo | string | Order Number | | market | string | Market Type : `TAIMEX` Future 、 Option | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | buySell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell : `Buy` Buy、`Sell` Sell | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | price | number | Deal Price | | origLots | number | Original Lots | | transactionFee | number | Transaction Fee | | tax | number | Tax | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futoptAccounting.closePositionRecord(account,"20240410"); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date : '2024/04/10', // Date (string) branchNo : '15000', // Branch Number (string) account : '9974825', // Account (string) positionKind : 1, // Position Kind : `1` Futures, `2` Options (number) orderNo : '15001-0000', // Order Number (string) market : 'TAIMEX', // Market : `TAIMEX` Futures, Options (string) symbol : 'FITX', // Symbol (string) expiryDate : "202404", // Expiry Date (number) buySell : Buy, // Buy/Sell Type : `Buy`, `Sell` (number) price : 20847.0, // Deal Price (number) origLots : 1, // Original Lots (number) transactionFee : 40.0, // Transaction Fee (number) tax : 83.0, // Tax (number) }, { date : '2024/04/10', // Date (string) branchNo : '15000', // Branch Number (string) account : '9974825', // Account (string) positionKind : 1, // Position Kind : `1` Futures, `2` Options (number) orderNo : 'C0005-0000', // Order Number (string) market : 'TAIMEX', // Market : `TAIMEX` Futures, Options (string) symbol : 'FITX', // Symbol (string) expiryDate : "202405", // Expiry Date (number) buySell : Buy, // Buy/Sell Type : `Buy`, `Sell` (number) price : 20890.0, // Deal Price (number) origLots : 1, // Original Lots (number) transactionFee : 40.0, // Transaction Fee (number) tax : 84.0, // Tax (number) }, ... ] } ``` --- ### Hybrid Position queryHybridPosition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Position list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### HybridPosition Parameter[​](#hybridposition-parameter "Direct link to HybridPosition Parameter") Return type : Object | Parameter | Type | Meaning | | -------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | > date | string | Transaction Date | | > branchNo | string | Branch Number | | > account | string | Account | | > isSpread | bool | Spread Order Flag | | > positionKind | number | Position Kind : `1` Future 、`2` Option | | > symbol | string | Symbol | | > expiryDate | number | Expiry Date | | > strikePrice | number | Strike Price | | > callPut | number | Call / Put : `1` Call 、`2` Put | | > buySell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | > price | number | Cost Price | | > origLots | number | Original Lot | | > tradableLots | number | Available Lot | | > orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | > currency | string | Currency | | > marketPrice | string | Market Price | | > initialMargin | number | Initial Margin | | > maintenanceMargin | number | Maintenance Margin | | > clearingMargin | number | Clearing Margin | | > optValue | number | Option market value | | > optLongValue | number | Long Option market value | | > optShortValue | number | Short Option market value | | > profitOrLoss | number | Profit or Loss | | > premium | number | Premium | | > spread | object | Spread Detail | | >> date | string | Transaction Date | | >> branchNo | string | Branch Number | | >> account | string | Account | | >> isSpread | bool | Spread Order Flag | | >> positionKind | number | Position Kind : `1` Future 、`2` Option | | >> symbol | string | Symbol | | >> expiryDate | number | Expiry Date | | >> strikePrice | number | Strike Price | | >> callPut | number | Call / Put : `1` Call 、`2` Put | | >> buySell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | >> price | number | Cost Price | | >> origLots | number | Original Lot | | >> tradableLots | number | Available Lot | | >> orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | >> currency | string | Currency | | >> marketPrice | string | Market Price | | >> initialMargin | number | Initial Margin | | >> maintenanceMargin | number | Maintenance Margin | | >> clearingMargin | number | Clearing Margin | | >> optValue | number | Option market value | | >> optLongValue | number | Long Option market value | | >> optShortValue | number | Short Option market value | | >> profitOrLoss | number | Profit or Loss | | >> premium | number | Premium | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futoptAccounting.queryHybridPosition(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```js { isSuccess: true, data:[ { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: false, // Spread Order Flag (bool) positionKind: 1, // Position Kind : `1` Future 、`2` Option (number) symbol: "FITX", // Symbol (str) expiryDate: 202404, // Expiry Date (number) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 20325.3333, // Cost Price (number) origLots: 3, // Original Lot (number) tradableLots: 3, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "20351", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 0.0, // Option market value (number) optLongValue: 0.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: 0.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: false, // Spread Order Flag (bool) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TX1", // Symbol (str) expiryDate: 202404, // Expiry Date (number) strikePrice: 20600, // Strike Price (number) callPut: "Call", // Call / Put : `Call` 、`Put` (CallPut) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 10, // Cost Price (number) origLots: 4, // Original Lot (number) tradableLots: 4, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "4.6", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 920.0, // Option market value (number) optLongValue: 920.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: -1080.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: false, // Spread Order Flag (bool) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TXO", // Symbol (str) expiryDate: 202404, // Expiry Date (number) strikePrice: 19800, // Strike Price (number) callPut: "Call", // Call / Put : `Call` 、`Put` (CallPut) buySell: "Sell", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 243, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLots: 2, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "46", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 4600.0, // Option market value (number) optLongValue: 4600.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: -19700.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: false, // Spread Order Flag (bool) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TXO", // Symbol (str) expiryDate: 202404, // Expiry Date (number) strikePrice: 20000, // Strike Price (number) callPut: "Put", // Call / Put : `Call` 、`Put` (CallPut) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 344, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLots: 2, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "82", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 8200.0, // Option market value (number) optLongValue: 8200.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: -26200.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) isSpread: true, // Spread Order Flag (bool) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TXO20100D4:20000P4", // Symbol (str) expiryDate: 1, // Expiry Date (number) strikePrice: 1, // Strike Price (number) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) origLots: 2, // Original Lot (number) tradableLots: 2, // Available Lot (number) orderType: "New", // Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency: "TWD", // Currency (str) marketPrice: "0.0", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0, // Initial Margin (number) optValue: 0.0, // Option market value (number) optLongValue: 0.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: 0.0, // Profit or Loss (number) premium: 0.0, // Premium (number) spreads: [ // Spread Detail (List[SpreadPosition]) { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TXO", // Symbol (str) expiryDate: 202404, // Expiry Date (number) strikePrice: 20100, // Strike Price (number) callPut: "Call", // Call / Put : `Call` 、`Put` (CallPut) buySell: "Buy", // Buy/Sell Type : `Buy` 、`Sell` (BSAction) price: 185, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLots: 2, // Available Lot (number) currency: "TWD", // Currency (str) marketPrice: "365", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0,// Initial Margin (number) optValue: 36500.0, // Option market value (number) optLongValue: 36500.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: 18000.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { date: "2024/04/08", // Transaction Date (str) branchNo: "15901", // Branch Number (str) account: "1234567", // Account (str) positionKind: 2, // Position Kind : `1` Future 、`2` Option (number) symbol: "TXO", // Symbol (str) expiryDate: 202404, // Expiry Date (number) strikePrice: 20100, // Strike Price (number) callPut: "Put", // Call / Put : `Call` 、`Put` (number) buySell: "Buy", // Buy/Sell Type : `Buy`、`Sell` (BSAction) price: 0, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLots: 2, // Available Lot (number) currency: "TWD", // Currency (str) marketPrice: "0.0", // Market Price (str) initialMargin: 0.0, // Initial Margin (number) maintenanceMargin: 0.0, // Maintenance Margin (number) clearingMargin: 0.0, // Clearing Margin (number) initialMarginAllSingle: 0.0,// Initial Margin (number) optValue: 0.0, // Option market value (number) optLongValue: 0.0, // Long Option market value (number) optShortValue: 0.0, // Short Option market value (number) profitOrLoss: 0.0, // Profit or Loss (number) premium: 0.0, // Premium (number) } ], } ] } ``` --- ### Query Equity queryMarginEquity ##### Reqeust Parameter[​](#reqeust-parameter "Direct link to Reqeust Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Equity is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Equity Parameter[​](#equity-parameter "Direct link to Equity Parameter") Return type : Object | 參數 | 類別 | 說明 | | ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------- | | date | string | Query Date | | branchNo | string | Branch Number | | account | string | Account | | currency | string | Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen | | yesterdayBalance | number | Yesterday Balance | | todayBalance | number | Today's Balance | | initialMargin | number | Initial Margin | | maintenanceMargin | number | Maintenace Margin | | clearingMargin | number | Clearing Margin | | todayEquity | number | Today's Equity | | todayDeposit | number | Today's Deposit | | todayWithdrawal | number | Today's Withdrawal | | todayTradingFee | number | Today's Trading Fee | | todayTradingTax | number | Today's Trading Tax | | receivablePremium | number | Receivable Premium | | payablePremium | number | Payable Premium | | excessMargin | number | Excess Margin | | availableMargin | number | Available Margin | | disgorgement | number | Disgorgement | | optPnl | number | Option Profit or loss | | optValue | number | Option Market Value | | optLongValue | number | Long Option Market Value | | optShortValue | number | Short Option Market Value | | futRealizedPnl | number | Future Realized Profit or Loss | | futUnrealizedPnl | number | Future Unrealized Profit or Loss | | buyLot | number | Buying Lot | | sellLot | number | Selling Lot | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futoptAccounting.queryMarginEquity(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: '2024/04/08', // Query Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) currency: 'NTD', // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance: 22435152.4, // Yesterday Balance (number) todayBalance: 22434910.4, // Today's Balance (number) initialMargin: 1114946.0, // Initial Margin (number) maintenanceMargin: 939214.0, // Maintenace Margin (number) clearingMargin: 915760.0, // Clearing Margin (number) todayEquity: 22694910.4, // Today's Equity (number) todayDeposit: 0.0, // Today's Deposit (number) todayWithdrawal: 2102.0, // Today's Withdrawal (number) todayTradingFee: 16.0, // Today's Trading Fee (number) todayTradingTax: 0.0, // Today's Trading Tax (number) receivablePremium: 0.0, // Receivable Premium (number) payablePremium: 9250.0, // Payable Premium (number) excessMargin: 28744525.0, // Excess Margin (number) availableMargin: 21453562.4, // Available Margin (number) disgorgement: 0.0, // Disgorgement (number) optPnl: -248600.0, // Option Profit or loss (number) optValue: -193100.0, // Option Market Value (number) optLongValue: 311900.0, // Long Option Market Value (number) optShortValue: 505000.0, // Short Option Market Value (number) futRealizedPnl: 0.0, // Future Realized Profit or Loss (number) futUnrealizedPnl: 60700.0, // Future Unrealized Profit or Loss (number) buyLot: 22, // Buying Lot (number) sellLot: 7 // Selling Lot (number) }, { date: '2024/04/08', // Query Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) currency: 'TWD', // Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen (string) yesterdayBalance: 19880310.0, // Yesterday Balance (number) todayBalance: 19880068.0, // Today's Balance (number) initialMargin: 1114946.0, // Initial Margin (number) maintenanceMargin: 939214.0, // Maintenace Margin (number) clearingMargin: 915760.0, // Clearing Margin (number) todayEquity: 20140068.0, // Today's Equity (number) todayDeposit: 0.0, // Today's Deposit (number) todayWithdrawal: 2102.0, // Today's Withdrawal (number) todayTradingFee: 16.0, // Today's Trading Fee (number) todayTradingTax: 0.0, // Today's Trading Tax (number) receivablePremium: 0.0, // Receivable Premium (number) payablePremium: 9250.0, // Payable Premium (number) excessMargin: 28744525.0, // Excess Margin (number) availableMargin: 18898720.0, // Available Margin (number) disgorgement: 0.0, // Disgorgement (number) optPnl: -248600.0, // Option Profit or loss (number) optValue: -193100.0, // Option Market Value (number) optLongValue: 311900.0, // Long Option Market Value (number) optShortValue: 505000.0, // Short Option Market Value (number) futRealizedPnl: 0.0, // Future Realized Profit or Loss (number) futUnrealizedPnl: 60700.0, // Future Unrealized Profit or Loss (number) buyLot: 22, // Buying Lot (number) sellLot: 7 // Selling Lot (number) } ] } ``` --- ### Query Single Position querySinglePosition #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Position list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Position Parameter[​](#position-parameter "Direct link to Position Parameter") Return type : Object | Parameter | Type | Meaning | | ----------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | date | string | Transaction Date | | branchNo | string | Branch Number | | account | string | Account | | isSpread | bool | Spread Order Flag | | positionKind | number | Position Kind : `1` Future 、`2` Option | | symbol | string | Symbol | | symbolName | string | Symbol Name | | expiryDate | number | Expiry Date | | strikePrice | number | Strike Price | | callPut | [Callput](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | buySell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | price | number | Cost Price | | origLots | number | Original Lot | | tradableLots | number | Available Lot | | orderType | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | currency | string | Currency | | marketPrice | string | Market Price | | initialMargin | number | Initial Margin | | maintenanceMargin | number | Maintenance Margin | | clearingMargin | number | Clearing Margin | | optValue | number | Option market value | | optLongValue | number | Long Option market value | | optShortValue | number | Short Option market value | | profitOrLoss | number | Profit or Loss | | premium | number | Premium | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futoptAccounting.querySinglePosition(account); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { dataDate: '2024/04/08', // Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) orderNo: 'l0001-0000', // Order Number (string) positionKind: 1, // Position Kind (number) symbol: 'FITX', // Symbol (string) expiryDate: 202404, // Expiry Date (number) strikePrice: null, // Strike Price (number) callPut: null, // Call/Put Type (CallPut) buySell: Buy, // Buy/Sell Type (BSAction) price: 20362, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLot: 2, // Tradable Lot (number) orderType: 0, // Order Type (FutOptOrderType) currency: 'TWD', // Currency (string) marketPrice: '20521.0000', // Market Price (string) initialMargin: 358000.0, // Initial Margin (number) maintenanceMargin: 274000.0, // Maintenance Margin (number) clearingMargin: 264000.0, // Clearing Margin (number) profitOrLoss: 63600.0, // Profit or Loss (number) premium: 0.0, // Premium (number) }, { dataDate: '2024/03/29', // Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) orderNo: 'l0007-0000', // Order Number (string) positionKind: 2, // Position Kind (number) symbol: 'TX1', // Symbol (string) expiryDate: 202404, // Expiry Date (number) strikePrice: 20600, // Strike Price (number) callPut: Call, // Call/Put Type (CallPut) buySell: Buy, // Buy/Sell Type (BSAction) price: 10, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLot: 2, // Tradable Lot (number) orderType: New, // Order Type (FutOptOrderType) currency: 'TWD', // Currency (string) marketPrice: '4.6000', // Market Price (string) initialMargin: 52660.0, // Initial Margin (number) maintenanceMargin: 36460.0, // Maintenance Margin (number) clearingMargin: 34460.0, // Clearing Margin (number) profitOrLoss: -540.0, // Profit or Loss (number) premium: -1000.0, // Premium (number) }, { dataDate: '2024/03/29', // Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) orderNo: 'l0007-0001', // Order Number (string) positionKind: 2, // Position Kind (number) symbol: 'TX1', // Symbol (string) expiryDate: 202404, // Expiry Date (number) strikePrice: 20600, // Strike Price (number) callPut: Call, // Call/Put Type (CallPut) buySell: Buy, // Buy/Sell Type (BSAction) price: 10, // Cost Price (number) origLots: 2, // Original Lot (number) tradableLot: 2, // Tradable Lot (number) orderType: New, // Order Type (FutOptOrderType) currency: 'TWD', // Currency (string) marketPrice: '4.6000', // Market Price (string) initialMargin: 52660.0, // Initial Margin (number) maintenanceMargin: 36460.0, // Maintenance Margin (number) clearingMargin: 34460.0, // Clearing Margin (number) profitOrLoss: -540.0, // Profit or Loss (number) premium: -1000.0, // Premium (number) }, { dataDate: '2024/03/01', // Date (string) branchNo: '15901', // Branch Number (string) account: '1234567', // Account (string) orderNo: 'l0002-0000', // Order Number (string) positionKind: 2, // Position Kind (number) symbol: 'TXO', // Symbol (string) expiryDate: 202404, // Expiry Date (number) strikePrice: 18500, // Strike Price (number) callPut: Call, // Call/Put Type (CallPut) buySell: Sell, // Buy/Sell Type (BSAction) price: 625, // Cost Price (number) origLots: 5, // Original Lot (number) tradableLot: 4, // Tradable Lot (number) orderType: New, // Order Type (FutOptOrderType) currency: 'TWD', // Currency (string) marketPrice: '2020.0000', // Market Price (string) initialMargin: 584000.0, // Initial Margin (number) maintenanceMargin: 544000.0, // Maintenance Margin (number) clearingMargin: 536000.0, // Clearing Margin (number) profitOrLoss: -279000.0, // Profit or Loss (number) premium: 125000.0, // Premium (number) } ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | ------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------- | | buySell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | buySell2 (optional) | BSAction | Spread Order [Buy/Sell Type](#bsaction) | | symbol2 (optional) | string | Spread Order Symbol | | price | string | Order Price | | lot | number | Order Lot | | marketType | FutOptMarketType | [Trading Session](#futoptmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` | | priceType | FutOptPriceType | [Price Type](#futoptpricetype) valid in `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | timeInForce | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | orderType | FutOptOrderType | [Order Type](#futoptordertype) valid in `New`、`Close`、`Auto` 、`FdayTrade` | | userDef (optional) | string | Customer Field (Up to 10 characters, no special characters supported) | ##### FutOptOrderResult[​](#futoptorderresult "Direct link to FutOptOrderResult") OrderResult,You can using [GetOrderResult(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/trade/GetOrderResults.md) get data. | Parameter | Type | Meaning | | --------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90` Failed | | date | string | Transaction Date | | seqNo | string | Order Serial Number | | branchNo | string | Branch Number | | account | string | Account | | orderNo | string | Order Number | | assetType | number | Asset Type : `1` Future、 `2` Option | | market | string | Market Type : `TAIMEX` Future 、Option | | marketType | FutOptMarketType | Trading Session Type : `Future`、`Option`、`FutureNight`、`OptionNight` | | symbol | string | Symbol | | buySell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | FutOptPriceType | Original OPrder Price Type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original Order Lot | | timeInForce | TimeInForce | Time In Force : `ROD` 、 `FOK` 、 `IOC` | | orderType | FutOptOrderType | Order Type : `New` 、 `Close` 、 `Auto` | | isPreOrder | bool | Reservation Order Flag | | status | number | Order Status : `0` Reservation 、 `4` InQueue、 `9` TimeOut 、 `10` New Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | FutOptPriceType | Valid Order Price Type :`Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid Order Price | | unit | number | Trading Unit | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | errorMessage | string | Error Message | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | >> functionType | number | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeLot | number | Original Order Lot | | >> afterLot | number | Valid Order Lot | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> errorMessage | string | Error Message | ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult,You can using [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/nodejs/trade/batchOrder/BatchOrderList.md) get data. | Parameter | Type | Meaning | | ------------ | ------ | ------------------------------------------------------------------------------------------ | | functionType | number | Function Type : `0` New 、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Date | | branchNo | string | Branch Aumber | | account | string | Account | | batchSeqNo | string | Batch Serial Number | ##### FutOptModifyPrice[​](#futoptmodifyprice "Direct link to FutOptModifyPrice") Modified Price Object | Parameter | Type | Meaning | | ----------------- | --------------- | --------------------------------------------------------------------------------------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | price | number | The price after modification | | PriceType | FutOptPriceType | The price type after modification : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | ##### FutOptModifyLot[​](#futoptmodifylot "Direct link to FutOptModifyLot") Modified Lot Object | Parameter | Type | Meaning | | ----------------- | ------ | --------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | lot | number | The lot after modification | ##### FutOptFilledData[​](#futoptfilleddata "Direct link to FutOptFilledData") Filled Data Object | Parameter | Type | Meaning | | --------------- | -------- | ----------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | CallPut | Call / Put : `Call`、`Put` | | buySell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Spread Symbol | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | CallPut | Call / Put : `Call`、`Put` | | buySellLeg2 | BSAction | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | filledNo | string | Filled Serial Number | | filledAvgPrice | number | Filled Average Price | | filledLot | number | Filled Share | | filledPrice | number | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ----------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branchNo | string | Branch Number | | accountType | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### CallPut[​](#callput "Direct link to CallPut") Call / Put Type | Name | Meaning | | ---- | ------- | | Call | Call | | Put | Put | ##### FutOptMarketType[​](#futoptmarkettype "Direct link to FutOptMarketType") Trading Session Type | Name | Meaning | | ----------- | ---------------------- | | Future | Future Regular Session | | Option | Option Regular Session | | FutureNight | Future After-Hours | | OptionNight | Option After-Hours | ##### FutOptPriceType[​](#futoptpricetype "Direct link to FutOptPriceType") Price Type | Name | Meaning | | ----------- | ----------------------------- | | Limit | Limit | | Market | Market | | RangeMarket | Market with Protection Orders | | Reference | Reference Price | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### FutOptOrderType[​](#futoptordertype "Direct link to FutOptOrderType") Order Type | Name | Meaning | | --------- | ------------ | | New | Common Stock | | Close | Margin | | Auto | Short sale | | FdayTrade | DayTrade | ##### functionType[​](#functiontype "Direct link to functionType") Function Type | Name | Value | | ----------------- | ----- | | New Order | 0 | | Execute New Order | 10 | | Amend Price | 15 | | Amend Lot | 20 | | Cancel Order | 30 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | -------------- | ------ | | Future、Option | TAIMEX | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ------------------------ | ---------------------------------------------------------------------------------------------------- | | Reservation | 0 | | InQueue | 4 (Using GetOrderResult retrieve the latest status) | | TimeOut | 9 (Please wait a moment and use GetOrderResult retrieve the latest status ; or connect your agency) | | New Order | 10 | | Cancel | 30 | | Fully filled | 50 | | Modified Price Failed | 19 | | Modified Quantity Failed | 29 | | Cancel Order Failed | 39 | | Failed | 90 | #### Month[​](#month "Direct link to Month") Month Code ##### Future[​](#future "Direct link to Future") | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | ##### Option[​](#option "Direct link to Option") Call | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | Put | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | M | N | O | P | Q | R | | Jul | Aug | Sep | Oct | Nov | Dec | | S | T | U | V | W | X | --- ### Login apikeyLogin Version Info. Available since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------ | ---------------------- | | personalId | String | Login ID | | key | String | Your Key | | certPath | String | Certification Path | | certPass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Account list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.apileyLogin("Your ID", "Your Key","Your Cert Path","Your Cert Password"); Console.log(accounts); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ name: '富邦Bill', // Account Name (string) account: '28', // Account Number (string) branchNo: '6460', // Branch Number (string) accountType: 'stock' // Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ------ | ---------------------- | | personalId | String | Login ID | | password | String | Login Password | | certPath | String | Certification Path | | certPass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Account list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branchNo | String | Branch Number | | accountType | String | Account Type: value in `stock` and `futopt` | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password","Your Cert Path","Your Cert Password"); Console.log(accounts); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ name: '富邦Bill', // Account Name (string) account: '28', // Account Number (string) branchNo: '6460', // Branch Number (string) accountType: 'stock' // Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ---- | ---------------- | | isSuccess | bool | Interface result | #### Request Example[​](#request-example "Direct link to Request Example") ```js const { FubonSDK, BSAction, TimeInForce, OrderType, PriceType, MarketType } = require('fubon-neo'); const sdk = new FubonSDK(); sdk.logout(); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js true ``` --- ### Batch Cancel Order batchCancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- | | account | Account | Account | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult)(list of object) | The intended order result object to be cancel | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch cancel( using the content returned by batch detail) cancel_object = [ batch_results_detail.data[0], batch_results_detail.data[1], ] sdk.futopt.batchCancelOrder(account, cancel_object) // Batch cancel( Using different individual orders) cancel_object = [ orders[37], orders[35], ] sdk.futopt.batchCancelOrder(account, cancel_object) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 30, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212608", // Order Sequence Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0001", // Order Number (string) assetType: 1, // Asset Type (number) market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: 202404, // Expiry Date (string) buySell: Buy, // Buy or Sell (BSAction) priceType: Limit, // Original Order Price Type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInforce) orderType: Auto, // Order Type (FutOptOrderType) isPreOrder: false, // Is Pre-Order (bool) status: 30, // Order Status (number) afterPrice: 1822.6, // Valid Order Price (number) afterLot: 0, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Amount (number) lastTime: "13:21:34", // Last Modification Time (string) }, { functionType: 30, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212608", // Order Sequence Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0001", // Order Number (string) assetType: 1, // Asset Type (number) market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: 202404, // Expiry Date (string) buySell: Buy, // Buy or Sell (BSAction) priceType: Limit, // Original Order Price Type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInforce) orderType: Auto, // Order Type (FutOptOrderType) isPreOrder: false, // Is Pre-Order (bool) status: 30, // Order Status (number) ... } } ``` --- ### Batch Modify Price batchModifyPrice ##### First, using 'makeModifyPriceObj' create a 'FutOptModifyPrice' object[​](#first-using-makemodifypriceobj-create-a-futoptmodifyprice-object "Direct link to First, using 'makeModifyPriceObj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string? | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype)? | The price type after modification | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'batchModifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmodifyprice) (list of object) | The object for price modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch price modification ( modifying orders using the content returned by batch detail ) modify_orders = [ sdk.futopt.makeModifyPriceObj(batch_res.data[0], "19900"), sdk.futopt.makeModifyPriceObj(batch_res.data[1], "19900") ] sdk.futopt.batchModifyPrice(account, modify_orders); // Batch price modification ( Using different individual orders ) modify_orders = [ sdk.futopt.makeModifyPriceObj(orderResult.data[20], "19900"), sdk.futopt.makeModifyPriceObj(orderResult.data[21], "19900"), sdk.futopt.makeModifyPriceObj(orderResult.data[28], "19900") ] sdk.futopt.batchModifyPrice(account, modify_orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ // Batch price modification (modifying orders using the content returned by batch detail) { functionType: 15, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212863", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0020", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` price: 20000, // Order Price (number) lot: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` afterPrice: 19900, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "13:40:05", // Last Modification Time (string) }, { functionType: 15, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212864", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0021", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 0, // Strike Price (number) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` ... } ] } Below example only extract data content [ // Batch price modification( Using different individual orders ) { functionType: 15, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212887", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0034", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 0, // Strike Price (number) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` price: 20000, // Order Price (number) lot: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` afterPrice: 19900, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "13:40:05", // Last Modification Time (string) }, { functionType: 15, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212888", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0035", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` ... } ... ] ``` --- ### Batch Modify Lot batchModifyLot ##### First, using 'makeModifyLotObj' create a 'FutOptModifyLot' object[​](#first-using-makemodifylotobj-create-a-futoptmodifylot-object "Direct link to First, using 'makeModifyLotObj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lot | number | The lot after modification ( The modified lot includes the partially filled portion of this order ) | Put the returned object into the 'batchModifyLot' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | ModifyLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmodifylot) (list of object) | The object for Lot modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js // Batch lot modification ( modifying orders using the content returned by batch detail ) modify_orders = [ sdk.futopt.makeModifyLotObj(batch_res.data[0], 2), sdk.futopt.makeModifyLotObj(batch_res.data[1], 2) ] sdk.futopt.batchModifyLot(account, modify_orders); // Batch lot modification ( Using different individual orders ) modify_orders = [ sdk.futopt.makeModifyLotObj(orderResult.data[22], 2), sdk.futopt.makeModifyLotObj(orderResult.data[40], 2) ] sdk.futopt.batchModifyLot(account, modify_orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ // Batch lot modification ( modifying orders using the content returned by batch detail ) { functionType: 20, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "03100161419", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "l002D", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FIMTX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` price: 20000, // Order Price (number) lot: 3, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` afterPrice: 20000, // Valid Order Price (number) afterLot: 2, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "18:24:50", // Last Modification Time (string) }, { functionType: 20, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "03100161420", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "l002E", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FIMTX", // Symbol (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` ... } ] } Below example only extract data content [ // Batch lot modification ( Using different individual orders ) { functionType: 20, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "03100161519", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "l005D", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FIMTX", // Symbol (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` price: 20000, // Order Price (number) lot: 3, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket`, `Reference` afterPrice: 20000, // Valid Order Price (number) afterLot: 2, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "18:24:50", // Last Modification Time (string) }, { functionType: 20, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "03100161520", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "l005E", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight`, `OptionNight` currency: "TWD", // Trading Currency (string) symbol: "FIMTX", // Symbol (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` ... } ] ``` --- ### Get Batch Order Detail batchOrderDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | BatchOrderList | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#batchresult) | Batch order list | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```js const batch_order_list = sdk.futopt.batchOrderLists(account) sdk.futopt.batchOrderDetail(account, batch_order_list.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: "2024/03/05", // Transaction date (string) seqNo: "00110212608", // Order sequence number (string) branchNo: "15901", // Branch number (string) account: "1234567", // Account (string) orderNo: "C0201", // Order number (string) assetType: 1, // Asset type (number) market: "TAIMEX", // Market type (string) marketType: Future, // Trading Session Type (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: "202404", // Expiry date (string) buySell: Buy, // Buy or sell (BSAction) priceType: Limit, // Original order price type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original order quantity (number) timeInForce: ROD, // Time in force (TimeInforce) orderType: Auto, // Order type (FutOptOrderType) isPreOrder: false, // Is pre-order (bool) status: 10, // Order status (number) afterPrice: 1822.6, // Valid order price (number) afterLot: 2, // Valid order quantity (number) filledLot: 0, // Filled quantity (number) filledMoney: 0, // Filled amount (number) lastTime: "10:20:27", // Last modification time (string) }, ... ] } ``` --- ### Get Batch Order List batchOrderLists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | BatchResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------ | ---------------------------------------------------------------------------------------------- | | function\_type | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Query Date (today) | | branchNo | string | Branch number | | account | string | Account | | batchSeqNo | string | Serial number | #### Request Example[​](#request-example "Direct link to Request Example") ```js sdk.futopt.batchOrderLists(target_user) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: 0, // Type of function (number) date: '2023/10/24', // Query Date (string) branchNo: '6460', // Branch number (string) account: '26', // Account (string) batchSeqNo: '11EE72270B4D79F48000000C29304663' // serial number (string) }, ... ] } ``` --- ### Place Batch Order batchPlaceOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | OrderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#orderobject) (list of object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = [{ buySell: BSAction.Buy, symbol: "TXO20000E4", price: "530", quantity: 1, marketType: FutOptMarketType.Option, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "batch1" },{ buySell: BSAction.Buy, symbol: "TXO20000E4", price: "530", quantity: 1, marketType: FutOptMarketType.Option, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "batch2" } ]; const batch_order_results = sdk.futopt.batchPlaceOrder(account,orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: 0, // Function Type (number): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", // Transaction Date (string) seqNo: "00230177110", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0102", // Order Number (string) assetType: 2, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, // Unit (number) currency: "TWD", // Trading Currency (string) symbol: "TXO", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 20000, // Strike Price (number) callPut: Call, // Call / Put (CallPut): `Call`, `Put` buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, // Order Price (number) lots: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` orderType: Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice: 530, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 530, // Before the Price Modification (number) userDef: "batch1", // Custom Fields (string) lastTime: "11:50:08", // Last Modification Time (string) }, { functionType: 0, // Function Type (number): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", // Transaction Date (string) seqNo: "00230177111", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0103", // Order Number (string) assetType: 2, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, // Unit (number) currency: "TWD", // Trading Currency (string) symbol: "TXO", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 20000, // Strike Price (number) callPut: Call, // Call / Put (CallPut): `Call`, `Put` buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, // Order Price (number) lots: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` orderType: Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... } ] } ``` --- ### Cancel Order cancelOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) | The intended order result object to be cancel | | unblock | bool? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```cs sdk.Stock.CancelOrder(account, cancel_order, true) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 30, // Function type (number) date: "2024/03/25", // Transaction date (string) seqNo: "00110212608", // Order sequence number (string) branchNo: "15901", // Branch number (string) account: "1234567", // Account (string) orderNo: "C0001", // Order number (string) assetType: 1, // Asset type (number) market: "TAIMEX", // Market type (string) marketType: Future, // Market type category (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: "202404", // Expiry date (string) buySell: Buy, // Buy or sell (BSAction) priceType: Limit, // Original order price type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original order quantity (number) timeInForce: ROD, // Time in force (TimeInforce) orderType: Auto, // Order type (FutOptOrderType) isPreOrder: false, // Is pre-order (bool) status: 30, // Order status (number) afterPrice: 1822.6, // Valid order price (number) afterLot: 0, // Valid order quantity (number) filledLot: 0, // Filled quantity (number) filledMoney: 0, // Filled amount (number) lastTime: "13:21:34", // Last modification time (string) } } ``` --- ### Convert Symbol converSymbol #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | | symbol | string | Symbol from accounting | | expiryDate | string | Expiry Date | | strikePrice | number ( Optional ) | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) ( Optional ) | Call / Put : `Call` Call 、 `Put` Put | #### Response Parameter[​](#response-parameter "Direct link to Response Parameter") | Parameter | Type | Meaning | | --------- | ------ | ---------------------------------------- | | symbol | string | Symbol for Order or Subscribe MarketData | info You can refer to the [Enumerations table](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#month) for month codes. #### Request Example[​](#request-example "Direct link to Request Example") ```js //Future sdk.futopt.convertSymbol("FITX","202404") //Option sdk.futopt.convertSymbol("TXO","202404",20000,CallPut.Call) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js //Future "TXFD4" //Option "TXO20000D4" ``` --- ### Query Estimate Margin queryEstimateMargin #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#orderobject) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | EstimateMargin is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### EstimateMargin Parameter[​](#estimatemargin-parameter "Direct link to EstimateMargin Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------ | --------------- | | date | string | Query Date | | currency | string | Currency | | estimateMargin | number | Estimate Margin | #### Request Example[​](#request-example "Direct link to Request Example") ```js order = FutOptOrder( BSAction.Buy, "TXFE4", "20900", 1, MarketType.Future, PriceType.Limit, TimeInForce.ROD, OrderType.Auto, "From nodejs" // optional field ) sdk.futopt.queryEstimateMargin(account, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data: { date: "2024/04/10", // Query Date (string) currency: "TWD", // Currency (string) estimateMargin: 179000 // Estimate Margin (number) } } ``` --- ### Get Historical Filled filledHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Query Start Date | | endDate | string? (null or empty will equals startDate) | Query End Date | info Support historical data for the past two days #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FilledData list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FilledData Parameter[​](#filleddata-parameter "Direct link to FilledData Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | date | string | Filled Date | | branchNo | string | Branch Number | | account | string | Account | | seqNo | string | Order serial number (only display on filled callback) | | orderNo | string | Order Number | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Spread Symbol | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buySellLeg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `FdayTrade` | | filledNo | string | Filled Serial Number | | filledAvgPrice | number | Filled Average Price | | filledLot | number | Filled Lot | | filledPrice | number | Filled Price | | filledTime | string | Filled Time | | userDef | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```js const filledHistory = sdk.futopt.filledHistory(account,"20230921","20230922"); console.log(filledHistory) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: "2023/09/21", // Filled Date (string) branchNo: "6460", // Branch number (string) account: "26", // Account (string) orderNo: "bA422", // Order number (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: "Buy", // Buy / Sell (BSAction) filledNo: "00000000001", // Filled Transaction number (string) filledAvgPrice: 20890.0, // Filled Average Price (number) filledLots: 1, // Filled Lot (number) filledPrice: 20890.0, // Filled Price (number) orderType: "New", // Order Type (string) filledTime: "10:31:00.931", // Filled Time (string) }, ... ] } ``` --- ### Get Order Results getOrderResults #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = sdk.futopt.getOrderResults(accounts.data[0]); console.log(orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: null, // Function type (number) date: "2024/03/25", // Transaction date (string) seqNo: "00110212608", // Order sequence number (string) branchNo: "15901", // Branch number (string) account: "1234567", // Account (string) orderNo: "C0001", // Order number (string) assetType: 1, // Asset type (number) market: "TAIMEX", // Market type (string) marketType: Future, // Trading session type (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: "202404", // Expiry date (string) buySell: Buy, // Buy or sell (BSAction) priceType: Limit, // Original order price type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original order quantity (number) timeInForce: ROD, // Time in force (TimeInforce) orderType: Auto, // Order type (OrderType) isPreOrder: false, // Is pre-order (bool) status: 10, // Order status (number) afterPrice: 1822.6, // Valid order price (number) afterLot: 2, // Valid order quantity (number) filledLot: 0, // Filled quantity (number) filledMoney: 0, // Filled amount (number) lastTime: "10:20:27", // Last modification time (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) getOrderResultsDetail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process | | >> functionType | number | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90`Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | number | Original Order Quantity | | >> afterQty | number | Valid Order Quantity (filled quantity included) | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> errorMessage | string | Error Message | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orders = sdk.futopt.getOrderResultsDetail(accounts.data[0]); console.log(orders); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { functionType: null, // Function type (number) date: "2024/03/25", // Transaction date (string) seqNo: "00110212608", // Order sequence number (string) branchNo: "15901", // Branch number (string) account: "1234567", // Account (string) orderNo: "C0001", // Order number (string) assetType: 1, // Asset type (number) market: "TAIMEX", // Market type (string) marketType: Future, // Trading session type (FutOptMarketType) unit: 1, // Unit (number) currency: "TWD", // Currency (string) symbol: "FITF", // Symbol (string) expiryDate: "202404", // Expiry date (string) buySell: Buy, // Buy or sell (BSAction) priceType: Limit, // Original order price type (FutOptPriceType) price: 1822.6, // Price (number) lot: 2, // Original order quantity (number) timeInForce: ROD, // Time in force (TimeInforce) orderType: Auto, // Order type (OrderType) isPreOrder: false, // Is pre-order (bool) status: 10, // Order status (number) afterPrice: 1822.6, // Valid order price (number) afterLot: 2, // Valid order quantity (number) filledLot: 0, // Filled quantity (number) filledMoney: 0, // Filled amount (number) lastTime: "10:20:27", // Last modification time (string) details:[ { functionType: 10, // functionType (number) modifiedTime: "10:20:27", // Order Modified Time (string) beforeLot: 0, // Original Order Lot (number) afterLot: 2, // Valid Order Lot (number) beforePrice: 1822.6, // Original Order Price (number) afterPrice: 1822.6 // Valid Order Price (number) } ] }, ... ] } ``` --- ### Modify Order Price modifyPrice ##### First, using 'makeModifyPriceObj' create a 'FutOptModifyPrice' object[​](#first-using-makemodifypriceobj-create-a-futoptmodifyprice-object "Direct link to First, using 'makeModifyPriceObj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string? | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype)? | The price type after modification | caution When 'price' is filled, priceType should be empty or null ; otherwise, the 'price' field should be empty or null Put the returned object into the 'modifyPrice' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmodifyprice) | The object for price modification | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const modifyPriceObj = sdk.futopt.makeModifyPriceObj(target_order, "19900"); sdk.futopt.modifyPrice(accounts.data[0], modifyPriceObj) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 15, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "00110212663", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0005", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Future, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option currency: "TWD", // Trading Currency (string) symbol: "FITX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, // Order Price (number) lot: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice: 19900, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "13:39:05", // Last Modification Time (string) } } ``` --- ### Modify Order Lot modifyLot ##### First, using 'makeModifyLotObj' create a 'FutOptModifyLot' object[​](#first-using-makemodifylotobj-create-a-futoptmodifylot-object "Direct link to First, using 'makeModifyLotObj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lot | numbe | The lot after modification ( The modified lot includes the partially filled portion of this order ) | Put the returned object into the 'modifyLot' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | account | [account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | modifiedLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmodifylot) | The object for Lot modification | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | Modified content is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const modifyQtyObj = sdk.futopt.makeModifyPriceObj(target_order, 1000); sdk.futopt.modifyLot(accounts.data[0], modifyQtyObj, false) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ { functionType: 20, // Function Type (number) date: "2024/03/25", // Transaction Date (string) seqNo: "03100161319", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "l001D", // Order Number (string) assetType: 1, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: FutureNight, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option currency: "TWD", // Trading Currency (string) symbol: "FIMTX", // Symbol (string) expiryDate: "202404", // Expiry Date (string) buySell: Buy, // Buy/Sell Type (string): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, // Order Price (number) lot: 3, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice: 20000, // Valid Order Price (number) afterLot: 2, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 20000, // Before the Price Modification (number) lastTime: "18:24:40", // Last Modification Time (string) } } } ``` --- ### Get Historical Order orderHistory #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | startDate | string | Query Start Date | | endDate | string | Query End Date | | marketType | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | info Support historical data for the past two days #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process | | >> functionType | number | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90`Failed | | >> modifiedTime | string | Order Modified Time | | >> beforeQty | number | Original Order Quantity | | >> afterQty | number | Valid Order Quantity (filled quantity included) | | >> beforePrice | number | Original Order Price | | >> afterPrice | number | Valid Order Price | | >> filledMoney | number | Filled Value | | >> errorMessage | string | Error Message | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js const orderHistory = sdk.futopt.orderHistory(account,"20240410","20240411"); console.log(orderHistory); ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:[ { date: "2024/04/11", // Transaction Date (string) seqNo: "00230177314", // Order Serial Number (string) branchNo: "15000", // Branch Number (string) account: "9974825", // Account (string) orderNo: "C0020", // Order Number (string) assetType: 2, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option symbol: "TXO", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 18600, // Strike Price (number) callPut: Call, // Call / Put (CallPut): `Call`, `Put` buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 2100, // Order Price (number) lot: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` orderType: New, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 50, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPrice: 2100, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 1, // Filled Lot (number) filledMoney: 2100, // Filled Value (number) lastTime: "10:41:46.760", // Last Modification Time (string) details:[ { functionType: 10, // functionType (number) modifiedTime: "10:41:46.760", // Order Modified Time (string) beforeLot: 0, // Original Order Lot (number) afterLot: 1, // Valid Order Lot (number) beforePrice: 2100, // Original Order Price (number) afterPrice: 2100 // Valid Order Price (number) } ] }, ... ] } ``` --- ### PlaceOrder placeOrder #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#account) | Account | | orderObject | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#orderobject) | Order Object | | unblock | bool ? (default = false) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | --------- | ------------------- | ----------------------------------------------- | | isSuccess | bool | Interface result | | data | Object | FutOptOrderResult list is returned | | message | string ? (optional) | isSuccess = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | functionType | number | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction date | | seqNo | string | Order serial number | | branchNo | string | Branch number | | account | string | Account | | orderNo | string | Order number | | assetType | number | Asset type : `1` Future 、`2` Option | | market | string | Market type : `TAIMEX` Future、Option | | marketType | js:string / ts:[FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptmarkettype) | Trading session type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future 、 `OptionNight` After-Hour Option | | unit | number | Trading Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiryDate | string | Expiry Date | | strikePrice | number | Strike Price | | callPut | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySell | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbolLeg2 | string | Symbol - Spread Order | | expiryDateLeg2 | string | Expiry Date - Spread Order | | strikePriceLeg2 | number | Strike Price - Spread Order | | callPutLeg2 | js:string / ts:[CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#callput) | Call / Put Type : `Call` Call 、`Put` Put | | buySellLeg2 | js:string / ts:[BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | priceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Original order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | price | number | Order Price | | lot | number | Original order lot | | timeInForce | js:string / ts:[TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#timeinforce) | Time In Force `ROD` 、 `FOK` 、 `IOC` | | orderType | js:string / ts:[FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` | | isPreOrder | bool | Reservation Flag | | status | number | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | afterPriceType | js:string / ts:[FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/nodejs/EnumMatrix.md#futoptpricetype) | Valid order price type : `Limit` 、 `Market` 、 `RangeMarket` Market with Protection Orders 、 `Reference` | | afterPrice | number | Valid order price | | afterLot | number | Valid Order Lot | | filledLot | number | Filled Lot | | filledMoney | number | Filled Value | | beforeLot | number | Before the Lot Modification | | beforePrice | number | Before the Price Modification | | userDef | string | Custom Fields | | lastTime | string | Last Modification Time | | details | list | Order Process (Return value when query orderResultDetail or orderHistory ) | | errorMessage | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```js //Single futoptorder = { buySell: BSAction.Buy, symbol: "TXO20000E4", price: "530", lot: 1, marketType: FutOptMarketType.Option, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "nodejs" // optional field } sdk.futopt.placeOrder(account, futoptorder) // Spread futoptorder = { buySell: BSAction.Sell, symbol: "TXO20000E4", buySell2: BSAction.Buy, // optional field symbol2: "TXO19900E4", // optional field price: "90", lot: 1, marketType: FutOptMarketType.Option, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.IOC, orderType: FutOptOrderType.Auto, userDef: "nodejs" // optional field } sdk.futopt.placeOrder(account, futoptorder) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```js { isSuccess: true, data:{ functionType: 0, // Function Type (number): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", // Transaction Date (string) seqNo: "00230177010", // Order Serial Number (string) branchNo: "15901", // Branch Number (string) account: "1234567", // Account (string) orderNo: "C0002", // Order Number (string) assetType: 2, // Asset Type (number): `1` Future, `2` Option market: "TAIMEX", // Market Type (string) marketType: Option, // Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, // Unit (number) currency: "TWD", // Trading Currency (string) symbol: "TXO", // Symbol (string) expiryDate: "202404", // Expiry Date (string) strikePrice: 20000, // Strike Price (number) callPut: Call, // Call / Put (CallPut): `Call`, `Put` buySell: Buy, // Buy/Sell Type (BSAction): `Buy`, `Sell` priceType: Limit, // Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, // Order Price (number) lots: 1, // Original Order Lot (number) timeInForce: ROD, // Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` orderType: Auto, // Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade isPreOrder: false, // Reservation Order Flag (bool) status: 10, // Order Status (number): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed afterPriceType: Limit, // Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` afterPrice: 530, // Valid Order Price (number) afterLot: 1, // Valid Order Lot (number) filledLot: 0, // Filled Lot (number) filledMoney: 0, // Filled Value (number) beforeLot: 0, // Before the Lot Modification (number) beforePrice: 530, // Before the Price Modification (number) userDef: "nodejs", // Custom Fields (string) lastTime: "11:50:08", // Last Modification Time (string) } } ``` --- ### Close Position Record close\_position\_record #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query Start Date | | end\_date | string | Query End Date | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | RealizedSummary list is returned | | message | string | is\_success = False error description is returned | ##### CloseRecord Parameter[​](#closerecord-parameter "Direct link to CloseRecord Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | | date | string | Data Date | | branch\_no | string | Branch Number | | position\_kind | int | Position Kind : `1` Future 、`2` Option | | account | string | Account | | order\_no | string | Order Number | | market | string | Market Type : `TAIMEX` Future 、 Option | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell : `Buy` Buy、`Sell` Sell | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | price | float | Deal Price | | orig\_lots | int | Original Lots | | transaction\_fee | float | Transaction Fee | | tax | float | Tax | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt_accounting.close_position_record(accounts,"20240310","20240410") ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ CloseRecord { date: "2024/04/10", # Date (string) branch_no: "15000", # Branch Number (string) account: "9974825", # Account (string) position_kind: 1, # Position Kind : `1` Futures, `2` Options (int) order_no: "15001-0000", # Order Number (string) market: "TAIMEX", # Market : `TAIMEX` Futures, Options (string) symbol: "FITX", # Symbol (string) expiry_date: 202404, # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call/Put Type : `Call` Call, `Put` Put (int) buy_sell: Buy, # Buy/Sell Type : `Buy`, `Sell` (int) price: 20847.0, # Deal Price (float) orig_lots: 1, # Original Lots (int) transaction_fee: 40.0, # Transaction Fee (float) tax: 83.0, # Tax (float) }, CloseRecord { date: "2024/04/10", # Date (string) branch_no: "15000", # Branch Number (string) account: "9974825", # Account (string) position_kind: 1, # Position Kind : `1` Futures, `2` Options (int) order_no: "C0005-0000", # Order Number (string) market: "TAIMEX", # Market : `TAIMEX` Futures, Options (string) symbol: "FITX", # Symbol (string) expiry_date: 202405, # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call/Put Type : `Call` Call, `Put` Put (int) buy_sell: Buy, # Buy/Sell Type : `Buy`, `Sell` (int) price: 20890.0, # Deal Price (float) orig_lots: 1, # Original Lots (int) transaction_fee: 40.0, # Transaction Fee (float) tax: 84.0, # Tax (float) } ] } ``` --- ### Hybrid Position hybrid\_position #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Inventory list is returned | | message | string | is\_success : False error description is returned | ##### Position Parameter[​](#position-parameter "Direct link to Position Parameter") | 參數 | 類別 | 說明 | | ---------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | > date | string | Transaction Date | | > branch\_no | string | Branch Number | | > account | string | Account | | > is\_spread | bool | Spread Order Flag | | > position\_kind | int | Position Kind : `1` Future 、`2` Option | | > symbol | string | Symbol | | > expiry\_date | int | Expiry Date | | > strike\_price | float | Strike Price | | > call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | > buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | > price | float | Cost Price | | > orig\_lots | int | Original Lot | | > tradable\_lots | int | Available Lot | | > order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | > currency | string | Currency | | > market\_price | string | Market Price | | > initial\_margin | float | Initial Margin | | > maintenance\_margin | float | Maintenance Margin | | > clearing\_margin | float | Clearing Margin | | > opt\_value | float | Option market value | | > opt\_long\_value | float | Long Option market value | | > opt\_short\_value | float | Short Option market value | | > profit\_or\_loss | float | Profit or Loss | | > premium | float | Premium | | > spread | object | Spread Detail | | >> date | string | Transaction Date | | >> branch\_no | string | Branch Number | | >> account | string | Account | | >> is\_spread | bool | Spread Order Flag | | >> position\_kind | int | Position Kind : `1` Future 、`2` Option | | >> symbol | string | Symbol | | >> expiry\_date | int | Expiry Date | | >> strike\_price | float | Strike Price | | >> call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call` Call 、`Put` Put | | >> buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、`Sell` | | >> price | float | Cost Price | | >> orig\_lots | int | Original Lot | | >> tradable\_lots | int | Available Lot | | >> order\_type | \[FutOptOrderType] (/docs/trading-future/library/python/EnumMatrix/#futoptordertype) | Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade | | >> currency | string | Currency | | >> market\_price | string | Market Price | | >> initial\_margin | float | Initial Margin | | >> maintenance\_margin | float | Maintenance Margin | | >> clearing\_margin | float | Clearing Margin | | >> opt\_value | float | Option market value | | >> opt\_long\_value | float | Long Option market value | | >> opt\_short\_value | float | Short Option market value | | >> profit\_or\_loss | float | Profit or Loss | | >> premium | float | PreMium | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt_accounting.hybrid_position(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ Position { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : False, # Spread Order Flag (bool) position_kind : 1, # Position Kind : `1` Future 、`2` Option (int) symbol : "FITX", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : None, # Strike Price (int or None) call_put : None, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 20325.3333, # Cost Price (float) orig_lots : 3, # Original Lot (int) tradable_lots : 3, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "20351", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 0.0, # Option market value (float) opt_long_value : 0.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : 0.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : None, # Spread Detail (List[SpreadPosition]) }, Position { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : False, # Spread Order Flag (bool) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int)) symbol : "TX1", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : 206000, # Strike Price (float) call_put : Call, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 10, # Cost Price (int) orig_lots : 4, # Original Lot (int) tradable_lots : 4, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "4.6", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 920.0, # Option market value (float) opt_long_value : 920.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : -1080.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : None, # Spread Detail (List[SpreadPosition]) }, Position { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : False, # Spread Order Flag (bool) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int) symbol : "TXO", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : 198000, # Strike Price (float) call_put : Call, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Sell, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 243, # Cost Price (int) orig_lots : 2, # Original Lot (int) tradable_lots : 2, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "46", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 4600.0, # Option market value (float) opt_long_value : 4600.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : -19700.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : None, # Spread Detail (List[SpreadPosition]) } Position { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : False, # Spread Order Flag (bool) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int) symbol : "TXO", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : 200000, # Strike Price (float) call_put : Put, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 344, # Cost Price (int) orig_lots : 2, # Original Lot (int) tradable_lots : 2, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "82", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 8200.0, # Option market value (float) opt_long_value : 8200.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : -26200.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : None, # Spread Detail (List[SpreadPosition]) }, Position { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) is_spread : True, # Spread Order Flag (bool) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int) symbol : "TXO20100D4:20000P4", # Symbol (str) expiry_date : "1", # Expiry Date (string) strike_price : 1, # Strike Price (float) call_put : None, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : None, # Cost Price (int) orig_lots : 2, # Original Lot (int) tradable_lots : 2, # Available Lot (int) order_type : New, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "0.0", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 0.0, # Option market value (float) opt_long_value : 0.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : 0.0, # Profit or Loss (float) premium : 0.0, # Premium (float) spreads : [ # Spread Detail (List[SpreadPosition]) SpreadPosition { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int) symbol : "TXO", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : 201000, # Strike Price (float) call_put : Call, # Call / Put : `Call` 、`Put` (CallPut) buy_sell : Buy, # Buy/Sell Type : `Buy` 、`Sell` (BSAction) price : 185, # Cost Price (int) orig_lots : 2, # Original Lot (int) tradable_lots : 2, # Available Lot (int) order_type : None, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "365", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0,# Initial Margin (float) opt_value : 36500.0, # Option market value (float) opt_long_value : 36500.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : 18000.0, # Profit or Loss (float) premium : 0.0, # Premium (float) }, SpreadPosition { date : "2024/04/08", # Transaction Date (str) branch_no : "15901", # Branch Number (str) account : "1234567", # Account (str) position_kind : 2, # Position Kind : `1` Future 、`2` Option (int) symbol : "TXO", # Symbol (str) expiry_date : "202404", # Expiry Date (string) strike_price : 201000, # Strike Price (float) call_put : Put, # Call / Put : `Call` 、`Put` (int) buy_sell : Buy, # Buy/Sell Type : `Buy`、`Sell` (BSAction) price : 0, # Cost Price (int) orig_lots : 2, # Original Lot (int) tradable_lots : 2, # Available Lot (int) order_type : None, # Order Type : `New` Open、`Close` Close、`FdayTrade` DayTrade (FutOptOrderType) currency : "TWD", # Currency (str) market_price : "0.0", # Market Price (str) initial_margin : 0.0, # Initial Margin (float) maintenance_margin : 0.0, # Maintenance Margin (float) clearing_margin : 0.0, # Clearing Margin (float) initial_margin_all_single : 0.0, # Initial Margin (float) opt_value : 0.0, # Option market value (float) opt_long_value : 0.0, # Long Option market value (float) opt_short_value : 0.0, # Short Option market value (float) profit_or_loss : 0.0, # Profit or Loss (float) premium : 0.0, # Premium (float) }, ], } ] } ``` --- ### Query Equity query\_margin\_equity #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Equity list is returned | | message | string | is\_success = False error description is returned | ##### Equity Parameter[​](#equity-parameter "Direct link to Equity Parameter") Return type : Object | Parameter | Type | Meaning | | -------------------- | ------ | -------------------------------------------------------------------------------------------------------------------- | | date | string | Query Date | | branch\_no | string | Branch Number | | account | string | Account | | currency | string | Currency : `NTD` TWD equivalents 、`TWD` New Taiwan Dollars、`USD` US Dollars、`CNY` ChiNa Yuan 、`JPY` Japanese Yen | | yesterday\_balance | float | Yesterday Balance | | today\_balance | float | Today's Balance | | initial\_margin | float | Initial Margin | | maintenance\_margin | float | Maintenace Margin | | clearing\_margin | float | Clearing Margin | | today\_equity | float | Today's Equity | | today\_deposit | float | Today's Deposit | | today\_withdrawal | float | Today's Withdrawal | | today\_trading\_fee | float | Today's Trading Fee | | today\_trading\_tax | float | Today's Trading Tax | | receivable\_premium | float | Receivable Premium | | payable\_premium | float | Payable Premium | | excess\_margin | float | Excess Margin | | available\_margin | float | Available Margin | | disgorgement | float | Disgorgement | | opt\_pnl | float | Option Profit or loss | | opt\_value | float | Option Market Value | | opt\_long\_value | float | Long Option Market Value | | opt\_short\_value | float | Short Option Market Value | | fut\_realized\_pnl | float | Future Realized Profit or Loss | | fut\_unrealized\_pnl | float | Future Unrealized Profit or Loss | | buy\_lot | int | Buying Lot | | sell\_lot | int | Selling Lot | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt_accounting.query_margin_equity(account) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data : [ Equity({ date: "2024/04/08", # Query Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) currency: "NTD", # Currency (string) yesterday_balance: 22435152.4, # Yesterday Balance (float) today_balance: 22434910.4, # Today's Balance (float) initial_margin: 1114946.0, # Initial Margin (float) maintenance_margin: 939214.0, # Maintenance Margin (float) clearing_margin: 915760.0, # Clearing Margin (float) today_equity: 22694910.4, # Today's Equity (float) today_deposit: 0.0, # Today's Deposit (float) today_withdrawal: 2102.0, # Today's Withdrawal (float) today_trading_fee: 16.0, # Today's Trading Fee (float) today_trading_tax: 0.0, # Today's Trading Tax (float) receivable_premium: 0.0, # Receivable Premium (float) payable_premium: 9250.0, # Payable Premium (float) excess_margin: 28744525.0, # Excess Margin (float) available_margin: 21453562.4, # Available Margin (float) disgorgement: 0.0, # Disgorgement (float) opt_pnl: -248600.0, # Option Profit or Loss (float) opt_value: -193100.0, # Option Market Value (float) opt_long_value: 311900.0, # Long Option Market Value (float) opt_short_value: 505000.0, # Short Option Market Value (float) fut_realized_pnl: 0.0, # Future Realized Profit or Loss (float) fut_unrealized_pnl: 60700.0, # Future Unrealized Profit or Loss (float) buy_lot: 22, # Buying Lot (int) sell_lot: 7 # Selling Lot (int) }), Equity({ date: "2024/04/08", # Query Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) currency: "TWD", # Currency (string) yesterday_balance: 19880310.0, # Yesterday Balance (float) today_balance: 19880068.0, # Today's Balance (float) initial_margin: 1114946.0, # Initial Margin (float) maintenance_margin: 939214.0, # Maintenance Margin (float) clearing_margin: 915760.0, # Clearing Margin (float) today_equity: 20140068.0, # Today's Equity (float) today_deposit: 0.0, # Today's Deposit (float) today_withdrawal: 2102.0, # Today's Withdrawal (float) today_trading_fee: 16.0, # Today's Trading Fee (float) today_trading_tax: 0.0, # Today's Trading Tax (float) receivable_premium: 0.0, # Receivable Premium (float) payable_premium: 9250.0, # Payable Premium (float) excess_margin: 28744525.0, # Excess Margin (float) available_margin: 18898720.0, # Available Margin (float) disgorgement: 0.0, # Disgorgement (float) opt_pnl: -248600.0, # Option Profit or Loss (float) opt_value: -193100.0, # Option Market Value (float) opt_long_value: 311900.0, # Long Option Market Value (float) opt_short_value: 505000.0, # Short Option Market Value (float) fut_realized_pnl: 0.0, # Future Realized Profit or Loss (float) fut_unrealized_pnl: 60700.0, # Future Unrealized Profit or Loss (float) buy_lot: 22, # Buying Lot (int) sell_lot: 7 # Selling Lot (int) }), ... ] } ``` --- ### Query Single Position query\_single\_position #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ------------------------------------------------------------------------------------------------------ | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Position list is returned | | message | string | is\_success = False error description is returned | ##### Position Example[​](#position-example "Direct link to Position Example") Return type : Object | Parameter | Type | Meaning | | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | date | string | Transaction Date | | branch\_no | string | Branch Number | | account | string | Account | | is\_spread | bool | Spread Flag | | position\_kind | int | Position Kind : `1` Future 、`2` Option | | symbol | string | Symbol | | expiry\_date | int | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put Type : `1` Call 、`2` Put | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy / Sell Type : `Buy` 、`Sell` | | price | float | Cost Price | | orig\_lots | int | Original Lot | | tradable\_lots | int | Available Lot | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` Open Position、`Close` Close、`FdayTrade` DayTrade | | currency | string | Currency | | market\_price | string | Market Price | | initial\_margin | float | Initial Margin | | maintenance\_margin | float | Maintenance Margin | | clearing\_margin | float | Clearing Margin | | opt\_value | float | Option market value | | opt\_long\_value | float | Long Option market value | | opt\_short\_value | float | Short Option market value | | profit\_or\_loss | float | Profit or Loss | | premium | float | Premium | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt_accounting.query_single_position(accounts) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ Position { date: "2024/04/08", # Transaction Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l0001-0000", # Order Number (string) position_kind: 1, # Position Kind (int) symbol: "FITX", # Symbol (string) expiry_date: 202404, # Expiry Date (int) strike_price: None, # Strike Price (float) call_put: None, # Call/Put Type (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction) price: 20362, # Cost Price (float) orig_lots: 2, # Original Lot (int) tradable_lot: 2, # Tradable Lot (int) order_type: New, # Order Type (FutOptOrderType) currency: "TWD", # Currency (string) market_price: "20521.0000", # Market Price (string) initial_margin: 358000.0, # Initial Margin (float) maintenance_margin: 274000.0, # Maintenance Margin (float) clearing_margin: 264000.0, # Clearing Margin (float) profit_or_loss: 63600.0, # Profit or Loss (float) premium: 0.0, # Premium (float) }, Position { date: "2024/03/29", # Transaction Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l0007-0000", # Order Number (string) position_kind: 2, # Position Kind (int) symbol: "TX1", # Symbol (string) expiry_date: 202404, # Expiry Date (int) strike_price: 20600, # Strike Price (float) call_put: Call, # Call/Put Type (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction) price: 10, # Cost Price (float) orig_lots: 2, # Original Lot (int) tradable_lot: 2, # Tradable Lot (int) order_type: New, # Order Type (FutOptOrderType) currency: "TWD", # Currency (string) market_price: "4.6000", # Market Price (string) initial_margin: 52660.0, # Initial Margin (float) maintenance_margin: 36460.0, # Maintenance Margin (float) clearing_margin: 34460.0, # Clearing Margin (float) profit_or_loss: -540.0, # Profit or Loss (float) premium: -1000.0, # Premium (float) }, Position { date: "2024/03/29", # Transaction Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l0007-0001", # Order Number (string) position_kind: 2, # Position Kind (int) symbol: "TX1", # Symbol (string) expiry_date: 202404, # Expiry Date (int) strike_price: 20600, # Strike Price (float) call_put: Call, # Call/Put Type (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction) price: 10, # Cost Price (float) orig_lots: 2, # Original Lot (int) tradable_lot: 2, # Tradable Lot (int) order_type: New, # Order Type (FutOptOrderType) currency: "TWD", # Currency (string) market_price: "4.6000", # Market Price (string) initial_margin: 52660.0, # Initial Margin (float) maintenance_margin: 36460.0, # Maintenance Margin (float) clearing_margin: 34460.0, # Clearing Margin (float) profit_or_loss: -540.0, # Profit or Loss (float) premium: -1000.0, # Premium (float) }, Position { date: "2024/03/01", # Transaction Date (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l0002-0000", # Order Number (string) position_kind: 2, # Position Kind (int) symbol: "TXO", # Symbol (string) expiry_date: 202404, # Expiry Date (int) strike_price: 18500, # Strike Price (float) call_put: Call, # Call/Put Type (CallPut) buy_sell: Sell, # Buy/Sell Type (BSAction) price: 625, # Cost Price (float) orig_lots: 5, # Original Lot (int) tradable_lot: 4, # Tradable Lot (int) order_type: New, # Order Type (FutOptOrderType) currency: "TWD", # Currency (string) market_price: "2020.0000", # Market Price (string) initial_margin: 584000.0, # Initial Margin (float) maintenance_margin: 544000.0, # Maintenance Margin (float) clearing_margin: 536000.0, # Clearing Margin (float) profit_or_loss: -279000.0, # Profit or Loss (float) premium: 125000.0, # Premium (float) } ] } ``` --- ### List of Enumerations #### Class[​](#class "Direct link to Class") Class ##### OrderObject[​](#orderobject "Direct link to OrderObject") | Parameter | Type | Meaning | | --------------------- | ---------------- | ---------------------------------------------------------------------------------------------- | | buy\_sell | BSAction | [Buy/Sell Type](#bsaction) valid in `Buy` 、 `Sell` | | symbol | string | Symbol | | buy\_sell2 (optional) | BSAction | Spread Order [Buy/Sell Type](#bsaction) | | symbol2 (optional) | string | Spread Order Symbol | | price | string | Order Price | | lot | int | Order Lot | | market\_type | FutOptMarketType | [Trading Session](#futoptmarkettype) valid in `Future`、`Option`、`FutureNight`、`OptionNight` | | price\_type | FutOptPriceType | [Price Type](#futoptpricetype) valid in `Limit`、`Market`、 `RangeMarket`、`Reference` | | time\_in\_force | TimeInForce | [Time In Force](#timeinforce) valid in `ROD`、`FOK`、`IOC` | | order\_type | FutOptOrderType | [Order Type](#futoptordertype) valid in `New`、`Close`、`Auto`、`FdayTrade` | | user\_def (optional) | string | Customer Field (Up to 10 characters, no special characters supported) | caution If FutOptPriceType.Limit, the 'price' field must be filled; otherwise, the 'price' field should be empty or None ##### FutOptOrderResult[​](#futoptorderresult "Direct link to FutOptOrderResult") OrderResult,You can using [get\_order\_result(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/trade/GetOrderResults.md) get data. | Parameter | Type | Meaning | | ------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | FutOptMarketType | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | string | Call / Put : `Call`、`Put` | | buy\_sell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | string | Call / Put - Spread Order: `Call` 、 `Put` | | buy\_sell\_leg2 | BSAction | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | FutOptPriceType | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | TimeInForce | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | FutOptOrderType | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` InQueue、`9` TimeOut 、 `10` New Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | FutOptPriceType | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | unit | int | Trading Unit | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | error\_message | string | Error Message | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | >> function\_type | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`50` Fully Filled 、`90`Failed | | >> modified\_time | string | Order Modified Time | | >> before\_lot | int | Original Order Lot | | >> after\_lot | int | Valid Order Lot | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> error\_message | string | Error Message | ##### BatchResult[​](#batchresult "Direct link to BatchResult") BatchResult,You can using [BatchOrderLists(accounts)](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/trade/batchOrder/BatchOrderList.md) get data. | Parameter | Type | Meaning | | -------------- | ------ | ---------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel | | date | string | Date | | branch\_no | string | Branch Number | | account | string | Account | | batch\_seq\_no | string | Batch Serial Number | ##### FutOptModifyPrice[​](#futoptmodifyprice "Direct link to FutOptModifyPrice") Modified Price Object | Parameter | Type | Meaning | | ----------------- | --------------- | ---------------------------------------------------------------------------------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | price | string | The price after modification | | Price\_type | FutOptPriceType | The price type after modification : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | ##### FutOptModifyLot[​](#futoptmodifylot "Direct link to FutOptModifyLot") Modified Lot Object | Parameter | Type | Meaning | | ----------------- | ------ | --------------------------------------- | | FutOptOrderResult | Object | [FutOptOrderResult](#futoptorderresult) | | lot | int | The lot after modification | ##### FutOptFilledData[​](#futoptfilleddata "Direct link to FutOptFilledData") Filled Data Object | Parameter | Type | Meaning | | ------------------ | -------- | ----------------------------------------------------- | | date | string | Filled Date | | branch\_no | string | Branch Number | | account | string | Account | | seq\_no | string | Order Serial Number (only display on filled callback) | | order\_no | string | Order Number | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | CallPut | Call / Put : `Call`、`Put` | | buy\_sell | BSAction | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strik\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | CallPut | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | BSAction | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | filled\_no | string | Filled Serial Number | | filled\_avg\_price | float | Filled Average Price | | filled\_qty | int | Filled Share | | filled\_price | float | Filled Price | | filled\_time | string | Filled Time | | user\_def | string | Custom Fields (only display on filled callback) | ##### Account[​](#account "Direct link to Account") Account Information | Parameter | Type | Meaning | | ------------- | ------ | ---------------------------------- | | name | string | Customer Name | | account | string | Account | | branch\_no | string | Branch Number | | account\_type | string | Account Type : `stock` 、 `futopt` | #### Constants ( Corresponding Values for Returned Fields )[​](#constants--corresponding-values-for-returned-fields- "Direct link to Constants ( Corresponding Values for Returned Fields )") ##### BSAction[​](#bsaction "Direct link to BSAction") Buy / Sell Type | Name | Meaning | | ---- | ------- | | Buy | Buy | | Sell | Sell | ##### CallPut[​](#callput "Direct link to CallPut") Call / Put Type | Name | Meaning | | ---- | ------- | | Call | Call | | Put | Put | ##### FutOptMarketType[​](#futoptmarkettype "Direct link to FutOptMarketType") Trading Session Type | Name | Meaning | | ----------- | ----------------- | | Future | Future Commodity | | Option | Option Commodity | | FutureNight | After-Hour Future | | OptionNight | After-Hour Option | ##### FutOptPriceType[​](#futoptpricetype "Direct link to FutOptPriceType") Price Type | Name | Meaning | | ----------- | ----------------------------- | | Limit | Limit | | Market | Market | | RangeMarket | Market with Protection Orders | | Reference | Reference Price | ##### TimeInForce[​](#timeinforce "Direct link to TimeInForce") Time In Force | Name | Meaning | | ---- | ------------------- | | ROD | Rest of Day | | FOK | Fill-or-Kill | | IOC | Immediate-or-Cancel | ##### FutOptOrderType[​](#futoptordertype "Direct link to FutOptOrderType") Order Type | Name | Meaning | | --------- | -------------- | | New | Open Position | | Close | Close Position | | Auto | Auto | | FdayTrade | DayTrade | ##### function\_type[​](#function_type "Direct link to function_type") Function Type | Name | Value | | ----------------- | ----- | | New Order | 0 | | Execute New Order | 10 | | Amend Price | 15 | | Amend Lot | 20 | | Cancel Order | 30 | ##### market[​](#market "Direct link to market") Market Category | Name | Value | | --------------- | ------ | | Future / Option | TAIMEX | ##### status[​](#status "Direct link to status") Order Status | Name | Value | | ------------------------ | ---------------------------------------------------------------------------------------------------- | | Reservation | 0 | | InQueue | 4 (Using GetOrderResult retrieve the latest status) | | TimeOut | 9 (Please wait a moment and use GetOrderResult retrieve the latest status ; or connect your agency) | | New Order | 10 | | Cancel | 30 | | Fully filled | 50 | | Modified Price Failed | 19 | | Modified Quantity Failed | 29 | | Cancel Order Failed | 39 | | Failed | 90 | #### Month[​](#month "Direct link to Month") Month Code ##### Future[​](#future "Direct link to Future") | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | ##### Option[​](#option "Direct link to Option") Call | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | A | B | C | D | E | F | | Jul | Aug | Sep | Oct | Nov | Dec | | G | H | I | J | K | L | Put | Jan | Feb | Mar | Apr | May | Jun | | --- | --- | --- | --- | --- | --- | | M | N | O | P | Q | R | | Jul | Aug | Sep | Oct | Nov | Dec | | S | T | U | V | W | X | --- ### Login apikey\_login Version Info. Available since v2.2.7 For more information, please refer to [API Key Introduction](https://www.fbs.com.tw/TradeAPI/en/docs/trading/api-key-apply.md) #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ------ | ---------------------- | | personal\_id | String | Login ID | | key | String | Your API Key | | cert\_path | String | Certification Path | | cert\_pass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Account list is returned | | message | string | is\_success = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ------------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branch\_no | String | Branch Number | | account\_type | String | Account Type: value in `stock` and `futopt` | ##### Reqeust Example[​](#reqeust-example "Direct link to Reqeust Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.apikey_login("Your ID", "Your key","Your Cert Path","Your Cert Password") print(accounts) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : Account{ name: "富邦Bill", # Account Name (string) account: "28", # Account Number (string) branch_no: "6460", # Branch Number (string) account_type: "stock" # Account Type (string) } } ``` --- ### Login login #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ------ | ---------------------- | | personal\_id | String | Login ID | | password | String | Login Password | | cert\_path | String | Certification Path | | cert\_pass | String | Certification password | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Account list is returned | | message | string | is\_success = False error description is returned | ##### Account Parameter[​](#account-parameter "Direct link to Account Parameter") Return type : Object | Parameter | Type | Meaning | | ------------- | ------ | ------------------------------------------- | | name | String | Account Name | | account | String | Account Number | | branch\_no | String | Branch Number | | account\_type | String | Account Type: value in `stock` and `futopt` | ##### Reqeust Example[​](#reqeust-example "Direct link to Reqeust Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password","Your Cert Path","Your Cert Password") print(accounts) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : Account{ name: "富邦Bill", # Account Name (string) account: "28", # Account Number (string) branch_no: "6460", # Branch Number (string) account_type: "stock" # Account Type (string) } } ``` --- ### Logout logout #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ---- | ---------------- | | is\_success | bool | Interface result | #### Request Example[​](#request-example "Direct link to Request Example") ```py from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, OrderType, PriceType, MarketType, BSAction sdk = FubonSDK() sdk.logout() ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py True ``` --- ### Batch Cancel Order batch\_cancel\_Order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | cancel\_object | [FutOptOrderResult(List)](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) (list of object) | The object list for cancel | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch Cancel( Using the content returned by batch detail ) cancel_object = [ batch_results_detail.data[0], batch_results_detail.data[1], ] sdk.stock.batch_cancel_order(account, cancel_object) # Batch Cancel ( Using different individual orders ) cancel_object = [ orders.data[37], orders.data[35], ] sdk.stock.batch_cancel_order(account, cancel_object) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ FutOptOrderResult{ # Batch Cancel( Using the content returned by batch detail ) function_type: 30, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212608", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0001", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Market type category (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order quantity (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 30, # Order status (int) after_price_type: None, # Valid order price type (FutOptPriceType) after_price: 1822.6, # Valid order price (float) after_lot: 0, # Valid order quantity (int) filled_lot: 0, # Filled quantity (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "13:21:34", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error message (string) }, FutOptOrderResult{ function_type: 30, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212609", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0002", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Market type category (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order quantity (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 30, # Order status (int) ... }] } Below example only extract data content [FutOptOrderResult({ # Batch Cancel ( Using different individual orders ) function_type: 30, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212708", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0011", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Market type category (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order quantity (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 30, # Order status (int) after_price_type: None, # Valid order price type (FutOptPriceType) after_price: 1822.6, # Valid order price (float) after_lot: 0, # Valid order quantity (int) filled_lot: 0, # Filled quantity (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "13:30:34", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error message (string) }, FutOptOrderResult{ function_type: 30, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212709", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0012", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Market type category (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order quantity (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 30, # Order status (int) ... })] ``` --- ### Batch Modify Price batch\_modify\_price ##### First, using 'make\_modify\_price\_obj' create a 'FutOptModifyPrice' object[​](#first-using-make_modify_price_obj-create-a-futoptmodifyprice-object "Direct link to First, using 'make_modify_price_obj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | The price type after modification | caution When 'price' is filled, priceType should be empty or None ; otherwise, the 'price' field should be empty or None Put the returned object into the 'modify\_price' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmodifyprice) (list of object) | The object for price modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch price modification ( modifying orders using the content returned by batch detail ) modify_objects = [ sdk.futopt.make_modify_price_obj(batch_results_detail.data[0], "19900"), sdk.futopt.make_modify_price_obj(batch_results_detail.data[1], "19900"), ] sdk.futopt.batch_modify_price(target_user, modify_objects) # Batch price modification ( Using different individual orders ) modify_objects = [ sdk.futopt.make_modify_price_obj(orders.data[37], "19900"), sdk.futopt.make_modify_price_obj(orders.data[35], "19900"), ] sdk.futopt.batch_modify_price(target_user, modify_objects) ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data :[ FutOptOrderResult{ # Batch price modification ( modifying orders using the content returned by batch detail ) function_type: 15, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "00110212563", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0017", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Future, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FITX", # Symbol (string) expiry_date: "0", # Expiry Date (string) strike_price: 0, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 19900, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "13:39:55", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, FutOptOrderResult{ function_type: 15, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "00110212564", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0018", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Future, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FITX", # Symbol (string) expiry_date: "0", # Expiry Date (string) strike_price: 0, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New ... }] } Below example only extract data content [FutOptOrderResult({ # Batch price modification ( Using different individual orders ) function_type: 15, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "00110212863", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0020", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Future, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FITX", # Symbol (string) expiry_date: "0", # Expiry Date (string) strike_price: 0, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 19900, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "13:40:05", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, FutOptOrderResult{ function_type: 15, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "00110212864", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0021", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Future, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FITX", # Symbol (string) expiry_date: "0", # Expiry Date (string) strike_price: 0, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New ... })] ``` --- ### Batch Modify Lot batch\_modify\_lot ##### First, using 'make\_modify\_lot\_obj' create a 'FutOptModifyLot' object[​](#first-using-make_modify_lot_obj-create-a-futoptmodifylot-object "Direct link to First, using 'make_modify_lot_obj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lot | int | The lot after modification ( The modified lot includes the partially filled portion of this order ) | Put the returned object into the 'modify\_lot' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | account | Account | Account | | ModifyLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmodifylot) (list of object ) | The object for Lot modification | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Batch lot modification ( modifying orders using the content returned by batch detail ) modify_objects = [ sdk.futopt.make_modify_lot_obj(batch_results_detail.data[0], 2), sdk.futopt.make_modify_lot_obj(batch_results_detail.data[1], 2), ] sdk.futopt.batch_modify_lot(target_user, modify_objects) # Batch lot modification ( Using different individual orders ) modify_objects = [ sdk.futopt.make_modify_lot_obj(orders.data[37], 2), sdk.futopt.make_modify_lot_obj(orders.data[35], 2), ] sdk.futopt.batch_modify_lot(target_user, modify_objects) ``` ##### Response[​](#response "Direct link to Response") ```py Result { is_success: True, message: None, data :[ FutOptOrderResult{ # Batch lot modification ( modifying orders using the content returned by batch detail ) function_type: 20, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "03100161419", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l002D", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: FutureNight, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FIMTX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (string) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 3, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 20000, # Valid Order Price (float) after_lot: 2, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "18:24:50", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, FutOptOrderResult{ function_type: 20, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "03100161420", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l002E", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: FutureNight, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FIMTX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (string) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 3, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... }] } Below example only extract data content [FutOptOrderResult({ # Batch lot modification ( Using different individual orders ) function_type: 20, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "03100161519", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l003D", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: FutureNight, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FIMTX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSaction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 3, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 20000, # Valid Order Price (float) after_lot: 2, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "18:24:45", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }), FutOptOrderResult({ function_type: 20, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "03100161520", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l003E", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: FutureNight, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FIMTX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (string) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 3, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed ... })] ``` --- ### Get Batch Order Detail batch\_order\_detail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------------ | ------------------------------------------------------------------------------------------------------- | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | batch\_order\_list | [BatchResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#batchresult) | Batch order list | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | caution This function is only for querying the execution results of batch orders. To obtain the latest status of an order, please use the single order inquiry function. #### Request Example[​](#request-example "Direct link to Request Example") ```py batch_results = sdk.futopt.batch_order_lists(account) sdk.futopt.batch_order_detail(account, batch_results.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ FutOptOrderResult{ function_type: None, # Function type (int) date: "2024/03/05", # Transaction date (string) seq_no: "00110212608", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0201", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Trading Session Type (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Symbol - Spread Order (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order Lot (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (FutOptPriceType) after_price: 1822.6, # Valid order price (float) after_lot: 2, # Valid order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "10:20:27", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error message (string) }, FutOptOrderResult{ function_type: None, # Function type (int) date: "2024/03/05", # Transaction date (string) seq_no: "00110212609", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0202", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Trading Session Type (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Symbol - Spread Order (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order Lot (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (FutOptPriceType) after_price: 1822.6, # Valid order price (float) after_lot: 2, # Valid order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "10:20:27", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error message (string) }] } ``` --- ### Get Batch Order List batch\_order\_lists #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | BatchResult list is returned | | message | string | is\_success = False error description is returned | ##### BatchResult Parameter[​](#batchresult-parameter "Direct link to BatchResult Parameter") Return type : Object | Parameter | Type | Meaning | | -------------- | ------ | ------------------------------------------------------------------------------------------------------------ | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Query Date (today) | | branch\_no | string | Branch number | | account | string | Account | | batch\_seq\_no | string | Serial number | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.batch_order_lists(account) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ BatchResult{ function_type: 0, # Function Type (int) date: "2023/10/16", # Trading Date (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) batch_seq_no: "11EE6BC3B85670DE8000000C29304663" # Batch Order Serial Number (string) }, BatchResult{ function_type: 15, # Function Type (int) date: "2023/10/16", # Trading Date (string) branch_no: "6460", # Branch Number (string) account: "26", # Account (string) batch_seq_no: "11EE6BC3E189F02A8000000C29304663" # Batch Order Serial Number (string) }, ... ] } ``` --- ### Place Batch Order batch\_place\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | Order\_object | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#orderobject) (list of object) | Order Object | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py orders = [ FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "530", lot = 1, market_type = FutOptMarketType.Option, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ), FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "530", lot = 1, market_type = FutOptMarketType.Option, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) ] sdk.futopt.batch_place_order(target_user, orders) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data :[ FutOptOrderResult{ function_type: 0, # Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", # Transaction Date (string) seq_no: "00230177210", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0002", # Order Number (string) asset_type: 2, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Option, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "TXO", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: 20000, # Strike Price (float) call_put: Call, # Call / Put (CallPut): `Call`, `Put` buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, # Order Price (float) lots: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` order_type: Auto, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 4, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 530, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 530, # Before the Price Modification (float) user_def: "From_Py", # Custom Fields (string) last_time: "11:50:58", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }, FutOptOrderResult{ function_type: 0, # Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", # Transaction Date (string) seq_no: "00230177211", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0003", # Order Number (string) asset_type: 2, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Option, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "TXO", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: 20000, # Strike Price (float) call_put: Call, # Call / Put (CallPut): `Call`, `Put` buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, # Order Price (float) lots: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` order_type: Auto, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 4, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 530, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 530, # Before the Price Modification (float) user_def: "From_Py", # Custom Fields (string) last_time: "11:50:58", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) }] } ``` --- ### Cancel Order cancel\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | order\_result | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) | The intended order result object to be cancel | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.cancel_order(account, cancel_order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : FutOptOrderResult{ function_type: 30, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212608", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0001", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Market type category (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (FutOptPriceType) price: 1822.6, # Price (float) lot: 2, # Original order lot (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (FutOptOrderType) is_pre_order: false, # Is pre-order (bool) status: 30, # Order status (int) after_price_type: None, # Valid order price type (FutOptPriceType) after_price: 1822.6, # Valid order price (float) after_lot: 0, # Valid order lot (int) filled_lot: 0, # Filled lot (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "13:21:34", # Last modification time (string) error_message: None # Error message (string) } } ``` --- ### Convert Symbol conver\_symbol #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | | symbol | string | Symbol from accounting | | expiry\_date | string | Expiry Date | | strike\_price | float ( Optional ) | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) ( Optional ) | Call / Put : `Call` Call 、 `Put` Put | #### Response Parameter[​](#response-parameter "Direct link to Response Parameter") | Parameter | Type | Meaning | | --------- | ------ | ---------------------------------------- | | symbol | string | Symbol for Order or Subscribe MarketData | info You can refer to the [Enumerations table](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#month) for month codes. #### Request Example[​](#request-example "Direct link to Request Example") ```py #Future sdk.futopt.convert_symbol("FITX","202404") #Option sdk.futopt.convert_symbol("TXO","202404",20000,CallPut.Call) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py #Future "TXFD4" #Option "TXO20000D4" ``` --- ### Query Estimate Margin query\_estimate\_margin #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | --------- | ----------------------------------------------------------------------------------------------- | ------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading/library/python/EnumMatrix.md#account) | Account | | symbol | string | Symbol | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | -------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | EstimateMargin | EstimateMargin is returned | | message | string | is\_success = False error description is returned | ##### EstimateMargin Parameter[​](#estimatemargin-parameter "Direct link to EstimateMargin Parameter") Return type : Object | Parameter | Type | Meaning | | ---------------- | ------ | --------------- | | date | string | Query Date | | currency | string | Currency | | estimate\_margin | float | Estimate Margin | #### Request Example[​](#request-example "Direct link to Request Example") ```py order = FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXFE4", price = "20890", lot = 1, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.New, user_def = "From_Py" # optional field ); sdk.futopt.query_estimate_margin(accounts.data[0], order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : EstimateMargin{ date: "2023/10/16", # Query Date (string) currency: "TWD", # Currency (string) estimate_margin: 179000 # Estimate Margin (float) } } ``` --- ### Get Historical Filled filled\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ----------- | ------------------------------------------------------------------------------------------------------ | ---------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query start date | | end\_date | string (optional) ( None or empty will equals start\_date) | Query end date | info Support historical data for the past two days #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FilledData list is returned | | message | string | is\_success = False error description is returned | ##### FutOptFilledData Parameter[​](#futoptfilleddata-parameter "Direct link to FutOptFilledData Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | date | string | Filled Date | | branch\_no | string | Branch number | | account | string | Account | | seq\_no | string | Order Serial Number (only display on filled callback) | | order\_no | string | Order number | | symbol | string | symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | filled\_no | string | Filled Transaction number | | filled\_avg\_price | float | Filled Average Price | | filled\_lot | int | Filled Share | | filled\_price | float | Filled Price | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `FdayTrade` | | filled\_time | string | Filled Time | | user\_def | string | Custom Fields (only display on filled callback) | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.filled_history(account,"20230921","20230922") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data :[ FutOptFilledData{ date: "2023/09/21", # Filled Date (string) branch_no: "6460", # Branch number (string) account: "26", # Account (string) seq_no: None, # Order Serial Number (string) order_no: "bA422", # Order number (string) symbol: "FITX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy / Sell (BSAction) symbol_leg2: None, # Symbol - Spread Order(string) expiry_date_leg2: None, # Expiry Date - Spread Order(string) strike_price_leg2: None, # Strike Price - Spread Order(float) call_put_leg2: None, # Call / Put - Spread Order(CallPut) buy_sell_leg2: None, # Buy / Sell - Spread Order(BSAction) filled_no: "00000000001", # Filled Transaction number (string) filled_avg_price: 20890.0, # Filled Average Price (float) filled_lots: 1, # Filled Lot (int) filled_price: 20890.0, # Filled Price (float) order_type: New, # Order Type (string) filled_time: "10:31:00.931" # Filled Time (string) user_def: None # Custom Fields (string) }, ... ] } ``` --- ### Get Order Results get\_order\_results #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (Optional) | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_order_results(accounts.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ FutOptOrderResult{ function_type: None, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212608", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0001", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Trading Session Type (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Symbol - Spread Order (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (PriceType) price: 1822.6, # Price (float) lot: 2, # Original order Lot (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (OrderType) is_pre_order: false, # Is pre-order (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (PriceType) after_price: 1822.6, # Valid order price (float) after_lot: 2, # Valid order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "10:20:27", # Last modification time (string) details: None, # Order Process (list) error_message: None # Error message (string) }, ... ] } ``` --- ### Get Order Results (Include Detail) get\_order\_results\_detail #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel 、`90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process | | >> function\_type | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modified\_time | string | Order Modified Time | | >> before\_lot | int | Original Order Lot | | >> after\_lot | int | Valid Order Lot | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> error\_message | string | Error Message | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.get_order_results_detail(accounts.data[0]) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : [ FutOptOrderResult{ function_type: None, # Function type (int) date: "2024/03/25", # Transaction date (string) seq_no: "00110212608", # Order sequence number (string) branch_no: "15901", # Branch number (string) account: "1234567", # Account (string) order_no: "C0001", # Order number (string) asset_type: 1, # Asset type (int) market: "TAIMEX", # Market type (string) market_type: Future, # Trading Session Type (FutOptMarketType) unit: 1, # Unit (int) currency: "TWD", # Currency (string) symbol: "FITF", # Symbol (string) expiry_date: "202404", # Expiry date (string) strike_price: None, # Strike price (float) call_put: None, # Call or put (CallPut) buy_sell: Buy, # Buy or sell (BSAction) symbol_leg2: None, # Symbol - Spread Order (string) expiry_date_leg2: None, # Expiry date - Spread Order (string) strike_price_leg2: None, # Strike price - Spread Order (float) call_put_leg2: None, # Call or put - Spread Order (CallPut) buy_sell_leg2: None, # Buy or sell - Spread Order (BSAction) price_type: Limit, # Original order price type (PriceType) price: 1822.6, # Price (float) lot: 2, # Original order Lot (int) time_in_force: ROD, # Time in force (TimeInforce) order_type: Auto, # Order type (OrderType) is_pre_order: false, # Is pre-order (bool) status: 10, # Order status (int) after_price_type: None, # Valid order price type (PriceType) after_price: 1822.6, # Valid order price (float) after_lot: 2, # Valid order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled amount (int) before_lot: None, # Lot before amendment (int) before_price: None, # Price before amendment (float) user_def: None, # User-defined field (string) last_time: "10:20:27", # Last modification time (string) details:[ OrderDetail{ function_type: 10, # Function Type (int) modified_time: "10:20:27", # Order Modified Time (string) before_lot: 0, # Original Order Lot (int) after_lot: 2, # Valid Order Lot (int) before_price: 1822.6, # Original Order Price (float) after_price: 1822.6, # Valid Order Price (float) error_message: None # Error Message (string) } ], error_message: None # Error message (string) }, ... ] } ``` --- ### Modify Order Price modify\_price ##### First, using 'make\_modify\_price\_obj' create a 'FutOptModifyPrice' object[​](#first-using-make_modify_price_obj-create-a-futoptmodifyprice-object "Direct link to First, using 'make_modify_price_obj' create a 'FutOptModifyPrice' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | price | string | The price after modification | | priceType | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | The price type after modification | caution When 'price' is filled, priceType should be empty or None ; otherwise, the 'price' field should be empty or None Put the returned object into the 'modify\_price' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | -------------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | account | Account | Account | | ModifyPriceObj | [FutOptModifyPrice](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmodifyprice) | The object for price modification | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py modify_price_obj = sdk.futopt.make_modify_price_obj(order_result, "19900") sdk.futopt.modify_price(account, modify_price_obj) ``` ##### Response[​](#response "Direct link to Response") ```py Result { is_success: True, message: None, data : FutOptOrderResult{ function_type: 15, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "00110212663", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0005", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Future, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FITX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: 0, # Strike Price (float) call_put: None, # Call / Put (CallPut) buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (OrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 19900, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "13:39:05", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Modify Order Lot modify\_lot ##### First, using 'make\_modify\_lot\_obj' create a 'FutOptModifyLot' object[​](#first-using-make_modify_lot_obj-create-a-futoptmodifylot-object "Direct link to First, using 'make_modify_lot_obj' create a 'FutOptModifyLot' object") | Parameter | Type | Meaning | | ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | orderResult | [FutOptOrderResult](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptorderresult) | The intended order result object to be modified | | lots | int | The lot after modification ( The modified lot includes the partially filled portion of this order ) | Put the returned object into the 'modify\_lot' function #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | account | Account | Account | | ModifyLotObj | [FutOptModifyLot](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmodifylot) | The object for Lot modification | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | FutOptOrderResult | Modified content is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py modify_lot_obj = sdk.futopt.make_modify_lot_obj(target_order, 2) sdk.futopt.modify_lot(account, modify_lot_obj) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : FutOptOrderResult{ function_type: 20, # Function Type (int) date: "2024/03/25", # Transaction Date (string) seq_no: "03100161319", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "l001D", # Order Number (string) asset_type: 1, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: FutureNight, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "FIMTX", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: None, # Strike Price (float) call_put: None, # Call / Put (string) buy_sell: Buy, # Buy/Sell Type (string): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (string) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 20000, # Order Price (float) lot: 3, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 20000, # Valid Order Price (float) after_lot: 2, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 20000, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "18:24:40", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } ``` --- ### Get Historical Order order\_history #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | | accounts | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | start\_date | string | Query start date | | end\_date | string | Query end date | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) (Optional : If not specified, it includes all) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | info Support historical data for the past two days #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ------ | ------------------------------------------------- | | is\_success | bool | Interface result | | data | List | FutOptOrderResult list is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int (optional) | Function Type : `0` New 、 `10` Execute New、`15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90` Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process | | >> function\_type | int | Function Type : `10` Execute New、 `15` Amend Price 、 `20` Amend Quantity 、 `30` Cancel 、`50` Fully Filled、`90` Failed | | >> modified\_time | string | Order Modified Time | | >> before\_lot | int | Original Order Lot | | >> after\_lot | int | Valid Order Lot | | >> before\_price | float | Original Order Price | | >> after\_price | float | Valid Order Price | | >> filled\_money | float | Filled Value | | >> error\_message | string | Error Message | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py sdk.futopt.order_history(accounts,"20240410","20240411") ``` #### 回傳範例[​](#回傳範例 "Direct link to 回傳範例") ```py Result { is_success: True, message: None, data : [ FutOptOrderResult{ function_type: None, # Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/04/11", # Transaction Date (string) seq_no: "00230177314", # Order Serial Number (string) branch_no: "15000", # Branch Number (string) account: "9974825", # Account (string) order_no: "C0020", # Order Number (string) asset_type: 2, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Option, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: None, # Unit (int) currency: None, # Trading Currency (string) symbol: "TXO", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: 18600, # Strike Price (float) call_put: Call, # Call / Put (CallPut): `Call`, `Put` buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 2100, # Order Price (float) lot: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInForce): `ROD`, `FOK`, `IOC` order_type: New, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 50, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: None, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 2100, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 1, # Filled Lot (int) filled_money: 2100, # Filled Value (float) before_lot: None, # Before the Lot Modification (int) before_price: None, # Before the Price Modification (float) user_def: None, # Custom Fields (string) last_time: "10:41:46.760", # Last Modification Time (string) details:[ OrderDetail{ function_type: 10, # Function Type (int) modified_time: "10:41:46.760", # Order Modified Time (string) before_lot: 0, # Original Order Lot (int) after_lot: 1, # Valid Order Lot (int) before_price: 2100, # Original Order Price (float) after_price: 2100 # Valid Order Price (float) } ] error_message: None # Error Message (string) } ... #More Result Reponse ] } ``` --- ### PlaceOrder place\_order #### Request Parameter[​](#request-parameter "Direct link to Request Parameter") | Parameter | Type | Meaning | | ------------- | -------------------------------------------------------------------------------------------------------------- | ------------ | | account | [Account](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#account) | Account | | order\_object | [OrderObject](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#orderobject) | Order Object | | unblock | bool (optional) (default = False) | unblock | #### Result Response[​](#result-response "Direct link to Result Response") | Parameter | Type | Meaning | | ----------- | ----------------- | ------------------------------------------------- | | is\_success | bool | Interface result | | data | FutOptOrderResult | FutOptOrderResult is returned | | message | string | is\_success = False error description is returned | ##### FutOptOrderResult Parameter[​](#futoptorderresult-parameter "Direct link to FutOptOrderResult Parameter") Return type : Object | Parameter | Type | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | function\_type | int | Function Type : `0` New 、`10` Execute New、 `15` Amend Price 、 `20` Amend Lot 、 `30` Cancel、`90`Failed | | date | string | Transaction Date | | seq\_no | string | Order Serial Number | | branch\_no | string | Branch Number | | account | string | Account | | order\_no | string | Order Number | | asset\_type | int | Asset Type : `1` Future 、`2` Option | | market | string | Market Type : `TAIMEX` Future、Option | | market\_type | [FutOptMarketType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptmarkettype) | Trading Session Type : `Future` 、 `Option` 、 `FutureNight` After-Hour Future、 `OptionNight` After-Hour Option | | unit | int | Unit | | currency | string | Trading Currency | | symbol | string | Symbol | | expiry\_date | string | Expiry Date | | strike\_price | float | Strike Price | | call\_put | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type : `Buy` 、 `Sell` | | symbol\_leg2 | string | Spread Symbol | | expiry\_date\_leg2 | string | Expiry Date - Spread Order | | strike\_price\_leg2 | float | Strike Price - Spread Order | | call\_put\_leg2 | [CallPut](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#callput) | Call / Put : `Call`、`Put` | | buy\_sell\_leg2 | [BSAction](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#bsaction) | Buy/Sell Type - Spread Order: `Buy` 、 `Sell` | | price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Original Order Price Type : `Limit` 、 `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | price | float | Order Price | | lots | int | Original Order Lot | | time\_in\_force | [TimeInForce](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#timeinforce) | Time In Force : `ROD` `FOK` 、 `IOC` | | order\_type | [FutOptOrderType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptordertype) | Order Type : `New` 、 `Close` 、 `Auto` 、 `FdayTrade` DayTrade | | is\_pre\_order | bool | Reservation Order Flag | | status | int | Order Status : `0` Reservation 、 `4` In queue 、 `8` Processing by system backend 、 `9` TimeOut 、 `10` Active Order 、 `30` Cancel Order 、 `50` Fully Filled 、 `90` Order Failed | | after\_price\_type | [FutOptPriceType](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/library/python/EnumMatrix.md#futoptpricetype) | Valid Order Price Type : `Limit` `Market`、`RangeMarket` Market with Protection Orders 、 `Reference` | | after\_price | float | Valid Order Price | | after\_lot | int | Valid Order Lot | | filled\_lot | int | Filled Lot | | filled\_money | float | Filled Value | | before\_lot | int | Before the Lot Modification | | before\_price | float | Before the Price Modification | | user\_def | string | Custom Fields | | last\_time | string | Last Modification Time | | details | list | Order Process (Return value when query order\_result\_detail or order\_history ) | | error\_message | string | Error Message | #### Request Example[​](#request-example "Direct link to Request Example") ```py # Single order = FutOptOrder( buy_sell = BSAction.Buy, symbol = "TXO20000E4", price = "530", lot = 1, market_type = FutOptMarketType.Option, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) sdk.futopt.place_order(account, order) # Spread Order order = Order( buy_sell = BSAction.Sell, symbol = "TXO20000E4", buy_sell2 = BSAction.Buy, symbol2 = "TXO19900E4", price = "90", lot = 1, market_type = FutOptMarketType.Option, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.IOC, order_type = FutOptOrderType.Auto, user_def = "From_Py" # optional field ) sdk.futopt.place_order(account, order) ``` #### Response Example[​](#response-example "Direct link to Response Example") ```py Result { is_success: True, message: None, data : FutOptOrderResult{ { function_type: 0, # Function Type (int): `0` New, `15` Amend Price, `20` Amend Lot, `30` Cancel date: "2024/03/25", # Transaction Date (string) seq_no: "00230177010", # Order Serial Number (string) branch_no: "15901", # Branch Number (string) account: "1234567", # Account (string) order_no: "C0002", # Order Number (string) asset_type: 2, # Asset Type (int): `1` Future, `2` Option market: "TAIMEX", # Market Type (string) market_type: Option, # Trading Session Type (FutOptMarketType): `Future`, `Option`, `FutureNight` After-Hour Future, `OptionNight` After-Hour Option unit: 1, # Unit (int) currency: "TWD", # Trading Currency (string) symbol: "TXO", # Symbol (string) expiry_date: "202404", # Expiry Date (string) strike_price: 20000, # Strike Price (float) call_put: Call, # Call / Put (CallPut): `Call`, `Put` buy_sell: Buy, # Buy/Sell Type (BSAction): `Buy`, `Sell` symbol_leg2: None, # Spread Symbol (string) expiry_date_leg2: None, # Expiry Date - Spread Order (string) strike_price_leg2: None, # Strike Price - Spread Order (float) call_put_leg2: None, # Call / Put - Spread Order (CallPut) buy_sell_leg2: None, # Buy/Sell Type - Spread Order (BSAction) price_type: Limit, # Original Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` price: 530, # Order Price (float) lots: 1, # Original Order Lot (int) time_in_force: ROD, # Time In Force (TimeInforce): `ROD`, `FOK`, `IOC` order_type: Auto, # Order Type (FutOptOrderType): `New`, `Close`, `Auto`, `FdayTrade` DayTrade is_pre_order: false, # Reservation Order Flag (bool) status: 10, # Order Status (int): `0` Reservation, `4` InQueue, `9` TimeOut, `10` New Order, `30` Cancel Order, `50` Fully Filled, `90` Order Failed after_price_type: Limit, # Valid Order Price Type (FutOptPriceType): `Limit`, `Market`, `RangeMarket` Market with Protection Orders, `Reference` after_price: 530, # Valid Order Price (float) after_lot: 1, # Valid Order Lot (int) filled_lot: 0, # Filled Lot (int) filled_money: 0, # Filled Value (int) before_lot: 0, # Before the Lot Modification (int) before_price: 530, # Before the Price Modification (float) user_def: "From_Py", # Custom Fields (string) last_time: "11:50:08", # Last Modification Time (string) details: None, # Order Process (list) error_message: None # Error Message (string) } } } ``` --- ### Preparation caution Before starting with the Fubon Neo API, you must complete the following steps:" 1. Have your Fubon Future account ready. (If you don't already have a Fubon Future account, please click the link.[Open Account](https://www.fubon.com/futures/home/account/e_open/e_open.html) 2. Sign API agreements 3. Apply digital certification #### Prepare[​](#prepare "Direct link to Prepare") Use your Fubon Future account ![Your Fubon Future account](/TradeAPI/en/assets/images/prepare_account-792b5d9a17005ebde0e7d7050b37bb5c.png) #### Sign API agreements[​](#sign-api-agreements "Direct link to Sign API agreements") Using Cell Phone `富邦e點通` APP or using desktop `E+` ###### Signing Process Completed[​](#signing-process-completed "Direct link to Signing Process Completed") Congratulations 🎉 you have successfully signed the agreements. #### Apply the Digital Certificate[​](#apply-the-digital-certificate "Direct link to Apply the Digital Certificate") Go to the [apply certificate](https://www.fbs.com.tw/Certificate/Management/) page and download the CATool. ![Certificate apply](/TradeAPI/en/assets/images/catool_down-7656be110b8cad6d84a981986dc1c34b.png) After logging in and completing the authentication, enter your mobile number or email to receive OTP code and complete the OTP verification. ![OTP](/TradeAPI/en/assets/images/ca_cover-3de617d54b6dfac697be7cae07ea3260.png) After completing the application, the certificate by default will be stored in the folder C:\CAFubon\\(Your ID Number). The certificate filename is (Your ID Number).pfx. ![CertLocation](/TradeAPI/en/assets/images/ca_repo-829d506640c176e4a8fc1b84c13b2908.png) #### Install SDK package[​](#install-sdk-package "Direct link to Install SDK package") * Python * Node.js * C# ```python pip install fubon_neo--cp37-abi3-win_amd64.whl ``` Support Python version 3.7 (~v1.3.2) and 3.8–3.13 (v2.0.1~, 3.14 not supported) First, create a folder named 'project' and initialize it using the following command: ```bash npm init ``` The file downloaded from the official website will be named fubon-neo-\.tgz, and place it in the folder you just created Add a line to the package.json file inside the Node.js project. ```json "dependencies": { ... "fubon-neo": "file:///fubon-neo-.tgz", ... } ``` Then enter the following command in the command line ```bash npm install ``` Node.js version 16 and above are supported the downloaded file name should look like this FubonNeo.\.nupkg for Visual Studio user, please refer to below tutorial. * Method 1 : Visual Studio Nuget Package Manager( **Using .NET 7 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click `Tools` -> `Nuget Package Manager` -> `Manage Nuget Packages for Solution` ![nugetpackage](/TradeAPI/en/assets/images/nugetpackage-d71a41371e06f457ac161917ba1a0af6.png) Next, select 1. Package source, select the package name you named in the previous step 2. Click Browse 3. Click Package 4. Select Project 5. Install Package ![nugetinstall](/TradeAPI/en/assets/images/nugetinstall-1cce8168b9c84304d8a20eaf103da69d.png) Finish ! You can using Fubon Neo SDK。 *** * Method 2 : Visual Studio Nuget Package Manager( **Using .NETFrame 4.7.2 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click On the right-hand side in Solution Explorer`Switch between solutions and available views` ( Or you can open it by going to the 'View' menu at the top) , After opening the folder, locate the .csproj file ![csprojadd](/TradeAPI/en/assets/images/csprojadd-884ccdbfb9631160aff1fabfc80d6f80.png) Inside the .csproj file, add an SDK reference (fill in the version according to the version number). ```xml ... ... ... ``` Click on the `.sln` file in File Explorer, right-click on the project name, and select Reload Project ![csprojimport](/TradeAPI/en/assets/images/csprojimport-a4dfc02aa766b2640c3b75692978f535.png) caution The current package only supports 64-bit. If your development environment is set to 32-bit by default, you can adjust it following the steps below: 1. Click on the top menu `Project` 2. Select `Project Properties` 3. Click on 'Build' on the left side, and change the platform target to x64 ![64bit](/TradeAPI/en/assets/images/64bit-b5e0de53211506491860e4f017fef7e9.png) *** * If you're not using Visual Studio NuGet Package Manager, you can use the Command Line as follows: You can add a new nuget.config file under the project folder: ```bash cd /Your Project path/ cd .>nuget.config #Create nuget.config ``` And copy and paste below content in the nuget.config ```xml ``` and then add sdk reference in the .csproj file (Vsesion base on downloaded package) ```xml ... ... ``` and then restore the project in the command line ```cs dotnet restore ``` C# develop .NET Standard 2.0 for the base , Suggest using .netcoreapp 3.1 and above; If using .NETFramework,suggest using .NETFramework 4.7.2 and above. #### Start Your Program Trading Journey[​](#start-your-program-trading-journey "Direct link to Start Your Program Trading Journey") * Python * Node.js * C# ```python from fubon_neo.sdk import FubonSDK, Order from fubon_neo.constant import TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType, CallPut, BSAction # Connect and login sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password") ## accounts = sdk.login("Your ID", "Your Password", "Your cert path") # If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions acc = accounts.data[0] # Create order object order = FutOptOrder( buy_sell = BSAction.Sell, symbol = "TXFD4", price = "20800", lot = 3, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "Python" # optional field ) # Place an order order_res = sdk.futopt.place_order(acc, order) print(order_res) ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```python Result { is_success: True, message: None, data : { function_type: 0, date : "2023/10/13", seq_no : "00000000016", branch_no : "6460", account : "26", order_no : "bA627", asset_type : 1, market : "TAIMEX", market_type : Future, symbol : "FITX", unit : 1 , currency : "TWD", expiry_date : "202404", strike_price : , call_put : , buy_sell : Buy , price_type : Limit, price : 20800, lot : 3, time_in_force : ROD, order_type : Auto, is_pre_order : False, status : 10, after_price_type : Limit, afterPrice : 20800, after_lot : 2000, filled_lot : 0, filled_money : 0, ... , user_def : "From Pyhton", last_time : "12:19:06.048", error_message : } } ``` ```js const { FubonSDK, TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType, CallPut, BSAction } = require('fubon-neo'); // Connect and login const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password"); // const accounts = sdk.login("Your ID", "Your Password", "Your cert path"); // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions const acc = accounts.data[0]; // Create order object const order = { buySell: BSAction.Buy, symbol: TXFD4, price: "20800", lot: 3, marketType: FutOptMarketType.Future, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "from Js" }; // Place an order sdk.futopt.placeOrder(acc,order); ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```js { isSuccess: true, data: { functionType : 0, date : '2023/10/13', seqNo : '00000000016', branchNo : '6460', account : '26', orderNo : 'bA627', assetType : 1, market : 'TAIMEX', marketType : Future, symbol : 'FITX', unit : 1 , currency : 'TWD', expiryDate : '202404' , buySell : Buy , priceType : Limit, price : 20800, lot : 3, timeInForce : ROD, orderType : Auto, isPreOrder : False, status : 10, afterPriceType : Limit, afterPrice : 20800, afterLot : 3, filledLot : 0, filledMoney : 0, ... , userDef : 'From JS', lastTime : '12:19:06.048', errorMessage : } } ``` ```cs using FubonNeo.Sdk; // Connect and login var sdk = new FubonSDK(); var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path" , "Your cert password"); /* // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path"); */ var acc = acc_obj.data[0]; // Create order object var order = new FutOptOrder( BsAction.Buy, "TXFD4", "20800", 3, FutOptMarketType.Future, FutOptPriceType.Limit, TimeInForce.Rod, FutOptOrderType.Auto, "From C#" ); // Place an order var order_res = sdk.FutOpt.PlaceOrder(acc, order); Console.WriteLine(order_res); ``` Congratulations 🎊 after placing your order, you will be able to see the system's response. ```cs { isSuccess = True, message = , data = FutOptOrderResult{functionType: 0, date = 2023/10/13, seqNo = 00000000016, branchNo = 6460, account = 26, orderNo = bA627, assetType = 1, market = TAIMEX, marketType = Future, symbol = FITX, unit = 1 , currency = TWD, expiryDate = 202404, strikePrice = , callPut = , buySell = Buy , priceType = Limit, price = 20800, lot = 3, timeInForce = ROD, orderType = Auto, isPreOrder = False, status = 10, afterPriceType = Limit, afterPrice = 66, afterLot = 2000, filledLot = 0, filledMoney = 0, ... , userDef = From C#, lastTime = 12:19:06.048, errorMessage = } } ``` --- ### Quick Start Please refer to the [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading-future/prepare.md) first and complete the application for the API Agreements and certificate download。 If you haven't installed the SDK package yet, you can download it from [SDK download page](https://www.fbs.com.tw/TradeAPI/en/docs/download/download-sdk.md). Once you have the SDK package and know the installation path, use the following command to install it:" #### Install Package[​](#install-package "Direct link to Install Package") * Python * Node.js * C# ```py pip install fubon_neo--cp37-abi3-win_amd64.whl ``` First, create a folder named 'project' and initialize it using the following command: ```bash npm init ``` The file downloaded from the official website will be named fubon-neo-\.tgz, and place it in the folder you just created Add a line to the package.json file inside the Node.js project. ```json "dependencies": { ... "fubon-neo": "file:///fubon-neo-.tgz", ... } ``` Then enter the following command in the command line ```bash npm install ``` Node.js version 16 and above are supported the downloaded file name should look like this FubonNeo.\.nupkg for Visual Studio user, please refer to below tutorial. * Method 1 : Visual Studio Nuget Package Manager( **Using .NET 7 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click `Tools` -> `Nuget Package Manager` -> `Manage Nuget Packages for Solution` ![nugetpackage](/TradeAPI/en/assets/images/nugetpackage-d71a41371e06f457ac161917ba1a0af6.png) Next, select 1. Package source, select the package name you named in the previous step 2. Click Browse 3. Click Package 4. Select Project 5. Install Package ![nugetinstall](/TradeAPI/en/assets/images/nugetinstall-1cce8168b9c84304d8a20eaf103da69d.png) Finish ! You can using Fubon Neo SDK。 *** * Method 2 : Visual Studio Nuget Package Manager( **Using .NETFrame 4.7.2 as an example** ) : After placing the package under the newly added project, click `Tools` -> `Nuget Package Manager` -> `Nuget Package Settings` ![nugetset](/TradeAPI/en/assets/images/nugetset-dcd96ee20e4663a6c4b996264d1b962e.png) After popup window, 1. Click on the upper-right corner `+` 2. Click on the bottom `...` select the location to store the package 3. Rename package 4. Click `Update` 5. Click OK ![nugetsource](/TradeAPI/en/assets/images/nugetsource-8523418911907166548dd2f4afd61d1c.png) Click On the right-hand side in Solution Explorer`Switch between solutions and available views` ( Or you can open it by going to the 'View' menu at the top) , After opening the folder, locate the .csproj file ![csprojadd](/TradeAPI/en/assets/images/csprojadd-884ccdbfb9631160aff1fabfc80d6f80.png) Inside the .csproj file, add an SDK reference (fill in the version according to the version number). ```xml ... ... ... ``` Click on the `.sln` file in File Explorer, right-click on the project name, and select Reload Project ![csprojimport](/TradeAPI/en/assets/images/csprojimport-a4dfc02aa766b2640c3b75692978f535.png) caution The current package only supports 64-bit. If your development environment is set to 32-bit by default, you can adjust it following the steps below: 1. Click on the top menu `Project` 2. Select `Project Properties` 3. Click on 'Build' on the left side, and change the platform target to x64 ![64bit](/TradeAPI/en/assets/images/64bit-b5e0de53211506491860e4f017fef7e9.png) *** * If you're not using Visual Studio NuGet Package Manager, you can use the Command Line as follows: You can add a new nuget.config file under the project folder: ```bash cd /Your Project path/ cd .>nuget.config #Create nuget.config ``` And copy and paste below content in the nuget.config ```xml ``` and then add sdk reference in the .csproj file (Vsesion base on downloaded package) ```xml ... ... ``` and then restore the project in the command line ```cs dotnet restore ``` ##### And you should place the certificate in your folder structure like this: ```text . └── XXXXXXXXXX.pfx ``` ###### [​](#-1 "Direct link to -1") * Python * Node.js * C# f you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.py` file in your folder and paste the following content into it, then execute it:: ```python from fubon_neo.sdk import FubonSDK, FutOptOrder from fubon_neo.constant import TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType, CallPut, BSAction sdk = FubonSDK() accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password") #If there are account groupings, multiple account information will be returned ## accounts = sdk.login("Your ID", "Your Password", "Your cert path") # If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions acc = accounts.data[0] ``` If you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.js` file in your folder and paste the following content into it, then execute it:: ```js const { FubonSDK, TimeInForce, FutOptOrderType, FutOptPriceType, FutOptMarketType, CallPut, BSAction } = require('fubon-neo'); const sdk = new FubonSDK(); const accounts = sdk.login("Your ID", "Your Password", "Your cert path" , "Your cert password"); // const accounts = sdk.login("Your ID", "Your Password", "Your cert path"); // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions const acc = accounts.data[0]; ``` If you have never used the SDK for logging in or if you have changed your SDK execution environment, please create an `index.cs` file in your folder and paste the following content into it, then execute it:: ```cs using FubonNeo.Sdk; var sdk = new FubonSDK(); var accounts = sdk.Login("Your ID", "Your Password", "Your cert path" , "Your cert password"); // If there are account groupings, multiple account information will be returned /* // If you use the "default" password for your certificate, for SDK v1.3.2 and newer versions var acc_obj = sdk.Login("Your ID", "Your Password", "Your cert path"); */ var acc = accounts.data[0]; ``` #### Send Order[​](#send-order "Direct link to Send Order") Next, add the following example code to demonstrate how to use the Fubon API to place a limit order to buy 1 board lot of Fubon Financial Holding Co., Ltd. (2881) at the fall stop price. * Python * Node.js * C# ```py order = FutOptOrder( buy_sell = BSAction.Sell, symbol = "TXFD4", price = "20800", lot = 3, market_type = FutOptMarketType.Future, price_type = FutOptPriceType.Limit, time_in_force = TimeInForce.ROD, order_type = FutOptOrderType.Auto, user_def = "Python" # optional field ) sdk.futopt.place_order(acc, order) ``` ```js const order = { buySell: BSAction.Buy, symbol: "TXFD4", price: "20800", lot: 3, marketType: FutOptMarketType.Future, priceType: FutOptPriceType.Limit, timeInForce: TimeInForce.ROD, orderType: FutOptOrderType.Auto, userDef: "from Js" }; sdk.futopt.placeOrder(acc,order); ``` ```cs var order = new FutOptOrder( BsAction.Buy, "TXFD4", null, // Spread Order Buy / Sell null, // Spread Order Symbol "20800", 3, FutOptMarketType.Future, FutOptPriceType.Limit, TimeInForce.Rod, FutOptOrderType.Auto, "From C#" ); sdk.FutOpt.PlaceOrder(acc, order); ``` --- ### Rate Limit ##### Connection Limit[​](#connection-limit "Direct link to Connection Limit") | Behavior | Upper Limit | | ---------- | ----------- | | Connection | 10 | When the connection exceeds the limit, you will receive the following message during login: ```json Result { is_success: False, message: Login Error, 超過本應用程式連線限制==>[10] data: None } ``` | Behavior | Upper Limit per Second | | ---------------- | ---------------------- | | Order | 50 | | Batch Order | 10 | | Query Accounting | 5 | When the limit for the number of times is exceeded, you will receive the following message: ```json Result { is_success: False, message: Login Error, 業務系統流量控管 data: None } ``` --- ### Fubon Neo API User Guide *** Key takeaways * This page is the entry point for getting started with the Fubon Neo API. * Complete account setup, certificate, and API agreement before development. * Sample code is available for Python, C#, and JavaScript. * Next step: [Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md). | Item | Details | | ------------- | ------------------------------------------------------------------------------------------------------- | | Product | Fubon Neo API | | Prerequisites | Account, certificate, API agreement + connection test | | Languages | Python / C# / JavaScript (Node.js) / C++ & Go (securities trading accounting and condition orders only) | | Resources | Sample code, test environment, community | Before you started Before depart for your program trading journey, the following steps need to be completed 1. Got to【[Preparation](https://www.fbs.com.tw/TradeAPI/en/docs/trading/prepare.md)】and complete the tasks: **a. Open a brokage account; b. Apply for e-trading certification; c. Sign the API agreement & complete the connectivity test** 2. Select your programming language ranging from Python, C#, and JavaScript. Refer to our【[Sample Code](#code_sample)】for starters. 3. Join our【[Discord](https://discord.com/invite/M8Gv9yKfza)】community to keep in tune of the newest programing trading information and resources #### Programming Development Environment (Python) and Sample Code Reference[​](#programming-development-environment-python-and-sample-code-reference "Direct link to Programming Development Environment (Python) and Sample Code Reference") This is for your information only, there is no mandate to setup the environment as in this tutorial ##### Set the Programming Development Environment (Python)[​](#set-the-programming-development-environment-python "Direct link to Set the Programming Development Environment (Python)") [Python安裝與使用教學](https://www.youtube.com/embed/XQo8d4-WsIg?si=Aq7l1Br0S5nqPE_m) ##### Sample Code[​](#code_sample "Direct link to Sample Code") Friendly Reminder The follows are source code only. SDK need to be installed separately. PYTHON Sample Code * **API Function Demo:** * [Python sample code](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/python_sample_code.zip) (.ipynb, Jupyter file) * **Application Example:** * [Trigger buy when seeing the limit-up price](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/win_for_limitup.zip) * [Short-sell limit order before market open](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/win_for_short_sell.zip) * [Convert unfilled limit order to market order when market open](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/limit_to_market.zip) * [Inventory stop-loss/take-profit](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/inventory_stop_loss.zip) C# Sample Code * **API Function Demo:** * [C# sample code (Trade)](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/fubondotnetsdkgui.zip) (WPF) * [C# sample code (Market Data and Accounting)](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/marketdata_n_accounting.zip) (Windows Forms) * **Application Example:** * [Convert unfilled limit order to market order when market open ](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/limit_to_market.zip)(Windows Forms) JAVASCRIPT Sample Code * **API Function Demo:** * [JS sample code](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/js_sample_code.zip) (.ipynb, Jupyter file) #### Test Environment[​](#test-environment "Direct link to Test Environment") Test Environment is available for Fubon Neo API. Please download the following instruction package: [Download the instruction package](https://www.fbs.com.tw/TradeAPI_SDK/sample_code/test_environment.zip)

Note 1. Only securities account is available for now.
Note 2. For further inquiry, please email to the PM mailbox ******. #### Useful Resources[​](#useful-resources "Direct link to Useful Resources") Fubon Securities Program Trading Online Seminar 【[Online Seminar Registration](https://www.fbs.com.tw/Course/Main;areaID=F)】There will be irregular program trading online seminars, covering stock selection to API trading program development. GITHUB Sample Code Contains a variety of common trading graphical interface application examples developed with Fubon Neo API Python:【[GitHub Sample Code](https://github.com/Tradepm/-API)】 YOUTUBE Program Trading Channel All about Fubon Neo API and program trading videos:【[Fubon Securities YouTube](https://youtube.com/playlist?list=PLm7R8dzlvMHd6LonqpQHoIS6ga0d5fdpp\&si=NrJt2fEl0kgXS_NG)】program trading channel DISCORD Program Trading Community Need idea for developing program trading tools? Join our【[Discord Community](https://discord.com/invite/M8Gv9yKfza)】! From rookie to veteran, all sorts of questions are discussed here. --- ### Building with LLMs You can use large language models (LLMs) to help build Fubon Neo API integrations. We provide the following applications to support your use of LLMs throughout the development process. #### Plain text docs[​](#plain-text-docs "Direct link to Plain text docs") We provide an [llms.txt](https://www.fbs.com.tw/TradeAPI/en/llms.txt) file to guide AI tools and agents on how to retrieve the plain-text versions of our pages. `/llms.txt` is an emerging standard designed to make websites and content easier for LLMs to access and use. * [llms.txt](https://www.fbs.com.tw/TradeAPI/en/llms.txt) * [llms-full.txt](https://www.fbs.com.tw/TradeAPI/en/llms-full.txt) ---