订单查询
获取订单列表
功能说明
查询全部订单。 req 所有字段可选;Account 留空时自动填默认账户。 方法签名
func (c *TradeClient) Orders(req model.OrdersRequest) ([]model.Order, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.OrdersRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Market | string | 否 | 空值省略 | 无;可选值:ALL, US, HK, CN, SG |
SecType | string | 否 | 空值省略 | 无;可选值:ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
StartDate | int64 | 否 | 空值省略 | 无;ms 时间戳 |
States | []string | 否 | 空值省略 | 无;OrderStatus 值列表 |
SortBy | string | 否 | 空值省略 | 无;可选值:LATEST_CREATED, LATEST_STATUS_UPDATED |
ShowCharges | *bool | 否 | 空值省略 | 无;Python 用 is not None 判断 |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.Order, error)。关键字段来自 model.Order:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| ID | int64 | 订单 ID |
| OrderId | int64 | 订单号 |
| Action | string | 交易方向 (BUY/SELL) |
| OrderType | string | 订单类型 |
| TotalQuantity | int64 | 委托数量 |
| LimitPrice | float64 | 限价 |
| AuxPrice | float64 | 辅助价格(止损价) |
| TrailingPercent | float64 | 跟踪止损百分比 |
| Status | string | 订单状态 |
| FilledQuantity | int64 | 成交数量 |
| AvgFillPrice | float64 | 成交均价 |
| TimeInForce | string | 有效期 |
| OutsideRth | bool | 是否允许盘前盘后 |
示例
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
}
]获取订单详情
功能说明
按订单 ID 查询单个订单详情。 API method: orders(传 id 或 order_id 参数,服务端直接返回单个 Order 对象,不是 {items:[]} 包装)。 必须提供 Id 或 OrderId 之一。没有匹配时返回 nil。 客户端会空账户字段由客户端填入默认账户。
方法签名
func (c *TradeClient) GetOrder(req model.GetOrderRequest) (*model.Order, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.GetOrderRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Id | int64 | 否 | 空值省略 | 无;全局订单 ID |
OrderId | int64 | 否 | 空值省略 | 无;账户维度订单 ID |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
(*model.Order, error)。关键字段来自 model.Order:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| ID | int64 | 订单 ID |
| OrderId | int64 | 订单号 |
| Action | string | 交易方向 (BUY/SELL) |
| OrderType | string | 订单类型 |
| TotalQuantity | int64 | 委托数量 |
| LimitPrice | float64 | 限价 |
| AuxPrice | float64 | 辅助价格(止损价) |
| TrailingPercent | float64 | 跟踪止损百分比 |
| Status | string | 订单状态 |
| FilledQuantity | int64 | 成交数量 |
| AvgFillPrice | float64 | 成交均价 |
| TimeInForce | string | 有效期 |
| OutsideRth | bool | 是否允许盘前盘后 |
示例
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
}获取待成交订单
功能说明
查询待成交订单。支持按 ParentId 过滤附加订单。 方法签名
func (c *TradeClient) ActiveOrders(req model.OrdersRequest) ([]model.Order, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.OrdersRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Market | string | 否 | 空值省略 | 无;可选值:ALL, US, HK, CN, SG |
SecType | string | 否 | 空值省略 | 无;可选值:ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
StartDate | int64 | 否 | 空值省略 | 无;ms 时间戳 |
States | []string | 否 | 空值省略 | 无;OrderStatus 值列表 |
SortBy | string | 否 | 空值省略 | 无;可选值:LATEST_CREATED, LATEST_STATUS_UPDATED |
ShowCharges | *bool | 否 | 空值省略 | 无;Python 用 is not None 判断 |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.Order, error)。关键字段来自 model.Order:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| ID | int64 | 订单 ID |
| OrderId | int64 | 订单号 |
| Action | string | 交易方向 (BUY/SELL) |
| OrderType | string | 订单类型 |
| TotalQuantity | int64 | 委托数量 |
| LimitPrice | float64 | 限价 |
| AuxPrice | float64 | 辅助价格(止损价) |
| TrailingPercent | float64 | 跟踪止损百分比 |
| Status | string | 订单状态 |
| FilledQuantity | int64 | 成交数量 |
| AvgFillPrice | float64 | 成交均价 |
| TimeInForce | string | 有效期 |
| OutsideRth | bool | 是否允许盘前盘后 |
示例
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
}
]获取已撤销订单
功能说明
查询已撤销订单。 方法签名
func (c *TradeClient) InactiveOrders(req model.OrdersRequest) ([]model.Order, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.OrdersRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Market | string | 否 | 空值省略 | 无;可选值:ALL, US, HK, CN, SG |
SecType | string | 否 | 空值省略 | 无;可选值:ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
StartDate | int64 | 否 | 空值省略 | 无;ms 时间戳 |
States | []string | 否 | 空值省略 | 无;OrderStatus 值列表 |
SortBy | string | 否 | 空值省略 | 无;可选值:LATEST_CREATED, LATEST_STATUS_UPDATED |
ShowCharges | *bool | 否 | 空值省略 | 无;Python 用 is not None 判断 |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.Order, error)。关键字段来自 model.Order:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| ID | int64 | 订单 ID |
| OrderId | int64 | 订单号 |
| Action | string | 交易方向 (BUY/SELL) |
| OrderType | string | 订单类型 |
| TotalQuantity | int64 | 委托数量 |
| LimitPrice | float64 | 限价 |
| AuxPrice | float64 | 辅助价格(止损价) |
| TrailingPercent | float64 | 跟踪止损百分比 |
| Status | string | 订单状态 |
| FilledQuantity | int64 | 成交数量 |
| AvgFillPrice | float64 | 成交均价 |
| TimeInForce | string | 有效期 |
| OutsideRth | bool | 是否允许盘前盘后 |
示例
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
}
]获取已成交订单
功能说明
查询已成交订单。 方法签名
func (c *TradeClient) FilledOrders(req model.OrdersRequest) ([]model.Order, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.OrdersRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
Market | string | 否 | 空值省略 | 无;可选值:ALL, US, HK, CN, SG |
SecType | string | 否 | 空值省略 | 无;可选值:ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
SegType | string | 否 | 空值省略 | 无;可选值:ALL, SEC, FUT, FUND |
StartDate | int64 | 否 | 空值省略 | 无;ms 时间戳 |
States | []string | 否 | 空值省略 | 无;OrderStatus 值列表 |
SortBy | string | 否 | 空值省略 | 无;可选值:LATEST_CREATED, LATEST_STATUS_UPDATED |
ShowCharges | *bool | 否 | 空值省略 | 无;Python 用 is not None 判断 |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.Order, error)。关键字段来自 model.Order:
| 字段 | 类型 | 说明 |
|---|---|---|
| Account | string | 账户 ID |
| ID | int64 | 订单 ID |
| OrderId | int64 | 订单号 |
| Action | string | 交易方向 (BUY/SELL) |
| OrderType | string | 订单类型 |
| TotalQuantity | int64 | 委托数量 |
| LimitPrice | float64 | 限价 |
| AuxPrice | float64 | 辅助价格(止损价) |
| TrailingPercent | float64 | 跟踪止损百分比 |
| Status | string | 订单状态 |
| FilledQuantity | int64 | 成交数量 |
| AvgFillPrice | float64 | 成交均价 |
| TimeInForce | string | 有效期 |
| OutsideRth | bool | 是否允许盘前盘后 |
示例
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
}
]获取成交记录
功能说明
查询订单成交明细。 所有过滤字段(Symbol / SecType / OrderId / 时间范围等)均可选。 方法签名
func (c *TradeClient) OrderTransactions(req model.OrderTransactionsRequest) ([]model.Transaction, error)需要配置中可访问的交易账户。机构账户可通过 SecretKey 鉴权。
参数
model.OrderTransactionsRequest
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
SecType | string | 否 | 空值省略 | 无;可选值:ALL, STK, OPT, WAR, IOPT, FUT, FOP, CASH, MLEG, FUND |
StartDate | int64 | 否 | 空值省略 | 无;ms 时间戳 |
SinceDate | string | 否 | 空值省略 | 无;yyyyMMdd |
Right | string | 否 | 空值省略 | 无;可选值:PUT, CALL (option side); br, nr when used as quote adjustment |
Lang | string | 否 | 空值省略 | 无;可选值:zh_CN, zh_TW, en_US |
返回
([]model.Transaction, error)。关键字段来自 model.Transaction:
| 字段 | 类型 | 说明 |
|---|---|---|
| ID | int64 | 成交记录 ID |
| OrderID | int64 | 订单 ID |
| AccountId | int64 | 账户数字 ID |
| Account | string | 账户 ID |
| Symbol | string | 股票代码 |
| SecType | string | 证券类型 |
| Market | string | 市场 |
| Currency | string | 币种 |
| Identifier | string | 标识符 |
| Action | string | 交易方向 (BUY/SELL) |
| Price | float64 | 委托价格 |
| FilledPrice | float64 | 成交价格 |
| Quantity | int64 | 委托数量 |
| FilledQuantity | int64 | 成交数量 |
示例
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 8 days ago
