Order Queries
Orders
OrdersPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
SortBy | string | No | Omitted if empty | Allowed values: LATEST_CREATED, LATEST_STATUS_UPDATED |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Order, error). Key fields from model.Order:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ID | int64 | Order ID |
| OrderId | int64 | Order number |
| Action | string | Trade direction (BUY/SELL) |
| OrderType | string | Order type |
| TotalQuantity | int64 | Order quantity |
| LimitPrice | float64 | Limit price |
| AuxPrice | float64 | Auxiliary price (stop price) |
| TrailingPercent | float64 | Trailing stop percentage |
| Status | string | Order status |
| FilledQuantity | int64 | Filled quantity |
| AvgFillPrice | float64 | Average fill price |
| TimeInForce | string | Time in force |
| OutsideRth | bool | Outside 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
GetOrderPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
(*model.Order, error). Key fields from model.Order:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ID | int64 | Order ID |
| OrderId | int64 | Order number |
| Action | string | Trade direction (BUY/SELL) |
| OrderType | string | Order type |
| TotalQuantity | int64 | Order quantity |
| LimitPrice | float64 | Limit price |
| AuxPrice | float64 | Auxiliary price (stop price) |
| TrailingPercent | float64 | Trailing stop percentage |
| Status | string | Order status |
| FilledQuantity | int64 | Filled quantity |
| AvgFillPrice | float64 | Average fill price |
| TimeInForce | string | Time in force |
| OutsideRth | bool | Outside 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
ActiveOrdersPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
SortBy | string | No | Omitted if empty | Allowed values: LATEST_CREATED, LATEST_STATUS_UPDATED |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Order, error). Key fields from model.Order:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ID | int64 | Order ID |
| OrderId | int64 | Order number |
| Action | string | Trade direction (BUY/SELL) |
| OrderType | string | Order type |
| TotalQuantity | int64 | Order quantity |
| LimitPrice | float64 | Limit price |
| AuxPrice | float64 | Auxiliary price (stop price) |
| TrailingPercent | float64 | Trailing stop percentage |
| Status | string | Order status |
| FilledQuantity | int64 | Filled quantity |
| AvgFillPrice | float64 | Average fill price |
| TimeInForce | string | Time in force |
| OutsideRth | bool | Outside 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
InactiveOrdersPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
SortBy | string | No | Omitted if empty | Allowed values: LATEST_CREATED, LATEST_STATUS_UPDATED |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Order, error). Key fields from model.Order:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ID | int64 | Order ID |
| OrderId | int64 | Order number |
| Action | string | Trade direction (BUY/SELL) |
| OrderType | string | Order type |
| TotalQuantity | int64 | Order quantity |
| LimitPrice | float64 | Limit price |
| AuxPrice | float64 | Auxiliary price (stop price) |
| TrailingPercent | float64 | Trailing stop percentage |
| Status | string | Order status |
| FilledQuantity | int64 | Filled quantity |
| AvgFillPrice | float64 | Average fill price |
| TimeInForce | string | Time in force |
| OutsideRth | bool | Outside 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
FilledOrdersPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
Market | string | No | Omitted if empty | Allowed values: ALL, US, HK, CN, SG |
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | No | Omitted if empty | Allowed values: ALL, SEC, FUT, FUND |
SortBy | string | No | Omitted if empty | Allowed values: LATEST_CREATED, LATEST_STATUS_UPDATED |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Order, error). Key fields from model.Order:
| Field | Type | Description |
|---|---|---|
| Account | string | Account ID |
| ID | int64 | Order ID |
| OrderId | int64 | Order number |
| Action | string | Trade direction (BUY/SELL) |
| OrderType | string | Order type |
| TotalQuantity | int64 | Order quantity |
| LimitPrice | float64 | Limit price |
| AuxPrice | float64 | Auxiliary price (stop price) |
| TrailingPercent | float64 | Trailing stop percentage |
| Status | string | Order status |
| FilledQuantity | int64 | Filled quantity |
| AvgFillPrice | float64 | Average fill price |
| TimeInForce | string | Time in force |
| OutsideRth | bool | Outside 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
OrderTransactionsPurpose
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 field | Type | Required | Serialization | SDK default and constraints |
|---|---|---|---|---|
SecType | string | No | Omitted if empty | Allowed values: ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SinceDate | string | No | Omitted if empty | None; yyyyMMdd |
Right | string | No | Omitted if empty | Allowed values: PUT, CALL (option side); br, nr when used as quote adjustment |
Lang | string | No | Omitted if empty | Allowed values: zh_CN, zh_TW, en_US |
Returns
([]model.Transaction, error). Key fields from model.Transaction:
| Field | Type | Description |
|---|---|---|
| ID | int64 | Transaction record ID |
| OrderID | int64 | Order ID |
| AccountId | int64 | Account numeric ID |
| Account | string | Account ID |
| Symbol | string | Symbol code |
| SecType | string | Security type |
| Market | string | Market |
| Currency | string | Currency |
| Identifier | string | Identifier |
| Action | string | Trade direction (BUY/SELL) |
| Price | float64 | Order price |
| FilledPrice | float64 | Filled price |
| Quantity | int64 | Order quantity |
| FilledQuantity | int64 | Filled 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"
}
]Updated about 17 hours ago
