Get Order Info

Methods returning web::json::value return the unwrapped response data; list methods further return its items. The typed method returning Order further 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

ParameterTypeRequiredDescription
idunsigned long longYesOrder ID
is_briefboolNoReturn abbreviated order information; default false

Return

Order object

Order Object Properties

PropertyTypeDescription
idunsigned long longOrder ID
order_idlongExternal order ID
accountutility::string_tAccount ID
contractContractContract object (contains symbol, sec_type, market, currency, etc.)
actionutility::string_tTrade direction BUY/SELL
order_typeutility::string_tOrder type MKT/LMT/STP/STP_LMT/TRAIL
total_quantitylong longTotal order quantity
filled_quantitylong longFilled quantity
limit_pricedoubleLimit price
aux_pricedoubleStop trigger price
trailing_percentdoubleTrailing stop percentage
avg_fill_pricedoubleVolume-weighted average of fill prices, excluding commissions and other fees
statusutility::string_tOrder status
time_in_forceutility::string_tOrder validity period
outside_rthboolIndicates whether pre-market and after-hours trading is allowed
realized_pnldoubleRealized P&L; commission and GST are returned separately. Refer to the account statement for the exact calculation basis and currency
commissiondoubleCommission; the model cannot distinguish a missing field from an explicit zero
open_timetime_tOrder placement time
latest_timetime_tLatest fill time
update_timetime_tOrder update time
user_markutility::string_tUser remarks
reasonutility::string_tOrder 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


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_by is supported only for omnibus accounts and selects both the ordering and the timestamp filtered by start_date and end_date: LATEST_CREATED sorts descending and filters by order creation/submission time, while LATEST_STATUS_UPDATED sorts descending and filters by the most recent order status update time. start_date and end_date are 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_by is supplied, the C++ SDK enum overload passes OrderSortBy::LATEST_STATUS_UPDATED by default. The string overload defaults to an empty string and omits the field, so the service defaults to LATEST_CREATED.

Parameters (String Version)

ParameterTypeRequiredDescription
accountutility::string_tNoAccount ID
sec_typeutility::string_tNoSecurity type, e.g., U("STK"), default empty
marketutility::string_tNoMarket, default U("ALL")
symbolutility::string_tNoSymbol; empty by default
start_datetime_tNoStart timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1
end_datetime_tNoEnd timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1
limitintNoNumber of records limit, default 100
is_briefboolNoReturn abbreviated order information; default false
statesvalueNoOrder status filter array
sort_byutility::string_tNoOrdering 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_typeutility::string_tNoAccount segment, default empty

Parameters (Enum Version)

ParameterTypeRequiredDescription
accountutility::string_tYesAccount ID
sec_typeSecTypeNoSecurity type, default SecType::ALL
marketMarketNoMarket, default Market::ALL
symbolutility::string_tNoSymbol
start_datetime_tNoStart timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1
end_datetime_tNoEnd timestamp (milliseconds), filtered against the timestamp selected by sort_by, default -1
limitintNoNumber of records limit, default 100
is_briefboolNoReturn abbreviated order information; default false
statesvalueNoOrder status filter array
sort_byOrderSortByNoOrdering 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_typeSegmentTypeNoAccount 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


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)

ParameterTypeRequiredDescription
accountutility::string_tNoAccount ID
sec_typeutility::string_tNoSecurity type, default empty
marketutility::string_tNoMarket, default U("ALL")
symbolutility::string_tNoSymbol
start_datetime_tNoStart timestamp, filtered against the timestamp selected by sort_by, default -1
end_datetime_tNoEnd timestamp, filtered against the timestamp selected by sort_by, default -1
parent_idunsigned long longNoDefaults to 0; the current get_active_orders implementation does not send this parameter
sort_byutility::string_tNoOrdering 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_typeutility::string_tNoAccount 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


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


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


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)

ParameterTypeRequiredDescription
accountutility::string_tYesAccount ID
order_idlong longYesOrder 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)

ParameterTypeRequiredDescription
accountutility::string_tYesAccount ID
symbolutility::string_tYesSymbol
sec_typeutility::string_tNoSecurity type, default empty
start_timelongNoStart timestamp (milliseconds), default -1
end_timetime_tNoEnd timestamp (milliseconds), default -1
limitintNoNumber of records limit, default 100
expiryutility::string_tNoOption expiry date
strikeutility::string_tNoOption strike price
rightutility::string_tNoOption direction, e.g., U("PUT")/U("CALL")
order_idlong longNoOrder 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


Preview an Order

value TradeClient::preview_order(Order &order)

Description

Returns estimated commission, margin, and other order details without submitting the order.

Parameters

ParameterTypeRequiredDescription
orderOrder&YesOrder 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;

Did this page help you?