# 富邦新一代 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 
2. Apply for a web certificate and receive the OTP 
3. After completing the certificate application, you can export the certificate and add a new key 
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 `
* Set control permissions ( Leave IP or date blank if you do not want to set corresponding controls ) 
* After successful setup, the Secret Key will be displayed ( **Once the Secret Key is closed, it will no longer be shown** ) 
5. You can view previously applied keys or deactivate them ( You can activate for up to 30 keys at the same time ) 
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). 
#### 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.

##### 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.

2. Click `M櫃台`

3. Choice `條件單同意書` and sign agreements.

#### 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).

#### 程式範例[](#程式範例 "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.

##### 程式範例[](#程式範例 "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