Get Order Information
get_orders Get a List of Orders
value get_orders(string account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
string symbol = "", long start_time = -1, long end_time = -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
Arguments
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | Account id, if left empty, this method witll use the default account id defined in client_config |
sec_type | SecurityType | no | Security type, you can use the constants defined in tigeropen.common.consts.SecurityType |
market | Market | no | Filter by market, you can use the constants defined in tigeropen.common.consts.Market |
symbol | str | no | Ticker symbol of the security |
start_time | str/int | no | Start time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
end_time | str/int | no | End time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
is_brief | bool | no | A bool,if true, the interface will return simplified order data |
status | OrderStatus | no | Order Status,yoiu can use constants defined in tigeropen.common.consts.OrderStatus |
sort_by | OrderSortBy | no | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_CREATED |
secret_key | str | no | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
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": "402901",
"action": "BUY",
"algoStrategy": "LMT",
"attrDesc": "",
"avgFillPrice": 0,
"canCancel": false,
"canModify": false,
"commission": 0,
"currency": "USD",
"discount": 0,
"filledQuantity": 0,
"id": 29404332116673536,
"identifier": "AAPL",
"latestTime": 1673313004000,
"limitPrice": 100,
"liquidation": false,
"market": "US",
"name": "Apple Inc",
"openTime": 1673236450000,
"orderId": 1276,
"orderType": "LMT",
"outsideRth": true,
"realizedPnl": 0,
"remark": "Order is expired",
"secType": "STK",
"source": "OpenApi",
"status": "Cancelled",
"symbol": "AAPL",
"timeInForce": "DAY",
"totalQuantity": 1,
"updateTime": 1673313004000,
"userMark": ""
},
{
"account": "402901",
"action": "BUY",
"algoStrategy": "LMT",
"attrDesc": "",
"avgFillPrice": 0,
"canCancel": false,
"canModify": false,
"commission": 0,
"currency": "USD",
"discount": 0,
"filledQuantity": 0,
"id": 29404332093867008,
"identifier": "AAPL",
"latestTime": 1673236453000,
"limitPrice": 100,
"liquidation": false,
"market": "US",
"name": "Apple Inc",
"openTime": 1673236450000,
"orderId": 1275,
"orderType": "LMT",
"outsideRth": true,
"realizedPnl": 0,
"secType": "STK",
"source": "OpenApi",
"status": "Cancelled",
"symbol": "AAPL",
"timeInForce": "DAY",
"totalQuantity": 1,
"updateTime": 1673236453000,
"userMark": ""
}
]
get_order Get Order
Order get_order(long id);
Description
Retreive an order by its order id
Arguments
Argument | Type | Required | Description |
---|---|---|---|
id | int | yes | order id, this id is used to identify an order on the server |
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":"",
"avgFillPrice":0,
"canCancel":false,
"canModify":false,
"commission":0,
"currency":"USD",
"discount":0,
"filledQuantity":0,
"id":29143867257783296,
"identifier":"AAPL",
"latestTime":1671330602000,
"limitPrice":100,
"liquidation":false,
"market":"US",
"name":"Apple Inc",
"openTime":1671249261000,
"orderId":1176,
"orderType":"LMT",
"outsideRth":true,
"realizedPnl":0,
"remark":"Order is expired",
"secType":"STK",
"source":"OpenApi",
"status":"Inactive",
"symbol":"AAPL",
"timeInForce":"DAY",
"totalQuantity":1,
"updateTime":1671330602000,
"userMark":""
}
get_active_orders Get Open Orders
value get_active_orders(string account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
string symbol = "", long start_time = -1, long end_time = -1, long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC)
Description
Get a list of open orders
Arguments
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | Account id, if left empty, the API witll return the default account defined in client_config |
sec_type | SecurityType | no | Security type, you can use the constants defined in tigeropen.common.consts.SecurityType |
market | Market | no | Affiliated market,you can use the constants defined in tigeropen.common.consts.Market |
symbol | str | no | Ticker symbol of the security |
start_time | str/int | no | Start time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
end_time | str/int | no | End time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
secret_key | str | no | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
Response
list
Each element of this list is an Order
object (tigeropen.trade.domain.order.Order), 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
same as get_orders
get_cancelled_orders Get a List of Canceled Orders
value get_cancelled_orders(string account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
string symbol = "", long start_time = -1, long end_time = -1, long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC)
Description
Get a list of cancelled orders. The list also includes orders that are cancelled by our system, and any orders that are expired but not filled.
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | Account id, if left empty, the API witll return the default account defined in client_config |
sec_type | SecurityType | no | Security type, you can use the constants defined in tigeropen.common.consts.SecurityType |
market | Market | no | Filter by market, you can use the constants defined in tigeropen.common.consts.Market |
symbol | str | no | Ticker symbol of the security |
start_time | str/int | no | Start time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
end_time | str/int | no | End time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
secret_key | str | no | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
Response
list
Each element of this list is an Order
object. Refer to Order object for details
Example
same as get_orders
get_filled_orders Get a List of Filled Orders
value get_filled_orders(string account, SecType sec_type = SecType::ALL,
Market market = Market::ALL,
string symbol = "", long start_time = -1, long end_time = -1, long parent_id = 0,
OrderSortBy sort_by = OrderSortBy::LATEST_STATUS_UPDATED,
SegmentType seg_type = SegmentType::SEC)
Description
Get filled order history
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | Account id, if left empty, the API witll return the default account defined in client_config |
sec_type | SecurityType | no | Security type, you can use the constants defined in tigeropen.common.consts.SecurityType |
market | Market | no | Filter by market, you can use the constants defined in tigeropen.common.consts.Market |
symbol | str | no | Ticker symbol of the security |
start_time | str/int | no | Start time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
end_time | str/int | no | End time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
secret_key | str | no | Secret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user |
Responselist
Each element of this list is an order
object, refer to Order object for details
Example
Response
same as get_orders
get_transactions Get Transactions
Get a detailed list of filled order (Only for Prime Account)。
Argument
Argument | Type | Required | Description |
---|---|---|---|
account | str | no | Account id, if left empty, the API witll return the default account defined in client_config |
order_id | int | no | Order id |
symbol | str | no | Ticker symbol of the security, sec_type is required when filtering by symbol |
sec_type | SecurityType | no | Security type, you can use the constants defined in tigeropen.common.consts.SecurityType |
start_time | str/int | no | Start time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
end_time | str/int | no | End time. Unix time in millisecond, or a string of date and time,for example: 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00 |
limit | int | no | Maximum record returned |
expiry | str | no | Options expiration date, format: 'yyyyMMdd', example: '220121' |
strike | float | no | Options strike price, example: 100.5 |
put_call | str | no | 'PUT' / 'CALL' for options |
Responselist
Each element of this list is a Transaction
object. Transaction
Example
Response Example
Transaction({'account': 111111, 'order_id': 20947299719447552, 'contract': AAPL/STK/USD, 'id': 20947300069016576, 'action': 'BUY', 'filled_quantity': 1, 'filled_price': 132.25, 'filled_amount': 132.25, 'transacted_at': '2020-12-23 17:06:54'}),
Transaction({'account': 111111, 'order_id': 19837920138101760, 'contract': AAPL/STK/USD, 'id': 19837920740508672, 'action': 'BUY', 'filled_quantity': 1, 'filled_price': 116.21, 'filled_amount': 116.21, 'transacted_at': '2020-09-16 18:02:00'})]