Get Order Information
get_orders Get a List of Orders
TradeClient.get_orders(account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None, limit=100, is_brief=False, states=None, sort_by=None, seg_type=None)
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 | str | No | Account id, if left empty, this method will 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(included). 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(excluded). 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 | 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 enumeration objects. If provided, filtering will be applied based on status. |
sort_by | OrderSortBy | No | Fields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_CREATED |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType |
Response
list
Each element in this list is an Order object (tigeropen.trade.domain.order.Order), for details, please see Order Object section.
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
orders = trade_client.get_orders(sec_type=SecurityType.STK, market=Market.ALL)
orders = trade_client.get_orders(limit=10,
start_time='2022-09-02 01:00:00', end_time='2022-11-08 00:00:00',
seg_type='SEC'
)
orders = trade_client.get_orders(limit=10,
start_time=1656224964000, end_time=1666224964000,
seg_type='SEC'
)
# check order
order1 = orders[0]
print(order1.status) # order status
print(order1.id) # order id
print(order1.contract.symbol) # order contract id
print(order1.contract.sec_type) # order type
Get order by page
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='', tiger_id='your tiger id', account='your account', secret_key='')
trade_client = TradeClient(client_config)
def test_get_orders_by_page():
result = list()
limit = 300
conditions = {
'limit': limit,
'start_time': '2025-01-01',
'end_time': '2025-02-12',
# The return data is in reverse order in time, that is, the latest data is in the first place. Here is sorted by order_time
'sort_by': OrderSortBy.LATEST_CREATED,
}
orders_page = trade_client.get_orders(**conditions)
result.extend(orders_page)
while len(orders_page) == limit:
next_order_time = orders_page[-1].order_time
conditions.pop('end_time', None)
orders_page = trade_client.get_orders(**conditions, end_time=next_order_time)
result.extend(orders_page)
print(f'total order size: {len(result)}')
return result
Return
[Order({'account': '1', 'id': 162998104807903232, 'order_id': 341, 'parent_id': 0, 'order_time': 1557972846184, 'reason': '136:Order is already being cancelled.', 'trade_time': 1557975394512, 'action': 'BUY', 'quantity': 2, 'filled': 0, 'avg_fill_price': 0, 'commission': 0, 'realized_pnl': 0, 'trail_stop_price': None, 'limit_price': 0.1, 'aux_price': None, 'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': 'DAY', 'outside_rth': True, 'contract': SPY, 'status': 'CANCELLED', 'remaining': 2}),
Order({'account': '1', 'id': 162998998620389376, 'order_id': 344, 'parent_id': 0, 'order_time': 1557973698590, 'reason': '136:Order is already being cancelled.', 'trade_time': 1557973773622, 'action': 'BUY', 'quantity': 1, 'filled': 0, 'avg_fill_price': 0, 'commission': 0, 'realized_pnl': 0, 'trail_stop_price': None, 'limit_price': 0.1, 'aux_price': None, 'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': 'DAY', 'outside_rth': True, 'contract': SPY, 'status': 'CANCELLED', 'remaining': 1}),
Order({'account': '1', 'id': 152239266327625728, 'order_id': 230, 'parent_id': 0, 'order_time': 1547712418243, 'reason': '201:Order rejected - Reason: YOUR ORDER IS NOT ACCEPTED. IN ORDER TO OBTAIN THE DESIRED POSITION YOUR EQUITY WITH LOAN VALUE [1247.90 USD] MUST EXCEED THE INITIAL MARGIN [4989.99 USD]', 'trade_time': 1547712418275, 'action': 'BUY', 'quantity': 100, 'filled': 0, 'avg_fill_price': 0, 'commission': 0, 'realized_pnl': 0, 'trail_stop_price': None, 'limit_price': 5, 'aux_price': None, 'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': 'DAY', 'outside_rth': True, 'contract': AAPL, 'status': 'REJECTED', 'remaining': 100})]
get_order Get Order
TradeClient.get_order(account=None, id=None, order_id=None, is_brief=False, show_charges=None)
Description
Retrieve an order by its order id
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
account | str | No | Account id, if left empty, the API witll return the default account defined in client_config |
id | int | Yes | order id, this id is used to identify an order on the server |
order_id | int | No | local order id |
is_brief | bool | No | [Only global account], 0 for detailed information, 1 for concise information |
show_charges | bool | No | Whether to show list of tigeropen.trade.domain.order.Charge |
Response
Order
Object
Refer to Order object for more details
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
print(trade_client.get_order(id=31059079170361344))
Response Example
Order({'account': '572386', 'id': 31059079170361344, 'order_id': 948, 'parent_id': None, 'order_time': 1685861168000,
'reason': '订单已过期', 'trade_time': 1686010200000, 'action': 'BUY', 'quantity': 1, 'filled': 0, 'avg_fill_price': 0.0,
'commission': 0.0, 'realized_pnl': 0.0, 'trail_stop_price': None, 'limit_price': 100.0, 'aux_price': None,
'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': 'DAY', 'outside_rth': True,
'order_legs': None, 'algo_params': None, 'algo_strategy': 'LMT', 'secret_key': '', 'liquidation': False, 'discount': 0,
'attr_desc': None, 'source': 'OpenApi', 'adjust_limit': None, 'sub_ids': None, 'user_mark': '',
'update_time': 1686010200000, 'expire_time': None, 'can_modify': False, 'external_id': '948', 'combo_type': None,
'combo_type_desc': None, 'is_open': True, 'contract_legs': None, 'filled_scale': 0, 'total_cash_amount': None,
'filled_cash_amount': 0.0, 'refund_cash_amount': None, 'attr_list': ['ALGORITHM', 'NON_TRADING_HOURS', 'TEST_ORDER'],
'latest_price': 215.82, 'orders': None, 'gst': 0.0, 'quantity_scale': 0, 'trading_session_type': None, 'charges': None,
'contract': AAPL/STK/USD, 'status': 'CANCELLED', 'remaining': 1})
get_open_orders Get Open Orders
TradeClient.get_open_orders(account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None, parent_id=None, sort_by=None, seg_type=None, **kwargs)
Description
Get a list of open orders
Parameters
Parameter | 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 |
parent_id | int | No | Main order_id |
sort_by | OrderSortBy | No | Field used to sort and filter start_time and end_time,available value can be imported from tigeropen.common.consts , like LATEST_CREATED or LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType |
Response
list
Each element of this list is an Order
object (tigeropen.trade.domain.order.Order), Refer to Order object for details
Response
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
open_orders = trade_client.get_open_orders(sec_type=SecurityType.STK, market=Market.ALL)
Response Example
See get_orders
get_cancelled_orders Get a List of Canceled Orders
TradeClient.get_cancelled_orders(account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None, sort_by=None, seg_type=None, **kwargs)
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.
Parameters
Parameter | 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 |
sort_by | OrderSortBy | No | Field used to sort and filter start_time and end_time,available value can be imported from tigeropen.common.consts , like LATEST_CREATED or LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType |
Response
list
Each element of this list is an Order
object. Refer to Order object for details
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
cancelled_orders = trade_client.get_cancelled_orders(sec_type=SecurityType.STK, market=Market.ALL)
Response Example
See get_orders
get_filled_orders Get a List of Filled Orders
TradeClient.get_filled_orders(account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None, sort_by=None, seg_type=None, **kwargs)
Description
Get filled order history, The order may have a partially completed status. At this time, the order status is quite special. It may be any of HELD, CANCELLED, EXPIRED, and REJECTED. Partial transaction status
Parameters
Parameter | 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 | Yes | 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 | Yes | 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 |
sort_by | OrderSortBy | No | Field used to sort and filter start_time and end_time,available value can be imported from tigeropen.common.consts , like LATEST_CREATED or LATEST_STATUS_UPDATED |
seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType |
The interval between start_time
and end_time
cannot exceed 90 days
Responselist
Each element of this list is an order
object, refer to Order object for details
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
print(trade_client.get_filled_orders(start_time='2025-01-05',end_time='2025-03-29'))
Response Examples
See get_orders
get_transactions
TradeClient.get_transactions(account=None, order_id=None, symbol=None, sec_type=None, start_time=None, end_time=None, limit=100, expiry=None, strike=None, put_call=None)
Description
Get a detailed list of filled order (Only for Prime Accounts)。
Parameters
Note: When making a request, either the order_id should be passed, or the symbol and sec_type should be passed.
Parameter | 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 | Yes when symbol + sec_type are not provided | Order id |
symbol | str | Yes when order_id is not provided | Ticker symbol of the security, sec_type is required when filtering by symbol |
sec_type | SecurityType | Yes when order_id is not provided | 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.
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='path of .pem file', tiger_id='your tiger id', account='your account', secret_key='secret key for registered traders, only applicable to institutions')
trade_client = TradeClient(client_config)
filled_orders = trade_client.get_transactions(symbol='AAPL', sec_type=SecurityType.STK)
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'})]