Get Order Information
get_orders Get Order List
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, page_token=None)
Description
Get account order records, including all order statuses and orders of various security types. Parameters can be passed for filtering.
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config |
| sec_type | SecurityType | No | Security type. Can use constants from tigeropen.common.consts.SecurityType |
| market | Market | No | Market. Can use constants from tigeropen.common.consts.Market |
| symbol | str | No | Security symbol |
| start_time | str or int | No | Start time (closed interval). Millisecond timestamp or date string, e.g. 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00'. (When sort_by=LATEST_STATUS_UPDATED, filters by order status update time) |
| end_time | str or int | No | End time (open interval). Millisecond timestamp or date string, e.g. 1653346000000 or '2019-11-01' or '2019-11-01 15:00:00'. (When sort_by=LATEST_STATUS_UPDATED, filters by order status update time) |
| limit | int | No | Number of orders to retrieve per request. Default: 100, Maximum: 300 |
| is_brief | bool | No | 【Only supports Global accounts】 Whether to return brief order data |
| status | list[OrderStatus] | No | 【Only supports Global accounts】 Order status. Can use enums from tigeropen.common.consts.OrderStatus |
| sort_by | OrderSortBy | No | 【Only supports Prime accounts】 Sorting and time range field: LATEST_CREATED/LATEST_STATUS_UPDATED; Default: LATEST_CREATED |
| seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for securities; SegmentType.FUT for commodities. Can import from tigeropen.common.consts.SegmentType |
| page_token | str | No | Page token. Note: If this field is set (pass empty string initially, then pass the next_page_token value from response), the return structure changes - instead of returning order list, returns OrdersResponse object with result and page_token fields |
Returns
list or OrdersResponse
If page_token is not None in the request, returns OrdersResponse object (OrdersResponse.result field contains order list, OrdersResponse.next_page_token contains next page token). Otherwise returns order list.
Each element in the list is an Order object (tigeropen.trade.domain.order.Order). For detailed field descriptions, see Order Object
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
orders = trade_client.get_orders(sec_type=SecurityType.STK, market=Market.ALL)
# Limit return count; filter by order time (if start_time/end_time are strings, server treats as Beijing time by default; client_config.timezone can set timezone, after setting, time strings are treated as that timezone's time)
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'
)
# View order properties
order1 = orders[0]
print(order1.status) # Order status
print(order1.id) # Order ID
print(order1.contract.symbol) # Contract symbol
print(order1.contract.sec_type) # Contract typeGet orders using page_token pagination
def test_get_orders_by_page():
results = []
params = {
'sec_type': 'STK',
'start_time': int(datetime.strptime('2023-01-01', '%Y-%m-%d').timestamp() * 1000),
'end_time': int(datetime.strptime('2025-08-01', '%Y-%m-%d').timestamp() * 1000),
'limit': 10,
'page_token': ''
}
page = 1
while True:
response: OrdersResponse = trade_client.get_orders(**params)
print(f'page {page}, size {len(response.result)}, next_page_token: {response.next_page_token}')
page += 1
if response.result:
results.extend(response.result)
if not response.next_page_token:
break
params['page_token'] = response.next_page_token
print(f'total: {len(results)}, results: {results}')
Get orders paginated by time
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
def test_get_orders_by_page():
result = list()
# Number returned each time (must be <= 300)
limit = 300
conditions = {
'limit': limit,
'start_time': '2025-01-01',
'end_time': '2025-02-12',
# Return data is in reverse chronological order, newest first. Sorted by order_time here
'sort_by': OrderSortBy.LATEST_CREATED,
# Can add other filter conditions
}
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 resultReturn Example
[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 Specific Order
TradeClient.get_order(account=None, id=None, order_id=None, is_brief=False, show_charges=None)
Description
Get a specific order by ID
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config |
| id | int | Yes | Global order ID returned after order submission |
| order_id | int | No | 【Only supports Global accounts】 Local order ID |
| is_brief | bool | No | 【Only supports Global accounts】 Return brief order data |
| show_charges | bool | No | Whether to display list of tigeropen.trade.domain.order.Charge |
Returns
Order object
For detailed field descriptions, see Order Object
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
print(trade_client.get_order(id=31059079170361344))Return Example
Order({'account': '111111', 'id': 31059079170361344, 'order_id': 948, 'parent_id': None, 'order_time': 1685861168000,
'reason': 'Order expired', '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 Pending Orders List
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 list of pending orders, may include partially filled orders where the unfilled portion remains pending.
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config |
| sec_type | SecurityType | No | Security type. Can use constants from tigeropen.common.consts.SecurityType |
| market | Market | No | Market. Can use constants from tigeropen.common.consts.Market, e.g. Market.US |
| symbol | str | No | Security symbol |
| start_time | str or int | No | Start time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| end_time | str or int | No | End time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| parent_id | int | No | Parent order ID |
| sort_by | OrderSortBy | No | Field for sorting and filtering start_time and end_time. Can import values from tigeropen.common.consts, e.g. LATEST_CREATED or LATEST_STATUS_UPDATED |
| seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for securities; SegmentType.FUT for commodities. Can import from tigeropen.common.consts.SegmentType |
Returns
list
Each element in the list is an Order object (tigeropen.trade.domain.order.Order). For detailed field descriptions, see Order Object
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
open_orders = trade_client.get_open_orders(sec_type=SecurityType.STK, market=Market.ALL)Return Example
Same as get_orders
get_cancelled_orders Get Cancelled Orders List
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 list of cancelled orders, including: manually cancelled, system cancelled, expired orders, etc. May include partially filled orders where the unfilled portion was cancelled.
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config |
| sec_type | SecurityType | No | Security type. Can use constants from tigeropen.common.consts.SecurityType |
| market | Market | No | Market. Can use constants from tigeropen.common.consts.Market, e.g. Market.US |
| symbol | str | No | Security symbol |
| start_time | str or int | No | Start time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| end_time | str or int | No | End time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| sort_by | OrderSortBy | No | Field for sorting and filtering start_time and end_time. Can import values from tigeropen.common.consts, e.g. LATEST_CREATED or LATEST_STATUS_UPDATED |
| seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for securities; SegmentType.FUT for commodities. Can import from tigeropen.common.consts.SegmentType |
Returns
list
Each element in the list is an Order object. For detailed field descriptions, see Order Object
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
cancelled_orders = trade_client.get_cancelled_orders(sec_type=SecurityType.STK, market=Market.ALL)Return Example
Same as get_orders
get_filled_orders Get Filled Orders List
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 list of filled orders
Orders may have partial fill status, in which case the order status might be HELD, CANCELLED, EXPIRED, or REJECTED.
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config |
| sec_type | SecurityType | No | Security type. Can use constants from tigeropen.common.consts.SecurityType |
| market | Market | No | Market. Can use constants from tigeropen.common.consts.Market, e.g. Market.US |
| symbol | str | No | Security symbol |
| start_time | str or int | Yes | Start time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| end_time | str or int | Yes | End time. Millisecond timestamp or datetime string, e.g. 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07' |
| sort_by | OrderSortBy | No | Field for sorting and filtering start_time and end_time. Can import values from tigeropen.common.consts, e.g. LATEST_CREATED or LATEST_STATUS_UPDATED |
| seg_type | SegmentType | No | Account segment. Available: SegmentType.SEC for securities; SegmentType.FUT for commodities. Can import from tigeropen.common.consts.SegmentType |
Note: The interval between start_time and end_time cannot exceed 90 days
Returns
list
Each element in the list is an Order object. For detailed field descriptions, see Order Object
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
print(trade_client.get_filled_orders(start_time='2025-01-05',end_time='2025-03-29'))Return Example
Same as get_orders
get_transactions Get Order Transaction Records
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 detailed transaction records of filled orders (only applicable to prime/paper trading accounts).
Parameters
Note: When making requests, parameters must be provided as either:
order_id- or
symbolandsec_type
| Parameter Name | Type | Required | Description | Remarks |
|---|---|---|---|---|
| account | str | No | Account ID. If not provided, uses the default account from client_config | |
| order_id | int | Yes/No(required when symbol+sec_type not provided) | Global order ID returned after order placement, not local order ID | |
| symbol | str | Yes/No(required when order_id not provided) | Underlying symbol. When querying by symbol, sec_type is required | |
| sec_type | SecurityType | Yes/No(required when order_id not provided) | Underlying type. When querying by symbol, sec_type is required | Security type. Can use constants from tigeropen.common.consts.SecurityType |
| start_time | str or int | No | Start time for order last update time. Millisecond timestamp or date string, e.g. 1643346000000 or '2019-01-01' or '2019-01-01 12:00:00' | |
| end_time | str or int | No | End time for order last update time. Millisecond timestamp or date string, e.g. 1653346000000 or '2019-11-01' or '2019-11-01 15:00:00' | |
| limit | int | No | Number of records to retrieve per request, maximum 100, default 20 | |
| expiry | str | No | Expiry date (for options). Format 'yyyyMMdd', e.g. '220121' | |
| strike | float | No | Strike price (for options). e.g. 100.5 | |
| put_call | str | No | Call or Put (for options). 'PUT' or 'CALL' | |
| page_token | str | No | Page token. Note: If this field is set (pass empty string initially, then pass next_page_token value), return structure changes - returns TransactionsResponse object with result list and page_token fields instead of transaction list |
Returns
list or TransactionsResponse
If page_token is not None in the request, returns TransactionsResponse object (TransactionsResponse.result field contains transaction list, TransactionsResponse.next_page_token contains next page token). Otherwise returns transaction list.
Each element in the list is a Transaction object. For detailed field descriptions, see Transaction
Example
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
filled_orders = trade_client.get_transactions(symbol='AAPL', sec_type=SecurityType.STK)Get transactions using page_token pagination
def test_get_transaction_by_page():
"""Get all transaction records
Get all transaction records within specified time range using pagination
"""
results = []
params = {
'symbol': 'AAPL',
'start_time': int(datetime.strptime('2023-01-01', '%Y-%m-%d').timestamp() * 1000),
'end_time': int(datetime.strptime('2025-08-01', '%Y-%m-%d').timestamp() * 1000),
'limit': 15,
'page_token': ''
}
page = 1
while True:
response: TransactionsResponse = trade_client.get_transactions(**params)
print(f'page {page}, size {len(response.result)}, next_page_token: {response.next_page_token}')
page += 1
if response.result:
results.extend(response.result)
if not response.next_page_token:
break
params['page_token'] = response.next_page_token
print(f'total: {len(results)}, results: {results}')Return 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'})]
preview_order Preview Order
TradeClient.preview_order(order)
Description
Preview order, returns whether the order can be submitted (i.e., whether the order can be filled) and asset information.
Parameters
Same as order placement interface, an Order object.
Currently does not support OCA orders and attached orders.
Returns
| Field | Type | Description |
|---|---|---|
| account | str | Account ID |
| init_margin | float | Initial margin after order placement, does not support futures |
| maint_margin | float | Maintenance margin after order placement, does not support futures |
| equity_with_loan | float | Borrowable equity after order placement, does not support futures |
| init_margin_before | float | Initial margin before order placement, does not support futures |
| maint_margin_before | float | Maintenance margin before order placement, does not support futures |
| equity_with_loan_before | float | Borrowable equity before order placement, does not support futures |
| margin_currency | str | Margin currency |
| commission | float | Estimated commission |
| gst | float | Estimated GST |
| commission_currency | str | Estimated commission currency |
| available_ee | float | Available remaining equity, does not support futures |
| excess_liquidity | float | Excess liquidity, does not support futures |
| overnight_liquidation | float | Overnight excess liquidity, does not support futures |
| is_pass | bool | Whether order can be submitted |
| message | str | Error reason if order cannot be submitted |
Example
from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
trade_client = TradeClient(client_config)
contract = stock_contract(symbol='AAPL', currency='USD')
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=170, quantity=5)
result = trade_client.preview_order(order)
print(result)Return Example
{"account": "111111", "init_margin": 3937.6255463, "maint_margin": 3437.6255463, "equity_with_loan": 1250864.63784,
"init_margin_before": 937.6255463, "maint_margin_before": 937.6255463, "equity_with_loan_before": 1250890.48784,
"margin_currency": "USD", "commission": 23.72, "commission_currency": "USD",
"available_ee": 1246927.0122936, "excess_liquidity": 1247427.0122936, "overnight_liquidation": 1247427.0122936,
"gst": 2.13, "is_pass": True
}
{'account': '111111', 'init_margin': 10000004816.402893, 'maint_margin': 10000004816.402893,
'equity_with_loan': -24603909.5121613, 'init_margin_before': 937.6255463,
'maint_margin_before': 937.6255463, 'equity_with_loan_before': 1250890.48784,
'margin_currency': 'USD', 'commission': 23720000.0, 'commission_currency': 'USD',
'available_ee': -10024608725.915054, 'excess_liquidity': -10024608725.915054,
'overnight_liquidation': -10024608725.915054, 'gst': 2134800.0,
'is_pass': False, 'message': 'Insufficient available funds or buying power'}Updated 1 day ago
