Get Order Information
get_order Get Order
Order get_order(unsigned long long id, bool is_brief=false));
Description
Retrieve an order by its order id
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
id | unsigned long long | yes | order id |
is_brief | bool | No | Whether to return simplified order data (Global Accounts Only) default: false |
Response
Order
object
Refer to Order object for more details
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
class TestTradeClient {
public:
static void test_get_order(const std::shared_ptr<TradeClient>& trade_client) {
// Contract contract = stock_contract("AAPL", "USD");
// Order order = limit_order(contract, "BUY", 1, 100.0);
// trade_client->place_order(order);
Order my_order = trade_client->get_order(29270263515317248);
cout << "order : " << my_order.to_string() << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_order(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response
{
"account":"402901",
"action":"BUY",
"algoStrategy":"LMT",
"attrDesc":"",
"attrList":["ALGORITHM","NON_TRADING_HOURS","TEST_ORDER"],
"avgFillPrice":0,
"canCancel":false,
"canModify":false,
"cancelStatus":"NONE",
"commission":0,
"currency":"USD",
"discount":0,
"externalId":"939",
"filledCashAmount":0,
"filledQuantity":0,
"filledQuantityScale":0,
"gst":0,
"id":29143867257783296,
"identifier":"AAPL",
"isOpen":true,
"latestTime":1671330602000,
"limitPrice":100,
"liquidation":false,
"market":"US",
"name":"Apple Inc",
"openTime":1671249261000,
"orderDiscount":0,
"orderId":1176,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"remark":"Order is expired",
"replaceStatus":"NONE",
"secType":"STK",
"source":"OpenApi",
"status":"Inactive",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"totalQuantityScale":0,
"updateTime":1671330602000,
"userMark":""
}
get_orders Get a List of Orders
value get_orders(const utility::string_t &account = U(""), const utility::string_t &sec_type = U(""),
const utility::string_t &market = U("ALL"),
const utility::string_t &symbol = U(""), time_t start_date = -1, time_t end_date = -1, int limit = 100,
bool is_brief = false, const value &states = value::array(), const utility::string_t &sort_by = U(""),
const utility::string_t &seg_type = U(""));
value get_orders(utility::string_t account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, int limit = 100,
bool is_brief = false, const value &states = value::array(),
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC);
Description
Get a list of all history orders of a specific account id. You can filter the orders by parameters listed below
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id, if left empty, this method will use the default account id defined in client_config |
sec_type | SecType | No | Security type |
market | Market | No | Filter by market |
symbol | utility::string_t | No | Ticker symbol of the security |
start_date | time_t | No | Start time. Unix time in millisecond, for example: 1643346000000 Default: -1 |
end_date | time_t | No | End time. Unix time in millisecond,for example: 1643346000000 Default: -1 |
limit | int | No | The number of orders retrieved each time Default: 100 |
is_brief | bool | No | A bool,if true, the interface will return simplified order data |
states | list<OrderStatus> | No | A list of order status enumerations |
sort_by | OrderSortBy | No | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment |
Response
value
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
class TestTradeClient {
public:
static void test_get_orders(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_orders();
cout << "orders: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_orders(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response
[
{
"account":"572386",
"action":"BUY",
"algoStrategy":"LMT",
"attrDesc":"",
"attrList":["ALGORITHM","NON_TRADING_HOURS","TEST_ORDER"],
"avgFillPrice":0,
"canCancel":false,
"canModify":false,
"cancelStatus":"NONE",
"commission":0,
"currency":"USD",
"discount":0,
"externalId":"953",
"filledCashAmount":0,
"filledQuantity":0,
"filledQuantityScale":0,
"gst":0,
"id":31070403805184000,
"identifier":"AAPL",
"isOpen":true,
"latestTime":1686010200000,
"limitPrice":100,
"liquidation":false,
"market":"US",
"name":"Apple",
"openTime":1685947568000,
"orderDiscount":0,
"orderId":953,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"remark":"Order is expired",
"replaceStatus":"NONE",
"secType":"STK",
"source":"OpenApi",
"status":"Cancelled",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"totalQuantityScale":0,
"updateTime":1686010200000,
"userMark":""
},
{
"account":"572386",
"action":"BUY",
"algoStrategy":"LMT",
"attrDesc":"",
"attrList":["ALGORITHM","NON_TRADING_HOURS","TEST_ORDER"],
"avgFillPrice":0,
"canCancel":false,
"canModify":false,
"cancelStatus":"RECEIVED",
"commission":0,
"currency":"USD",
"discount":0,
"externalId":"952",
"filledCashAmount":0,
"filledQuantity":0,
"filledQuantityScale":0,
"gst":0,
"id":31070403803482112,
"identifier":"AAPL",
"isOpen":true,
"latestTime":1685947571000,
"limitPrice":100,
"liquidation":false,
"market":"US",
"name":"Apple",
"openTime":1685947568000,
"orderDiscount":0,
"orderId":952,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"replaceStatus":"NONE",
"secType":"STK",
"source":"OpenApi",
"status":"Cancelled",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"totalQuantityScale":0,
"updateTime":1685947571000,
"userMark":""
}
]
get_active_orders Get Open Orders
value get_active_orders(utility::string_t account = U(""), utility::string_t sec_type = U(""),
utility::string_t market = U("ALL"),
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, unsigned long long parent_id = 0,
utility::string_t sort_by = U(""),
utility::string_t seg_type = U(""));
value get_active_orders(utility::string_t account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, unsigned long long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC);
Description
Get a list of open orders
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id, if left empty, the API will return the default account defined in client_config |
sec_type | SecType | No | Security type default: SecType::ALL |
market | Market | No | Affiliated market default: Market:ALL |
symbol | utility::string_t | No | Ticker symbol of the security |
start_date | time_t | No | Start time. Unix time in milliseconds |
end_date | time_t | No | End time. Unix time in milliseconds |
parent_id | unsigned long long | No | Main order id |
sort_by | OrderSortBy | No | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment default: SegmentType::SEC |
Response
list
Each element of this list is an Order
object (include/tigerapi/enums.h), Refer to Order object for details
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
class TestTradeClient {
public:
static void test_get_active_orders(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_active_orders();
cout << "active orders: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_active_orders(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response
[
{
"account":"572386",
"action":"BUY",
"algoStrategy":"LMT",
"attrDesc":"",
"attrList":["ALGORITHM","NON_TRADING_HOURS","TEST_ORDER"],
"avgFillPrice":0,
"canCancel":true,
"canModify":true,
"cancelStatus":"NONE",
"commission":0,
"currency":"USD",
"discount":0,
"externalId":"1026",
"filledCashAmount":0,
"filledQuantity":0,
"filledQuantityScale":0,
"gst":0,
"id":38442973239706624,
"identifier":"AAPL",
"isOpen":true,
"latestPrice":213.28999999999999,
"latestTime":1742195809000,
"limitPrice":105,
"liquidation":false,
"market":"US",
"name":"Apple",
"openTime":1742195809000,
"orderDiscount":0,
"orderId":1026,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"remark":"Change order succeeded",
"replaceStatus":"REPLACED",
"secType":"STK",
"source":"OpenApi",
"status":"PendingSubmit",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"totalQuantityScale":0,
"tradingSessionType":"PRE_RTH_POST",
"updateTime":1742195810000,
"userMark":""
}
]
get_inactive_orders Get a List of Inactive Orders
value get_inactive_orders(utility::string_t account = U(""), utility::string_t sec_type = U(""),
utility::string_t market = U("ALL"),
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, unsigned long long parent_id = 0,
utility::string_t sort_by = U(""),
utility::string_t seg_type = U(""));
value get_inactive_orders(utility::string_t account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, unsigned long long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC);
Description
Get a list of inactive orders. The list also includes orders that are cancelled by our system, and any orders that are expired but not filled.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id, if left empty, the API witll return the default account defined in client_config |
sec_type | SecType | No | Security type default: SecType::ALL |
market | Market | No | Filter by market default: Market::ALL |
symbol | utility::string_t | No | Ticker symbol of the security |
start_date | time_t | No | Start time. Unix time in milliseconds |
end_date | time_t | No | End time. Unix time in milliseconds |
parent_id | unsigned long long | No | Main order id |
sort_by | OrderSortBy | No | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment default: SegmentType::SEC |
Response
list
Each element of this list is an Order
object. Refer to Order object for details
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
class TestTradeClient {
public:
static void test_get_inctive_orders(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_inactive_orders();
cout << "inactive orders: " << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_inactive_orders(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Example
[
{
"account":"572386",
"action":"BUY",
"algoStrategy":"LMT",
"attrDesc":"",
"attrList":["ALGORITHM","NON_TRADING_HOURS","TEST_ORDER"],
"avgFillPrice":0,
"canCancel":false,
"canModify":false,
"cancelStatus":"RECEIVED",
"commission":0,
"currency":"USD",
"discount":0,
"externalId":"1026",
"filledCashAmount":0,
"filledQuantity":0,
"filledQuantityScale":0,
"gst":0,
"id":38442973239706624,
"identifier":"AAPL",
"isOpen":true,
"latestTime":1742195998000,
"limitPrice":105,
"liquidation":false,
"market":"US",
"name":"Apple",
"openTime":1742195809000,
"orderDiscount":0,
"orderId":1026,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"replaceStatus":"NONE",
"secType":"STK",
"source":"OpenApi",
"status":"Cancelled",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"totalQuantityScale":0,
"tradingSessionType":"PRE_RTH_POST",
"updateTime":1742195998000,
"userMark":""
}
]
get_filled_orders Get a List of Filled Orders
value get_filled_orders(utility::string_t account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
utility::string_t symbol = U(""), time_t start_date = -1, time_t end_date = -1, unsigned long long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC);
Description
Get filled order history
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id, if left empty, the API witll return the default account defined in client_config |
sec_type | SecType | No | Security type default: SecType::ALL |
market | Market | No | Affiliated market default: Market:ALL |
symbol | utility::string_t | No | Ticker symbol of the security |
start_date | time_t | No | Start time. Unix time in milliseconds |
end_date | time_t | No | End time. Unix time in milliseconds |
parent_id | unsigned long long | No | Main order id |
sort_by | OrderSortBy | No | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment default: SegmentType::SEC |
Responselist
Each element of this list is an order
object, refer to Order object for details
Response
same as get_orders but filtered by filled orders
get_transactions Get Transactions
value get_transactions(utility::string_t account, long long order_id);
value get_transactions(utility::string_t account, utility::string_t symbol, utility::string_t sec_type = U(""),
long start_time = -1, time_t end_time = -1,
int limit = 100, utility::string_t expiry = U(""), utility::string_t strike = U(""), utility::string_t right = U(""),
long long order_id = 0);
Description
Get a detailed list of filled order (Only for Prime Account)。
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id |
order_id | int | Yes | Order id |
Parameter | Type | Required | Description |
---|---|---|---|
account | utility::string_t | Yes | Account id |
symbol | utility::string_t | Yes | Ticker symbol of the security |
sec_type | SecType | No | Security type |
start_time | long | No | Start time. Unix time in millisecond,for example: 1643346000000 |
end_time | long | No | End time. Unix time in millisecond, for example: 1643346000000 |
limit | int | No | Maximum record returned |
expiry | utility::string_t | No | Options expiration date, format: 'yyyyMMdd', example: '220121' |
strike | utility::string_t | No | Options strike price, example: 100.5 |
right | utility::string_t | No | 'PUT' / 'CALL' for options |
order_id | int | No | Order id |
Responselist
Field | Type | Description |
---|---|---|
accountId | int | Account id |
action | utility::string_t | Order direction |
currency | utility::string_t | Currency |
filledAmount | float | Transacted amount |
filledPrice | float | Transacted price |
filledQuantity | int | Transacted quantity |
id | int | Transaction id |
market | utility::string_t | Market |
orderId | int | Order id |
secType | utility::string_t | Security type |
symbol | utility::string_t | Ticker symbol of the security |
transactedAt | utility::string_t | Transacted time given as "yyyy-mm-dd 00:00::00" |
transactionTime | time_t | Transacted time given in milliseconds |
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/contract_util.h"
#include "tigerapi/order_util.h"
using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;
class TestTradeClient {
public:
static void test_get_transactions(const std::shared_ptr<TradeClient>& trade_client) {
value res = trade_client->get_transactions(trade_client->client_config.account,U("AAPL"));
cout << U("transactions: ") << res << endl;
}
static void test_trade(const std::shared_ptr<TradeClient>& trade_client) {
TestTradeClient::test_get_transactions(trade_client);
}
};
int main(int argc, char *args[]) {
cout << "Tiger Api main" << endl;
/************************** set config **********************/
ClientConfig config = ClientConfig(true);
config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
"xxxxxx private key xxxxxxxx"
"-----END RSA PRIVATE KEY-----";
config.tiger_id = "Tiger ID";
config.account = "Account ID";
/**
* Use TradeClient
*/
std::shared_ptr<TradeClient> trade_client = std::make_shared<TradeClient>(config);
TestTradeClient::test_trade(trade_client);
return 0;
}
Response Example
[
{
"accountId":572386,
"action":"BUY",
"currency":"USD",
"filledAmount":100,
"filledPrice":25.5749,
"filledQuantity":391,
"id":35631544146200576,
"market":"SI",
"orderId":35620179683181568,
"secType":"FUND",
"symbol":"LU0689472784.USD",
"transactedAt":"2024-07-11 00:00:00",
"transactionTime":1720627200000
},
{
"accountId":572386,
"action":"BUY",
"currency":"USD",
"filledAmount":99.989999999999995,
"filledPrice":25.326899999999998,
"filledQuantity":3948,
"id":35586246013878272,
"market":"SI",
"orderId":35540907181473792,
"secType":"FUND",
"symbol":"LU0689472784.USD",
"transactedAt":"2024-07-05 00:00:00",
"transactionTime":1720108800000
}
]