获取订单信息

大约 9 分钟

获取订单

对应的请求类:TigerRequest(TradeApiService.ORDERS)

说明

获取订单

参数

获取指定单个订单

参数类型是否必填描述
accountstringYes用户授权账户:572386
idintYes下单成功后返回的订单号
secret_keystringNo机构用户专用,交易员密钥
show_chargesboolNo是否返回订单的费用明细

获取订单列表

参数类型是否必填描述
accountstringYes用户授权账户:572386
seg_typeSegmentTypeNo账户划分类型, 可选值有: SegmentType.SEC 代表证券; SegmentType.FUT 代表期货; SegmentType.FUND 代表基金, SegmentType.ALL:代表证券+期货+基金。 默认为SegmentType.SEC
sec_typestringNoALL/STK/OPT/FUT/FOP/CASH 默认 ALL
marketstringNoALL/US/HK/CN 默认 ALL
symbolstringNo股票代码
expirystringNo过期日(期权、窝轮、牛熊证专属)
strikestringNo行权价格(期权、窝轮、牛熊证专属)
rightstringNo期权方向 PUT/CALL(期权、窝轮、牛熊证专属)
start_datestringNo订单下单时间的起始时间(当 sort_by=LATEST_STATUS_UPDATED 时,按订单状态更新时间进行过滤),格式为'2018-05-01' 或者 "2018-05-01 10:00:00"(默认东八区,可指定时区),闭区间
end_datestringNo订单下单时间的截止时间(当 sort_by=LATEST_STATUS_UPDATED 时,按订单状态更新时间进行过滤),格式为'2018-05-15' 或者 "2018-05-01 10:00:00"(默认东八区,可指定时区),开区间
statesarrayNo】订单状态, 默认查有效订单,参考:订单状态
isBriefbooleanNo】是否返回精简的订单信息
limitintegerNo默认:100, 最大限制: 300
sort_byOrderSortByNo】排序和起止时间作用字段,LATEST_CREATED/LATEST_STATUS_UPDATED; 默认值:LATEST_CREATED
secret_keystringNo机构用户专用,交易员密钥
langstringNo语言支持(枚举类Language): zh_CN,zh_TW,en_US, 默认: en_US
page_tokenstringNo分页查询token,使用pageToken分页拉取数据时其他查询条件不能变

返回

按id查询返回TigerOpenAPI.Trade.Response.SingleOrderResponse, 返回数据可通过SingleOrderResponse.Data属性访问,返回TradeOrder对象。 不传ID查询返回TigerOpenAPI.Trade.Response.OrderBatchResponse, 返回数据可通过OrderBatchResponse.Data属性访问,返回OrderBatchItem对象, 其数据结构如下:

字段类型说明
nextPageTokenstring查询下一页用的token
itemsList<TradeOrder>订单数组,字段参考下面说明

其中订单数据items属性如下:

名称示例说明
id27363676799501312订单全局唯一ID,下单成功后返回
orderId830154374用户本地的自增订单ID,非全局唯一
externalId830154374扩展ID, API下单为orderId的值
parentId0父订单的订单ID
account572386交易账户
actionBUY交易方向,BUY or SELL
orderTypeLMT订单类型
limitPrice108.62限价单价格
auxPrice0.0止损单辅助价格-跟踪额
trailingPercent5跟踪止损单的跟踪百分比
totalQuantity50下单数量
totalQuantityScale0下单数量的偏移量,默认为0。碎股单的totalQuantity 和 totalQuantityScale 结合起来代表真实下单数量,如 totalQuantity=111 totalQuantityScale=2,那么真实 quantity=111*10^(-2)=1.11
timeInForceDAYDAY/GTC/GTD
expireTime1669000183188timeInForce为GTD时才有值
outsideRthtrue是否允许盘前、盘后
filledQuantity50成交数量
filledQuantityScale0成交数量偏移量,如 filledQuantity=11123, filledQuantityScale=2,那么实际 filledQuantity=11123*10^(-2)=111.23
totalCashAmount100下单总金额,按股数下单时为null
filledCashAmount100已成交金额,按股数下单时为null
refundCashAmount0退回金额,等于下单总金额-已成交金额。按股数下单或订单未终结时为null
avgFillPrice108.62包含佣金的平均成交价
remarkOrder is expired错误描述
statusFilled订单状态,参考:订单状态
attrDescExercise订单描述信息,参考:订单描述
commission0.99包含佣金、印花税、证监会费等系列费用
commissionCurrencyUSD佣金币种
realizedPnl0.0已实现盈亏
openTime1657667486000下单时间
updateTime1657670428000最后更新时间
latestTime1657670428000状态更新时间
symbolBABA股票代码
currencyUSD货币
marketUS交易市场
multiplier0.0每手股数
secTypeSTK交易类型
userMarkmy_strategy_1下单时备注参数,会按照设置值返回,长度不能超过200
canModifyfalse是否可修改订单
canCancelfalse是否可撤销订单
liquidationfalse是否强制平仓
isOpentrue是否为开仓
replaceStatusNONE订单改单状态
cancelStatusNONE订单撤单状态
charges订单佣金等费用明细(仅限单个订单查询)。详细说明见下方Charge描述。
commissionDiscountAmount0免佣金额(仅限单个订单查询)
orderDiscountAmount0订单扣减金额
orderDiscount0订单抵扣状态(仅限单个订单查询)。1:待抵扣;2:已抵扣;0:默认值

Charge说明:

名称示例说明
categoryTIGER费用类别:TIGER/THIRD_PARTY
categoryDescTiger Charge费用类别描述:Tiger Charge; Third Parties
total18当前类别费用总额
details费用明细。详细说明见下方ChargeDetails描述。

ChargeDetails说明:

名称示例说明
typeSETTLEMENT_FEE费用类型:SETTLEMENT_FEE/STAMP_DUTY/TRANSACTION_LEVY/EXCHANGE_FEE/FRC_TRANSACTION_LEVY
typeDescSettlement Fee费用类型描述:Settlement Fee(结算费); Stamp Duty(印花税); Transaction Levy(交易征费); Exchange Fee(交易所费用); AFRC Transaction Levy(会计及才会局交易征费)
originalAmount4费用金额
afterDiscountAmount4抵扣后的费用

示例

获取单个订单

  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)

说明

获取订单的成交记录

参数

参数类型是否必填描述
accountStringYes账户,目前仅支持综合账户
order_idlongYes下单成功后返回的全局订单ID,非本地订单ID。 order_id 和 symbol其中一个必传。 使用orderId后,symbol参数不生效
symbolStringYes股票代码。order_id 和 symbol其中一个必传。
sec_typeStringNo, 指定symbol查询时必传STK:股票/FUT:期货/OPT:期权/WAR:窝轮/IOPT:牛熊证, 未指定查全部。
expiryStringNo, sect_type为OPT/WAR/IOPT类型时必传到期日
rightStringNo, sect_type为OPT/WAR/IOPT类型时必传CALL/PUT
start_datelongNo起始时间(yyyy-MM-dd HH-mm-ss格式需要转换为毫秒的时间戳)
end_datelongNo截止时间(yyyy-MM-dd HH-mm-ss格式需要转换为毫秒的时间戳)
limitintNo返回数据数量限制,默认20, 最大100
secretKeyStringNo机构用户专用,交易员密钥

返回

字段示例说明
id24653027221308416成交记录ID
accountId402190账号
orderId24637316162520064订单ID
secTypeSTK证券类型
symbolCIIsymbol
currencyUSD币种
marketUS市场
actionBUY动作, BUY/SELL
filledQuantity100成交数量
filledPrice21成交价
filledAmount2167.0成交金额
transactedAt2021-11-15 22:34:30成交时间
transactionTime1636986870000成交时间戳

示例

// 按照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="
}
上次编辑于: