Get Order Info
Methods returning
web::json::valuereturn the unwrapped responsedata; list methods further return itsitems. The typed method returningOrderfurther deserializes that content into an SDK object. The complete-response envelope shown in JSON is not part of the method return value.
Get an Order
Order TradeClient::get_order(unsigned long long id, bool is_brief)
Description
Returns an order by ID as an Order structure.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | unsigned long long | Yes | Order ID |
| is_brief | bool | No | Return abbreviated order information; default false |
Return
Order object
Order Object Properties
| Property | Type | Description |
|---|---|---|
| id | unsigned long long | Order ID |
| order_id | long | External order ID |
| account | utility::string_t | Account ID |
| contract | Contract | Contract object (contains symbol, sec_type, market, currency, etc.) |
| action | utility::string_t | Trade direction BUY/SELL |
| order_type | utility::string_t | Order type MKT/LMT/STP/STP_LMT/TRAIL |
| total_quantity | long long | Total order quantity |
| filled_quantity | long long | Filled quantity |
| limit_price | double | Limit price |
| aux_price | double | Stop trigger price |
| trailing_percent | double | Trailing stop percentage |
| avg_fill_price | double | Volume-weighted average of fill prices, excluding commissions and other fees |
| status | utility::string_t | Order status |
| time_in_force | utility::string_t | Order validity period |
| outside_rth | bool | Indicates whether pre-market and after-hours trading is allowed |
| realized_pnl | double | Realized P&L; commission and GST are returned separately. Refer to the account statement for the exact calculation basis and currency |
| commission | double | Commission; the model cannot distinguish a missing field from an explicit zero |
| open_time | time_t | Order placement time |
| latest_time | time_t | Latest fill time |
| update_time | time_t | Order update time |
| user_mark | utility::string_t | User remarks |
| reason | utility::string_t | Order failure reason |
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/client_config.h"
using namespace TIGER_API;
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
Order order = trade_client.get_order(14275856193552384);
ucout << order.to_string() << std::endl;
std::cout << "Status: " << order.status << std::endl;
std::cout << "Filled: " << order.filled_quantity << "/" << order.total_quantity << std::endl;Rate Limit
- Base rate: 120 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Get Orders
value TradeClient::get_orders(const utility::string_t &account, const utility::string_t &sec_type, const utility::string_t &market, const utility::string_t &symbol, time_t start_date, time_t end_date, int limit, bool is_brief, const value &states, const utility::string_t &sort_by, const utility::string_t &seg_type)
Description
Returns a list of orders. Overloads accept either enum or string parameters.
sort_byis supported only for omnibus accounts and selects both the ordering and the timestamp filtered bystart_dateandend_date:LATEST_CREATEDsorts descending and filters by order creation/submission time, whileLATEST_STATUS_UPDATEDsorts descending and filters by the most recent order status update time.start_dateandend_dateare optional; omitting either applies no corresponding date filter. The interface imposes no maximum date span, but results remain subject to pagination or result limits. Use a reasonable date range and split broader queries when needed.When no
sort_byis supplied, the C++ SDK enum overload passesOrderSortBy::LATEST_STATUS_UPDATEDby default. The string overload defaults to an empty string and omits the field, so the service defaults toLATEST_CREATED.
Parameters (String Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | No | Account ID |
| sec_type | utility::string_t | No | Security type, e.g., U("STK"), default empty |
| market | utility::string_t | No | Market, default U("ALL") |
| symbol | utility::string_t | No | Symbol; empty by default |
| start_date | time_t | No | Start timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1 |
| end_date | time_t | No | End timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1 |
| limit | int | No | Number of records limit, default 100 |
| is_brief | bool | No | Return abbreviated order information; default false |
| states | value | No | Order status filter array |
| sort_by | utility::string_t | No | Ordering and time-filter field: LATEST_CREATED (order creation/submission time) or LATEST_STATUS_UPDATED (most recent order status update time); defaults to empty and omits the field |
| seg_type | utility::string_t | No | Account segment, default empty |
Parameters (Enum Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | Yes | Account ID |
| sec_type | SecType | No | Security type, default SecType::ALL |
| market | Market | No | Market, default Market::ALL |
| symbol | utility::string_t | No | Symbol |
| start_date | time_t | No | Start timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1 |
| end_date | time_t | No | End timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1 |
| limit | int | No | Number of records limit, default 100 |
| is_brief | bool | No | Return abbreviated order information; default false |
| states | value | No | Order status filter array |
| sort_by | OrderSortBy | No | Ordering and time-filter field: OrderSortBy::LATEST_CREATED (order creation/submission time) or OrderSortBy::LATEST_STATUS_UPDATED (most recent order status update time); C++ SDK default OrderSortBy::LATEST_STATUS_UPDATED |
| seg_type | SegmentType | No | Account segment, default SegmentType::SEC |
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
value orders = trade_client.get_orders();
ucout << orders.serialize() << std::endl;Response Example
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": {
"items": [
{
"id": 123456,
"orderId": 789012,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"totalQuantity": 100,
"filledQuantity": 100,
"limitPrice": 150.0,
"avgFillPrice": 149.95,
"status": "Filled",
"openTime": 1785441600000,
"latestTime": 1785441650000
}
]
}
}Rate Limit
- Base rate: 120 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Get Active Orders
value TradeClient::get_active_orders(utility::string_t account, utility::string_t sec_type, utility::string_t market, utility::string_t symbol, time_t start_date, time_t end_date, unsigned long long parent_id, utility::string_t sort_by, utility::string_t seg_type)
Description
Returns currently active, unfilled orders.
Parameters (String Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | No | Account ID |
| sec_type | utility::string_t | No | Security type, default empty |
| market | utility::string_t | No | Market, default U("ALL") |
| symbol | utility::string_t | No | Symbol |
| start_date | time_t | No | Start timestamp, filtered against the timestamp selected by sort_by, default -1 |
| end_date | time_t | No | End timestamp, filtered against the timestamp selected by sort_by, default -1 |
| parent_id | unsigned long long | No | Defaults to 0; the current get_active_orders implementation does not send this parameter |
| sort_by | utility::string_t | No | Ordering and time-filter field: LATEST_CREATED (order creation/submission time) or LATEST_STATUS_UPDATED (most recent order status update time); defaults to empty and omits the field |
| seg_type | utility::string_t | No | Account segment, default empty |
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
value active_orders = trade_client.get_active_orders();
ucout << active_orders.serialize() << std::endl;Response Example
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": {
"items": [
{
"id": 123457,
"orderId": 789013,
"symbol": "TSLA",
"action": "BUY",
"orderType": "LMT",
"totalQuantity": 50,
"filledQuantity": 0,
"limitPrice": 280.0,
"status": "PendingSubmit",
"openTime": 1785527000000
}
]
}
}Rate Limit
- Base rate: 120 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Get Inactive Orders
value TradeClient::get_inactive_orders(utility::string_t account, utility::string_t sec_type, utility::string_t market, utility::string_t symbol, time_t start_date, time_t end_date, unsigned long long parent_id, utility::string_t sort_by, utility::string_t seg_type)
Description
Returns inactive orders, including canceled and expired orders.
Parameters
The parameters match get_active_orders, except the current get_inactive_orders implementation sends the parent order ID when parent_id > 0.
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
value inactive_orders = trade_client.get_inactive_orders();
ucout << inactive_orders.serialize() << std::endl;Response Example
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": {
"items": [
{
"id": 123456,
"orderId": 789012,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"totalQuantity": 100,
"filledQuantity": 100,
"limitPrice": 150.0,
"avgFillPrice": 149.95,
"status": "Filled"
}
]
}
}Rate Limit
- Base rate: 120 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Get Filled Orders
value TradeClient::get_filled_orders(utility::string_t account, utility::string_t sec_type, utility::string_t market, utility::string_t symbol, time_t start_date, time_t end_date, unsigned long long parent_id, utility::string_t sort_by, utility::string_t seg_type)
Description
Returns filled orders.
Parameters
The parameters match get_active_orders; the current get_filled_orders implementation does not send parent_id.
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
value filled = trade_client.get_filled_orders();
ucout << filled.serialize() << std::endl;Response Example
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": {
"items": [
{
"id": 123456,
"orderId": 789012,
"symbol": "AAPL",
"action": "BUY",
"orderType": "LMT",
"totalQuantity": 100,
"filledQuantity": 100,
"limitPrice": 150.0,
"avgFillPrice": 149.95,
"status": "Filled"
}
]
}
}Rate Limit
- Base rate: 120 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Get Transaction Records
Description
Returns transaction records. One overload queries by order ID; the other queries by symbol and optional filters.
Overload 1: Query by Order ID
value TradeClient::get_transactions(utility::string_t account, long long order_id)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | Yes | Account ID |
| order_id | long long | Yes | Order ID |
Overload 2: Query by Symbol/Conditions
value TradeClient::get_transactions(utility::string_t account, utility::string_t symbol, utility::string_t sec_type, long start_time, time_t end_time, int limit, utility::string_t expiry, utility::string_t strike, utility::string_t right, long long order_id)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | Yes | Account ID |
| symbol | utility::string_t | Yes | Symbol |
| sec_type | utility::string_t | No | Security type, default empty |
| start_time | long | No | Start timestamp (milliseconds), default -1 |
| end_time | time_t | No | End timestamp (milliseconds), default -1 |
| limit | int | No | Number of records limit, default 100 |
| expiry | utility::string_t | No | Option expiry date |
| strike | utility::string_t | No | Option strike price |
| right | utility::string_t | No | Option direction, e.g., U("PUT")/U("CALL") |
| order_id | long long | No | Order ID, default 0 |
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
// Query by order ID
value transactions = trade_client.get_transactions(config.account, 14275856193552384LL);
ucout << transactions.serialize() << std::endl;
// Query by symbol
value trans2 = trade_client.get_transactions(config.account, U("AAPL"));
ucout << trans2.serialize() << std::endl;Rate Limit
- Base rate: 60 requests per minute (counted per TigerId and interface in a 60-second rolling window).
Preview an Order
value TradeClient::preview_order(Order &order)
Description
Returns estimated commission, margin, and other order details without submitting the order.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| order | Order& | Yes | Order object |
Return
web::json::value JSON object containing estimated information
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/client_config.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace TIGER_API;
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
Contract contract = ContractUtil::stock_contract(U("AAPL"), U("USD"));
Order order = OrderUtil::limit_order(config.account, contract, U("BUY"), 100, 150.0);
value preview = trade_client.preview_order(order);
ucout << preview.serialize() << std::endl;Updated about 1 month ago
