获取订单信息
大约 9 分钟
获取订单
对应的请求类:TigerRequest(TradeApiService.ORDERS)
说明
获取订单
参数
获取指定单个订单
参数 | 类型 | 是否必填 | 描述 |
---|---|---|---|
account | string | Yes | 用户授权账户:572386 |
id | int | Yes | 下单成功后返回的订单号 |
secret_key | string | No | 机构用户专用,交易员密钥 |
show_charges | bool | No | 是否返回订单的费用明细 |
获取订单列表
参数 | 类型 | 是否必填 | 描述 |
---|---|---|---|
account | string | Yes | 用户授权账户:572386 |
seg_type | SegmentType | No | 账户划分类型, 可选值有: SegmentType.SEC 代表证券; SegmentType.FUT 代表期货; SegmentType.FUND 代表基金, SegmentType.ALL:代表证券+期货+基金。 默认为SegmentType.SEC |
sec_type | string | No | ALL/STK/OPT/FUT/FOP/CASH 默认 ALL |
market | string | No | ALL/US/HK/CN 默认 ALL |
symbol | string | No | 股票代码 |
expiry | string | No | 过期日(期权、窝轮、牛熊证专属) |
strike | string | No | 行权价格(期权、窝轮、牛熊证专属) |
right | string | No | 期权方向 PUT/CALL(期权、窝轮、牛熊证专属) |
start_date | string | No | 订单下单时间的起始时间(当 sort_by=LATEST_STATUS_UPDATED 时,按订单状态更新时间进行过滤),格式为'2018-05-01' 或者 "2018-05-01 10:00:00"(默认东八区,可指定时区),闭区间 |
end_date | string | No | 订单下单时间的截止时间(当 sort_by=LATEST_STATUS_UPDATED 时,按订单状态更新时间进行过滤),格式为'2018-05-15' 或者 "2018-05-01 10:00:00"(默认东八区,可指定时区),开区间 |
states | array | No | 【】订单状态, 默认查有效订单,参考:订单状态 |
isBrief | boolean | No | 【】是否返回精简的订单信息 |
limit | integer | No | 默认:100, 最大限制: 300 |
sort_by | OrderSortBy | No | 【】排序和起止时间作用字段,LATEST_CREATED/LATEST_STATUS_UPDATED; 默认值:LATEST_CREATED |
secret_key | string | No | 机构用户专用,交易员密钥 |
lang | string | No | 语言支持(枚举类Language): zh_CN,zh_TW,en_US, 默认: en_US |
page_token | string | No | 分页查询token,使用pageToken分页拉取数据时其他查询条件不能变 |
返回
按id查询返回TigerOpenAPI.Trade.Response.SingleOrderResponse
, 返回数据可通过SingleOrderResponse.Data
属性访问,返回TradeOrder
对象。 不传ID查询返回TigerOpenAPI.Trade.Response.OrderBatchResponse
, 返回数据可通过OrderBatchResponse.Data
属性访问,返回OrderBatchItem
对象, 其数据结构如下:
字段 | 类型 | 说明 |
---|---|---|
nextPageToken | string | 查询下一页用的token |
items | List<TradeOrder> | 订单数组,字段参考下面说明 |
其中订单数据items属性如下:
名称 | 示例 | 说明 |
---|---|---|
id | 27363676799501312 | 订单全局唯一ID,下单成功后返回 |
orderId | 830154374 | 用户本地的自增订单ID,非全局唯一 |
externalId | 830154374 | 扩展ID, API下单为orderId的值 |
parentId | 0 | 父订单的订单ID |
account | 572386 | 交易账户 |
action | BUY | 交易方向,BUY or SELL |
orderType | LMT | 订单类型 |
limitPrice | 108.62 | 限价单价格 |
auxPrice | 0.0 | 止损单辅助价格-跟踪额 |
trailingPercent | 5 | 跟踪止损单的跟踪百分比 |
totalQuantity | 50 | 下单数量 |
totalQuantityScale | 0 | 下单数量的偏移量,默认为0。碎股单的totalQuantity 和 totalQuantityScale 结合起来代表真实下单数量,如 totalQuantity=111 totalQuantityScale=2,那么真实 quantity=111*10^(-2)=1.11 |
timeInForce | DAY | DAY/GTC/GTD |
expireTime | 1669000183188 | timeInForce为GTD时才有值 |
outsideRth | true | 是否允许盘前、盘后 |
filledQuantity | 50 | 成交数量 |
filledQuantityScale | 0 | 成交数量偏移量,如 filledQuantity=11123, filledQuantityScale=2,那么实际 filledQuantity=11123*10^(-2)=111.23 |
totalCashAmount | 100 | 下单总金额,按股数下单时为null |
filledCashAmount | 100 | 已成交金额,按股数下单时为null |
refundCashAmount | 0 | 退回金额,等于下单总金额-已成交金额。按股数下单或订单未终结时为null |
avgFillPrice | 108.62 | 包含佣金的平均成交价 |
remark | Order is expired | 错误描述 |
status | Filled | 订单状态,参考:订单状态 |
attrDesc | Exercise | 订单描述信息,参考:订单描述 |
commission | 0.99 | 包含佣金、印花税、证监会费等系列费用 |
commissionCurrency | USD | 佣金币种 |
realizedPnl | 0.0 | 已实现盈亏 |
openTime | 1657667486000 | 下单时间 |
updateTime | 1657670428000 | 最后更新时间 |
latestTime | 1657670428000 | 状态更新时间 |
symbol | BABA | 股票代码 |
currency | USD | 货币 |
market | US | 交易市场 |
multiplier | 0.0 | 每手股数 |
secType | STK | 交易类型 |
userMark | my_strategy_1 | 下单时备注参数,会按照设置值返回,长度不能超过200 |
canModify | false | 是否可修改订单 |
canCancel | false | 是否可撤销订单 |
liquidation | false | 是否强制平仓 |
isOpen | true | 是否为开仓 |
replaceStatus | NONE | 订单改单状态 |
cancelStatus | NONE | 订单撤单状态 |
charges | 订单佣金等费用明细(仅限单个订单查询)。详细说明见下方Charge 描述。 | |
commissionDiscountAmount | 0 | 免佣金额(仅限单个订单查询) |
orderDiscountAmount | 0 | 订单扣减金额 |
orderDiscount | 0 | 订单抵扣状态(仅限单个订单查询)。1:待抵扣;2:已抵扣;0:默认值 |
Charge
说明:
名称 | 示例 | 说明 |
---|---|---|
category | TIGER | 费用类别:TIGER/THIRD_PARTY |
categoryDesc | Tiger Charge | 费用类别描述:Tiger Charge; Third Parties |
total | 18 | 当前类别费用总额 |
details | 费用明细。详细说明见下方ChargeDetails 描述。 |
ChargeDetails
说明:
名称 | 示例 | 说明 |
---|---|---|
type | SETTLEMENT_FEE | 费用类型:SETTLEMENT_FEE/STAMP_DUTY/TRANSACTION_LEVY/EXCHANGE_FEE/FRC_TRANSACTION_LEVY |
typeDesc | Settlement Fee | 费用类型描述:Settlement Fee(结算费); Stamp Duty(印花税); Transaction Levy(交易征费); Exchange Fee(交易所费用); AFRC Transaction Levy(会计及才会局交易征费) |
originalAmount | 4 | 费用金额 |
afterDiscountAmount | 4 | 抵扣后的费用 |
示例
获取单个订单
static async Task<SingleOrderResponse?> QueryOrderByIdAsync(TradeClient tradeClient)
{
TigerRequest<SingleOrderResponse> request = new TigerRequest<SingleOrderResponse>()
{
ApiMethodName = TradeApiService.ORDERS,
ModelValue = new QueryOrderModel()
{
Account = "572386",// tradeClient.GetDefaultAccount,
IsShowCharges = true,
Id = 29360305075913728
}
};
return await tradeClient.ExecuteAsync(request);
}
获取订单列表
static async Task<OrderBatchResponse?> QueryOrderAsync(TradeClient tradeClient)
{
TigerRequest<OrderBatchResponse> request = new TigerRequest<OrderBatchResponse>()
{
ApiMethodName = TradeApiService.ORDERS,
ModelValue = new QueryOrderModel()
{
Account = "20200821144442583",// tradeClient.GetDefaultAccount,
StartDate = DateUtil.ConvertTimestamp("2022-12-20 00:00:00", tradeClient.GetConfigTimeZone),
EndDate = DateUtil.CurrentTimeMillis(),
SortBy = OrderSortBy.LATEST_CREATED,
Limit = 5
}
};
return await tradeClient.ExecuteAsync(request);
}
返回示例
单个订单
{
"code": 0,
"message": "success",
"timestamp": 1730979366565,
"data": {
"symbol": "01177",
"market": "HK",
"secType": "STK",
"currency": "HKD",
"identifier": "01177",
"id": 36810407788938240,
"externalId": "710344498739626686",
"orderId": 0,
"account": "572386",
"action": "SELL",
"orderType": "LMT",
"limitPrice": 3.54,
"totalQuantity": 6000,
"totalQuantityScale": 0,
"filledQuantity": 6000,
"filledQuantityScale": 0,
"filledCashAmount": 21240,
"avgFillPrice": 3.54,
"timeInForce": "GTC",
"outsideRth": false,
"commission": 45.82,
"gst": 0,
"realizedPnl": -6388.735,
"remark": "",
"liquidation": false,
"openTime": 1729740323000,
"updateTime": 1730045103000,
"latestTime": 1729740324000,
"name": "SINO BIOPHARM",
"attrDesc": "",
"userMark": "",
"attrList": [
"SETTLED"
],
"charges": [
{
"category": "TIGER",
"categoryDesc": "Tiger Charge",
"total": 18,
"details": [
{
"type": "USER_COMMISSION",
"typeDesc": "Commission",
"originalAmount": 18,
"afterDiscountAmount": 18
}
]
},
{
"category": "THIRD_PARTY",
"categoryDesc": "Third Parties",
"total": 27.82,
"details": [
{
"type": "SETTLEMENT_FEE",
"typeDesc": "Settlement Fee",
"originalAmount": 4,
"afterDiscountAmount": 4
},
{
"type": "STAMP_DUTY",
"typeDesc": "Stamp Duty",
"originalAmount": 22,
"afterDiscountAmount": 22
},
{
"type": "TRANSACTION_LEVY",
"typeDesc": "Transaction Levy",
"originalAmount": 0.58,
"afterDiscountAmount": 0.58
},
{
"type": "EXCHANGE_FEE",
"typeDesc": "Exchange Fee",
"originalAmount": 1.2,
"afterDiscountAmount": 1.2
},
{
"type": "FRC_TRANSACTION_LEVY",
"typeDesc": "AFRC Transaction Levy",
"originalAmount": 0.04,
"afterDiscountAmount": 0.04
}
]
}
],
"algoStrategy": "LMT",
"status": "Filled",
"source": "android",
"discount": 0,
"replaceStatus": "NONE",
"cancelStatus": "NONE",
"canModify": false,
"canCancel": false,
"isOpen": false,
"orderDiscount": 0,
"tradingSessionType": "RTH"
},
"sign": "qTgxt2K5t10LDbmAc+7onHOMEMORKO/qfWJw05O+YIM/mdohUhO4FR+nbe7COIhoJyTwuLGcFSKEowWRjWDwA+cMt/bKx3mj+6A754kaxmtjY4b76tYmjzuH33JmkiIcigeiDYQU1qjziRwK5EKAJRhTXIQefQIh2NzyVCXZjyk="
}
订单列表
{
"data":{
"nextPageToken":"b3JkZXJzfDE2NzE0NjU2MDAwMDB8MTY3MjkyMDk2MTU5MXwyOTM2MDM2Nzk4MzY1Njk2MA==",
"items":[
{
"symbol":"01810",
"market":"HK",
"secType":"STK",
"currency":"HKD",
"identifier":"01810",
"id":29360396894077952,
"orderId":1466,
"parentId":29360396893815808,
"account":"20200821144442583",
"action":"SELL",
"orderType":"TRAIL",
"trailingPercent":10,
"totalQuantity":200,
"timeInForce":"DAY",
"remark":"The primary order has expired",
"openTime":1672901251000,
"updateTime":1672901251000,
"latestTime":1672901252000,
"name":"XIAOMI-W",
"attrDesc":"",
"userMark":"test-attach-stoplosstrail",
"algoStrategy":"TRAIL",
"status":"Invalid"
},
{
"symbol":"01810",
"market":"HK",
"secType":"STK",
"currency":"HKD",
"identifier":"01810",
"id":29360396893815808,
"orderId":1465,
"account":"20200821144442583",
"action":"BUY",
"orderType":"LMT",
"limitPrice":11,
"totalQuantity":200,
"timeInForce":"DAY",
"outsideRth":true,
"remark":"The current order is cross-trading with your pending sell order of the same holders account",
"openTime":1672901251000,
"updateTime":1672901251000,
"latestTime":1672901252000,
"name":"XIAOMI-W",
"attrDesc":"",
"userMark":"test-attach-stoplosstrail",
"algoStrategy":"LMT",
"status":"Invalid"
},
{
"symbol":"01810",
"market":"HK",
"secType":"STK",
"currency":"HKD",
"identifier":"01810",
"id":29360379940570112,
"orderId":1464,
"parentId":29360379940044800,
"account":"20200821144442583",
"action":"SELL",
"orderType":"STP",
"auxPrice":10,
"totalQuantity":200,
"timeInForce":"DAY",
"remark":"The primary order has expired",
"openTime":1672901122000,
"updateTime":1672901122000,
"latestTime":1672901122000,
"name":"XIAOMI-W",
"attrDesc":"",
"userMark":"test001",
"algoStrategy":"STP",
"status":"Invalid"
},
{
"symbol":"01810",
"market":"HK",
"secType":"STK",
"currency":"HKD",
"identifier":"01810",
"id":29360379940044800,
"orderId":1463,
"account":"20200821144442583",
"action":"BUY",
"orderType":"LMT",
"limitPrice":11,
"totalQuantity":200,
"timeInForce":"DAY",
"outsideRth":true,
"remark":"The current order is cross-trading with your pending sell order of the same holders account",
"openTime":1672901122000,
"updateTime":1672901122000,
"latestTime":1672901122000,
"name":"XIAOMI-W",
"attrDesc":"",
"userMark":"test001",
"algoStrategy":"LMT",
"status":"Invalid"
},
{
"symbol":"01810",
"market":"HK",
"secType":"STK",
"currency":"HKD",
"identifier":"01810",
"id":29360367983656960,
"orderId":1462,
"parentId":29360367983789056,
"account":"20200821144442583",
"action":"SELL",
"orderType":"LMT",
"limitPrice":13,
"totalQuantity":200,
"timeInForce":"DAY",
"outsideRth":true,
"remark":"The primary order has expired",
"openTime":1672901030000,
"updateTime":1672901030000,
"latestTime":1672901031000,
"name":"XIAOMI-W",
"attrDesc":"",
"userMark":"",
"algoStrategy":"LMT",
"status":"Invalid"
}
]
},
"message":"success",
"timestamp":1672920984579,
"sign":"iHos8Cj27VV64rMsmHweSOk8n6dAPgGWoRaGVqzA0+MLiNZv1MlBLfhg+UdhGyL4znuALK+KtRZ8TI0LhrcCHsZWeqVIajYN6Vyvx7vn9lshUmzhZ8f+a7DLrk3lkqLay8HnMM+j6BuRSaDaUWfsIHeT/1mYM586nhskIrZnFVU="
}
获取已成交订单列表
对应的请求类:TigerRequest(TradeApiService.FILLED_ORDERS)
说明
获取状态为成交的订单列表
参数
参考获取订单,其中start_date和end_date为必传参数。
示例
static async Task<OrderBatchResponse?> QueryFilledOrderAsync(TradeClient tradeClient)
{
TigerRequest<OrderBatchResponse> request = new TigerRequest<OrderBatchResponse>()
{
ApiMethodName = TradeApiService.FILLED_ORDERS,
ModelValue = new QueryOrderModel()
{
Account = "20200821144442583",// tradeClient.GetDefaultAccount,
StartDate = DateUtil.ConvertTimestamp("2022-12-20 00:00:00", tradeClient.GetConfigTimeZone),
EndDate = DateUtil.CurrentTimeMillis(),
SortBy = OrderSortBy.LATEST_CREATED,
Limit = 3
}
};
return await tradeClient.ExecuteAsync(request);
}
返回
参考获取订单
获取待成交订单列表
对应的请求类:TigerRequest(TradeApiService.ACTIVE_ORDERS)
参数
参考获取订单,可能包含部分成交的订单
示例
static async Task<OrderBatchResponse?> QueryActiveOrderAsync(TradeClient tradeClient)
{
TigerRequest<OrderBatchResponse> request = new TigerRequest<OrderBatchResponse>()
{
ApiMethodName = TradeApiService.ACTIVE_ORDERS,
ModelValue = new QueryOrderModel()
{
Account = "20200821144442583",// tradeClient.GetDefaultAccount,
StartDate = DateUtil.ConvertTimestamp("2022-12-20 00:00:00", tradeClient.GetConfigTimeZone),
EndDate = DateUtil.CurrentTimeMillis(),
SortBy = OrderSortBy.LATEST_CREATED,
Limit = 3
}
};
return await tradeClient.ExecuteAsync(request);
}
返回
参考获取订单
获取已撤销订单列表
对应的请求类:TigerRequest(TradeApiService.INACTIVE_ORDERS)
参数
参考获取订单
示例
static async Task<OrderBatchResponse?> QueryInactiveOrderAsync(TradeClient tradeClient)
{
TigerRequest<OrderBatchResponse> request = new TigerRequest<OrderBatchResponse>()
{
ApiMethodName = TradeApiService.INACTIVE_ORDERS,
ModelValue = new QueryOrderModel()
{
Account = tradeClient.GetDefaultAccount, // "20200821144442583",
StartDate = DateUtil.ConvertTimestamp("2022-12-20 00:00:00", tradeClient.GetConfigTimeZone),
EndDate = DateUtil.CurrentTimeMillis(),
SecType = SecType.STK,
SortBy = OrderSortBy.LATEST_CREATED,
Limit = 3
}
};
return await tradeClient.ExecuteAsync(request);
}
返回
参考获取订单
获取成交记录
对应的请求类:TigerRequest(TradeApiService.ORDER_TRANSACTIONS)
说明
获取订单的成交记录
参数
参数 | 类型 | 是否必填 | 描述 |
---|---|---|---|
account | String | Yes | 账户,目前仅支持综合账户 |
order_id | long | Yes | 下单成功后返回的全局订单ID,非本地订单ID。 order_id 和 symbol其中一个必传。 使用orderId后,symbol参数不生效 |
symbol | String | Yes | 股票代码。order_id 和 symbol其中一个必传。 |
sec_type | String | No, 指定symbol查询时必传 | STK:股票/FUT:期货/OPT:期权/WAR:窝轮/IOPT:牛熊证, 未指定查全部。 |
expiry | String | No, sect_type为OPT/WAR/IOPT类型时必传 | 到期日 |
right | String | No, sect_type为OPT/WAR/IOPT类型时必传 | CALL/PUT |
start_date | long | No | 起始时间(yyyy-MM-dd HH-mm-ss格式需要转换为毫秒的时间戳) |
end_date | long | No | 截止时间(yyyy-MM-dd HH-mm-ss格式需要转换为毫秒的时间戳) |
limit | int | No | 返回数据数量限制,默认20, 最大100 |
secretKey | String | No | 机构用户专用,交易员密钥 |
返回
字段 | 示例 | 说明 |
---|---|---|
id | 24653027221308416 | 成交记录ID |
accountId | 402190 | 账号 |
orderId | 24637316162520064 | 订单ID |
secType | STK | 证券类型 |
symbol | CII | symbol |
currency | USD | 币种 |
market | US | 市场 |
action | BUY | 动作, BUY/SELL |
filledQuantity | 100 | 成交数量 |
filledPrice | 21 | 成交价 |
filledAmount | 2167.0 | 成交金额 |
transactedAt | 2021-11-15 22:34:30 | 成交时间 |
transactionTime | 1636986870000 | 成交时间戳 |
示例
// 按照symbol查询
static async Task<OrderTransactionsResponse?> QueryOrderTransactionsAsync(TradeClient tradeClient)
{
TigerRequest<OrderTransactionsResponse> request = new TigerRequest<OrderTransactionsResponse>()
{
ApiMethodName = TradeApiService.ORDER_TRANSACTIONS,
ModelValue = new OrderTransactionsModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
Symbol = "01810",
StartDate = DateUtil.ConvertTimestamp("2022-11-01 00:00:00", tradeClient.GetConfigTimeZone),
EndDate = DateUtil.CurrentTimeMillis(),
Limit = 20
}
};
return await tradeClient.ExecuteAsync(request);
}
// 按照orderId查询
static async Task<OrderTransactionsResponse?> QueryOrderTransactionsAsync(TradeClient tradeClient)
{
TigerRequest<OrderTransactionsResponse> request = new TigerRequest<OrderTransactionsResponse>()
{
ApiMethodName = TradeApiService.ORDER_TRANSACTIONS,
ModelValue = new OrderTransactionsModel()
{
Account = tradeClient.GetDefaultAccount,// "20200821144442583",
OrderId = 29358459894498304
}
};
return await tradeClient.ExecuteAsync(request);
}
返回示例
{
"data":{
"items":[
{
"id":28805813759117312,
"orderId":28805688059365376,
"accountId":"572386",
"secType":"STK",
"market":"HK",
"currency":"HKD",
"symbol":"01810",
"right":"PUT",
"action":"SELL",
"filledQuantity":200,
"filledPrice":10.32,
"filledAmount":2064,
"transactedAt":"2022-11-17 15:28:37",
"transactionTime":1668670117000
}
]
},
"code":0,
"message":"success",
"timestamp":1672977133300,
"sign":"mfQ7wBB785UReYysC2TcD+1Wo6+sz8l5NzQKofvxD5uSNdAs+Jl/qaiYSwEobQBE1gvJ3bH1JPynlN2DyEG3E6WfD1Lbsqdy4XDcO2UKWIbUpbioW0SLT0WTT/Wr9hX6/uH1xgg3FitL40IX7sR2e40+fa1AmyTaRZkRrGIENk0="
}