Get Order Information

About 6 min

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)

Description

Get a list of all history orders of a specific account id. You can filter the orders by parameters listed below

Arguments

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, this method witll use the default account id defined in client_config
sec_typeSecurityTypenoSecurity type, you can use the constants defined in tigeropen.common.consts.SecurityType
marketMarketnoFilter by market, you can use the constants defined in tigeropen.common.consts.Market
symbolstrnoTicker symbol of the security
start_timestr/intnoStart 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_timestr/intnoEnd 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_briefboolnoA bool,if true, the interface will return simplified order data
statusOrderStatusnoOrder Status,yoiu can use constants defined in tigeropen.common.consts.OrderStatus
sort_byOrderSortBynoFields used to sort and filter start_date and end_date,LATEST_CREATED/LATEST_STATUS_UPDATED; Default:LATEST_CREATED
secret_keystrnoSecret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user

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

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)

Description

Retreive an order by its order id

Arguments

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, the API witll return the default account defined in client_config
idintyesorder id, this id is used to identify an order on the server
order_idintnolocal order id
is_briefboolno[only global account], 0 for detailed information, 1 for concise information
secret_keystrnoSecret key for the trader of institutions, please config in client_config, ignore if you are a indiviual user

Response

OrderObject

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)

order = trade_client.get_order(id=1230001200123)

Response Example

{'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}

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)

Description

Get a list of open orders

Arguments

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, the API witll return the default account defined in client_config
sec_typeSecurityTypenoSecurity type, you can use the constants defined in tigeropen.common.consts.SecurityType
marketMarketnoAffiliated market,you can use the constants defined in tigeropen.common.consts.Market
symbolstrnoTicker symbol of the security
start_timestr/intnoStart 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_timestr/intnoEnd 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_keystrnoSecret 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

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)

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

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, the API witll return the default account defined in client_config
sec_typeSecurityTypenoSecurity type, you can use the constants defined in tigeropen.common.consts.SecurityType
marketMarketnoFilter by market, you can use the constants defined in tigeropen.common.consts.Market
symbolstrnoTicker symbol of the security
start_timestr/intnoStart 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_timestr/intnoEnd 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_keystrnoSecret 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

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)

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

Argument

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, the API witll return the default account defined in client_config
sec_typeSecurityTypenoSecurity type, you can use the constants defined in tigeropen.common.consts.SecurityType
marketMarketnoFilter by market, you can use the constants defined in tigeropen.common.consts.Market
symbolstrnoTicker symbol of the security
start_timestr/intnoStart 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_timestr/intnoEnd 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_keystrnoSecret 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

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_filled_orders(sec_type=SecurityType.STK, market=Market.ALL)

Respons Examples

See get_orders


get_transactions

Description

Get a detailed list of filled order (Only for Prime Account)。

Argument
Note: When making a request, either the order_id should be passed, or the symbol and sec_type should be passed.

ArgumentTypeRequiredDescription
accountstrnoAccount id, if left empty, the API witll return the default account defined in client_config
order_idintnoOrder id
symbolstrnoTicker symbol of the security, sec_type is required when filtering by symbol
sec_typeSecurityTypenoSecurity type, you can use the constants defined in tigeropen.common.consts.SecurityType
start_timestr/intnoStart 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_timestr/intnoEnd 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
limitintnoMaximum record returned
expirystrnoOptions expiration date, format: 'yyyyMMdd', example: '220121'
strikefloatnoOptions strike price, example: 100.5
put_callstrno'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'})]
        
Last update: