Get Order Info
get_order Get Single Order
Order TradeClient::get_order(unsigned long long id, bool is_brief)
Description
Query single order details by order ID, returns an Order struct object
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | unsigned long long | Yes | Order ID |
| is_brief | bool | No | Whether brief 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 | Fund account |
| 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 | Whether pre/post market |
| 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("/path/to/your/properties/"));
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 Get Order List
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
Query order list. This method provides both enum and string overloaded versions.
Parameters (String Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | No | Fund account |
| 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 code, default empty |
| 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 | Whether brief 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 | Fund account |
| sec_type | SecType | No | Security type, default SecType::ALL |
| market | Market | No | Market, default Market::ALL |
| symbol | utility::string_t | No | Symbol code |
| 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 | Whether brief 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("/path/to/your/properties/"));
TradeClient trade_client(config);
value orders = trade_client.get_orders();
ucout << orders.serialize() << std::endl;get_active_orders 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
Query currently active (unfilled) order list
Parameters (String Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| account | utility::string_t | No | Fund account |
| 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 code |
| 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("/path/to/your/properties/"));
TradeClient trade_client(config);
value active_orders = trade_client.get_active_orders();
ucout << active_orders.serialize() << std::endl;get_inactive_orders 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
Query inactive order list (cancelled, expired, etc.)
Parameters
Same parameters as get_active_orders
Return
web::json::value JSON array
Example
ClientConfig config(false, U("/path/to/your/properties/"));
TradeClient trade_client(config);
value inactive_orders = trade_client.get_inactive_orders();
ucout << inactive_orders.serialize() << std::endl;get_filled_orders 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
Query filled order list
Parameters
Same parameters as get_active_orders
Return
web::json::value JSON array
Example
ClientConfig config(false, U("/path/to/your/properties/"));
TradeClient trade_client(config);
value filled = trade_client.get_filled_orders();
ucout << filled.serialize() << std::endl;get_transactions Get Transaction Records
Description
Query transaction records. Two overloaded versions: query by order ID and query by symbol/conditions.
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 | Fund account |
| 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 | Fund account |
| symbol | utility::string_t | Yes | Symbol code |
| 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("/path/to/your/properties/"));
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_order Preview Order
value TradeClient::preview_order(Order &order)
Description
Preview an order, returning estimated commission, margin, and other information without actually 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("/path/to/your/properties/"));
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 1 day ago
