Get Order Info
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 | Average fill price |
| 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 | double | Commission |
| 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;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.
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), default -1 |
| end_date | time_t | No | End timestamp (milliseconds), 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 | Sort method, default empty |
| 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), default -1 |
| end_date | time_t | No | End timestamp (milliseconds), 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 | Sort method, 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
}
]
}
}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, default -1 |
| end_date | time_t | No | End timestamp, default -1 |
| parent_id | unsigned long long | No | Parent order ID, default 0 |
| sort_by | utility::string_t | No | Sort method, default empty |
| 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
}
]
}
}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
Same parameters as get_active_orders
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"
}
]
}
}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
Same parameters as get_active_orders
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"
}
]
}
}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;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 8 days ago
