Skip to main content

Query Order History

order_history

Input Parameters

ParameterTypeMeaning
accountAccountAccount
start_datestringQuery start date
end_datestring ( optional ) ( None or empty will equals start_date )Query end date
info

Since v2.1.1, this supports longer term historical data inquiry. The day range is limited maximum 30 days per request. For older SDK versions (until v2.1.0), it supports historical data for the past two days.

Result

ParameterTypeMeaning
is_successboolWhether successful
dataListOrderResult list is returned
messagestringError message returned when is_success = false

OrderResult Parameter

Return type : Object

ParameterTypeMeaning
function_typeint (Optional)Function Type : 0 New Order, 10 New Order Executed, 15 Change Price, 20 Change Quantity, 30 Cancel, 90 Failed
datestringTransaction Date
seq_nostringOrder Serial Number
branch_nostringBranch Number
accountstringAccount
order_nostringOrder Number
asset_typeintAsset Type : 0 Stock
marketstringMarket Type : TAIEX Listed, TAISDAQ OTC, TAIEMG EMG
market_typeMarketTypeTrading Session Type : Common, Fixing, IntradayOdd, Odd, Emg, EmgOdd
stock_nostringSymbol
buy_sellintBuy/Sell Type : Buy, Sell
price_typePriceTypeOriginal Order Price Type : Limit, LimitUp, LimitDown, Market, Reference
pricefloatOrder Price
quantityintOriginal Order Quantity
time_in_forceTimeInforceTime In Force : ROD FOK, IOC
order_typeOrderTypeOrder Type : Stock, Margin, Short, DayTrade, SBL
is_pre_orderboolReservation Order Flag
statusintOrder Status, for details please refer to STATUS
after_price_typePriceTypeValid Order Price Type : Limit, LimitUp, LimitDown, Market, Reference
after_pricefloatValid Order Price
unitintTrading Unit
after_qtyintValid Order Quantity (filled quantity included)
filled_qtyintFilled Quantity
filled_moneyintFilled Value
before_qtyintBefore the Quantity Modification
before_pricefloatBefore the Price Modification
user_defstringCustom Fields
last_timestringLast Modification Time
error_messagestringError Message
>> detailslistOrder Process
>> function_typeintFunction Type : 0 New Order, 10 New Order Executed, 15 Change Price, 20 Change Quantity, 30 Cancel, 50 Fully Filled, 90 Failed
>> modified_timestringOrder Modified Time
>> before_qtyintOriginal Order Quantity
>> after_qtyintValid Order Quantity (filled quantity included)
>> before_pricefloatOriginal Order Price
>> after_pricefloatValid Order Price
>> filled_moneyfloatFilled Value
>> statusintOrder Status
>> err_msgstringError Message

Request Example

sdk.stock.order_history(account,"20230921","20230922")

Response Example

Result {
is_success: True,
message: None,
data : [OrderResult{
function_type: None, # Function type (int)
date: "2023/09/21", # Transaction date (date)
seq_no: "00000221427", # Order sequence number (string)
branch_no: "6460", # Branch code (string)
account: "26", # Account (string)
order_no: "bA489", # Order Number (string)
asset_type: 0, # Asset type (int)
market: "TAIEX", # Market Type (string)
market_type: Common, # Trading session type (MarketType)
stock_no: "2888", # Symbol (string)
buy_sell: Buy, # Buy/sell side (BSAction)
price_type: Limit, # Original order price type (PriceType)
price: 9.1, # Price (float)
quantity: 1000, # Original order quantity (int)
time_in_force: ROD, # Time in force (TimeInForce)
order_type: Stock, # Order Type (OrderType)
is_pre_order: False, # Reservation Order Flag (bool)
status: 10, # Order status (int)
after_price_type: , # Valid order price type (PriceType)
after_price: 9.1, # Valid order price (float)
unit: 1000, # Trading unit (int)
after_qty: 1000, # Valid order quantity (int)
filled_qty: 0, # Filled quantity (int)
filled_money: 0, # Filled amount (int)
before_qty: , # Valid quantity before modification (int)
before_price: , # Valid price before modification (float)
user_def: , # Custom Fields (string)
last_time: "09:00:32.477", # Last Modification Time (string)
details:[ # Order history (list)
OrderDetail {
function_type: 10, # Function type (int)
modified_time: "09:00:32.477", # Modification time (string)
before_qty: 0, # Valid quantity before modification (int)
after_qty: 1000, # Valid order quantity (int)
before_price: 9.1, # Valid price before modification (float)
after_price: 9.1 # Valid order price (float)
}
]
error_message: None # Error message (string)
},
... # Additional Result response
]}