Order Queries

Orders

Purpose

Lists orders using account, instrument, status, time, and pagination filters. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) Orders(req model.OrdersRequest) ([]model.Order, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.OrdersRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
MarketstringNoOmitted if emptyAllowed values: ALL, US, HK, CN, SG
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
SortBystringNoOmitted if emptyAllowed values: LATEST_CREATED, LATEST_STATUS_UPDATED
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Order, error). Key fields from model.Order:

FieldTypeDescription
AccountstringAccount ID
IDint64Order ID
OrderIdint64Order number
ActionstringTrade direction (BUY/SELL)
OrderTypestringOrder type
TotalQuantityint64Order quantity
LimitPricefloat64Limit price
AuxPricefloat64Auxiliary price (stop price)
TrailingPercentfloat64Trailing stop percentage
StatusstringOrder status
FilledQuantityint64Filled quantity
AvgFillPricefloat64Average fill price
TimeInForcestringTime in force
OutsideRthboolOutside regular trading hours

Invocation example

result, err := tc.Orders(model.OrdersRequest{
	Account: "U123456",
	Market: "US",
	SecType: "STK",
	Symbol: "AAPL",
	StartDate: 1,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 123456789,
    "orderId": 123456789,
    "symbol": "AAPL",
    "secType": "STK",
    "market": "US",
    "action": "BUY",
    "orderType": "LMT",
    "limitPrice": 310.00,
    "totalQuantity": 100,
    "filledQuantity": 100,
    "avgFillPrice": 309.85,
    "status": "Filled",
    "account": "12345678",
    "currency": "USD",
    "openTime": 1785504600000,
    "updateTime": 1785505200000
  }
]

GetOrder

Purpose

Retrieves one order by global ID or account-level order ID. The client fills an empty account field from the client default.

Signature

func (c *TradeClient) GetOrder(req model.GetOrderRequest) (*model.Order, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.GetOrderRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

(*model.Order, error). Key fields from model.Order:

FieldTypeDescription
AccountstringAccount ID
IDint64Order ID
OrderIdint64Order number
ActionstringTrade direction (BUY/SELL)
OrderTypestringOrder type
TotalQuantityint64Order quantity
LimitPricefloat64Limit price
AuxPricefloat64Auxiliary price (stop price)
TrailingPercentfloat64Trailing stop percentage
StatusstringOrder status
FilledQuantityint64Filled quantity
AvgFillPricefloat64Average fill price
TimeInForcestringTime in force
OutsideRthboolOutside regular trading hours

Invocation example

result, err := tc.GetOrder(model.GetOrderRequest{
	Account: "U123456",
	Lang: "en_US",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
{
    "id": 123456789,
    "orderId": 123456789,
    "symbol": "AAPL",
    "secType": "STK",
    "market": "US",
    "action": "BUY",
    "orderType": "LMT",
    "limitPrice": 310.00,
    "totalQuantity": 100,
    "filledQuantity": 100,
    "avgFillPrice": 309.85,
    "status": "Filled",
    "account": "12345678",
    "currency": "USD",
    "openTime": 1785504600000,
    "updateTime": 1785505200000
  }

ActiveOrders

Purpose

Lists open orders and optionally filters attached orders by parent ID. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) ActiveOrders(req model.OrdersRequest) ([]model.Order, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.OrdersRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
MarketstringNoOmitted if emptyAllowed values: ALL, US, HK, CN, SG
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
SortBystringNoOmitted if emptyAllowed values: LATEST_CREATED, LATEST_STATUS_UPDATED
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Order, error). Key fields from model.Order:

FieldTypeDescription
AccountstringAccount ID
IDint64Order ID
OrderIdint64Order number
ActionstringTrade direction (BUY/SELL)
OrderTypestringOrder type
TotalQuantityint64Order quantity
LimitPricefloat64Limit price
AuxPricefloat64Auxiliary price (stop price)
TrailingPercentfloat64Trailing stop percentage
StatusstringOrder status
FilledQuantityint64Filled quantity
AvgFillPricefloat64Average fill price
TimeInForcestringTime in force
OutsideRthboolOutside regular trading hours

Invocation example

result, err := tc.ActiveOrders(model.OrdersRequest{
	Account: "U123456",
	Market: "US",
	SecType: "STK",
	Symbol: "AAPL",
	StartDate: 1,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 123456790,
    "orderId": 123456790,
    "symbol": "TSLA",
    "secType": "STK",
    "market": "US",
    "action": "BUY",
    "orderType": "LMT",
    "limitPrice": 280.00,
    "totalQuantity": 50,
    "filledQuantity": 0,
    "status": "Submitted",
    "account": "12345678",
    "currency": "USD",
    "openTime": 1785504600000
  }
]

InactiveOrders

Purpose

Lists inactive or cancelled orders using OrdersRequest filters. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) InactiveOrders(req model.OrdersRequest) ([]model.Order, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.OrdersRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
MarketstringNoOmitted if emptyAllowed values: ALL, US, HK, CN, SG
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
SortBystringNoOmitted if emptyAllowed values: LATEST_CREATED, LATEST_STATUS_UPDATED
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Order, error). Key fields from model.Order:

FieldTypeDescription
AccountstringAccount ID
IDint64Order ID
OrderIdint64Order number
ActionstringTrade direction (BUY/SELL)
OrderTypestringOrder type
TotalQuantityint64Order quantity
LimitPricefloat64Limit price
AuxPricefloat64Auxiliary price (stop price)
TrailingPercentfloat64Trailing stop percentage
StatusstringOrder status
FilledQuantityint64Filled quantity
AvgFillPricefloat64Average fill price
TimeInForcestringTime in force
OutsideRthboolOutside regular trading hours

Invocation example

result, err := tc.InactiveOrders(model.OrdersRequest{
	Account: "U123456",
	Market: "US",
	SecType: "STK",
	Symbol: "AAPL",
	StartDate: 1,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 123456789,
    "orderId": 123456789,
    "symbol": "AAPL",
    "secType": "STK",
    "market": "US",
    "action": "BUY",
    "orderType": "LMT",
    "limitPrice": 310.00,
    "totalQuantity": 100,
    "filledQuantity": 100,
    "avgFillPrice": 309.85,
    "status": "Filled",
    "account": "12345678",
    "currency": "USD",
    "openTime": 1785504600000,
    "updateTime": 1785505200000
  }
]

FilledOrders

Purpose

Lists filled orders using OrdersRequest filters. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) FilledOrders(req model.OrdersRequest) ([]model.Order, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.OrdersRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
MarketstringNoOmitted if emptyAllowed values: ALL, US, HK, CN, SG
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
SegTypestringNoOmitted if emptyAllowed values: ALL, SEC, FUT, FUND
SortBystringNoOmitted if emptyAllowed values: LATEST_CREATED, LATEST_STATUS_UPDATED
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Order, error). Key fields from model.Order:

FieldTypeDescription
AccountstringAccount ID
IDint64Order ID
OrderIdint64Order number
ActionstringTrade direction (BUY/SELL)
OrderTypestringOrder type
TotalQuantityint64Order quantity
LimitPricefloat64Limit price
AuxPricefloat64Auxiliary price (stop price)
TrailingPercentfloat64Trailing stop percentage
StatusstringOrder status
FilledQuantityint64Filled quantity
AvgFillPricefloat64Average fill price
TimeInForcestringTime in force
OutsideRthboolOutside regular trading hours

Invocation example

result, err := tc.FilledOrders(model.OrdersRequest{
	Account: "U123456",
	Market: "US",
	SecType: "STK",
	Symbol: "AAPL",
	StartDate: 1,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 123456789,
    "orderId": 123456789,
    "symbol": "AAPL",
    "secType": "STK",
    "market": "US",
    "action": "BUY",
    "orderType": "LMT",
    "limitPrice": 310.00,
    "totalQuantity": 100,
    "filledQuantity": 100,
    "avgFillPrice": 309.85,
    "status": "Filled",
    "account": "12345678",
    "currency": "USD",
    "openTime": 1785504600000,
    "updateTime": 1785505200000
  }
]

OrderTransactions

Purpose

Lists execution records for orders or an instrument and time range. The client unwraps the server items envelope, and fills an empty account field from the client default.

Signature

func (c *TradeClient) OrderTransactions(req model.OrderTransactionsRequest) ([]model.Transaction, error)

Requires a trading account accessible through the configuration. Institutional accounts can authenticate with SecretKey.

Parameters

model.OrderTransactionsRequest

SDK fieldTypeRequiredSerializationSDK default and constraints
SecTypestringNoOmitted if emptyAllowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND
SinceDatestringNoOmitted if emptyNone; yyyyMMdd
RightstringNoOmitted if emptyAllowed values: PUT, CALL (option side); br, nr when used as quote adjustment
LangstringNoOmitted if emptyAllowed values: zh_CN, zh_TW, en_US

Returns

([]model.Transaction, error). Key fields from model.Transaction:

FieldTypeDescription
IDint64Transaction record ID
OrderIDint64Order ID
AccountIdint64Account numeric ID
AccountstringAccount ID
SymbolstringSymbol code
SecTypestringSecurity type
MarketstringMarket
CurrencystringCurrency
IdentifierstringIdentifier
ActionstringTrade direction (BUY/SELL)
Pricefloat64Order price
FilledPricefloat64Filled price
Quantityint64Order quantity
FilledQuantityint64Filled quantity

Invocation example

result, err := tc.OrderTransactions(model.OrderTransactionsRequest{
	Account: "U123456",
	Symbol: "AAPL",
	SecType: "STK",
	StartDate: 1,
	EndDate: 1,
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%#v\n", result)
[
  {
    "id": 987654321,
    "orderId": 123456789,
    "symbol": "AAPL",
    "secType": "STK",
    "action": "BUY",
    "filledQuantity": 100,
    "filledPrice": 309.85,
    "filledAmount": 30985.00,
    "transactionTime": 1785505200000,
    "account": "12345678",
    "currency": "USD"
  }
]


Did this page help you?