exchange/okex/docs/trade.json
2024-06-26 00:59:56 +08:00

2016 lines
98 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"openapi": "3.0.1",
"info": {
"title": "REST API",
"version": "1.0",
"description": "# 使用说明 \n <b>该功能接口用户需先登陆,接口只会请求模拟环境</b><br><br>*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。<br>"
},
"tags": [
{
"name": "Trade",
"description": "交易"
}
],
"paths": {
"/api/v5/trade/order": {
"post": {
"tags": [
"Trade"
],
"summary": "下单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId",
"tdMode",
"side",
"ordType",
"sz"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"tdMode": {
"type": "string",
"description": "必填<br>交易模式<br>保证金模式:`isolated`:逐仓 `cross`<br>全仓非保证金模式:`cash`:非保证金"
},
"side": {
"type": "string",
"description": "必填<br>订单方向。买:`buy` 卖:`sell`"
},
"ordType": {
"type": "string",
"description": "必填<br>订单类型。<br>市价单:`market`<br>限价单:`limit`<br>只做maker单`post_only`<br>全部成交或立即取消:`fok`<br>立即成交并取消剩余:`ioc`<br>市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)"
},
"sz": {
"type": "string",
"description": "必填<br>委托数量"
},
"px": {
"type": "string",
"description": "可选<br>委托价格<br>仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单"
},
"posSide": {
"type": "string",
"description": "可选<br>持仓方向<br>在双向持仓模式下必填,且仅可选择 `long` 或 `short`"
},
"ccy": {
"type": "string",
"description": "非必填<br>保证金币种USDT<br>仅适用于单币种保证金模式下的全仓杠杆订单"
},
"clOrdId": {
"type": "string",
"description": "非必填<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
},
"tag": {
"type": "string",
"description": "非必填<br>订单标签<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度在1-8位之间。"
},
"reduceOnly": {
"type": "boolean",
"description": "非必填<br>是否只减仓,`true` 或 `false`,默认`false`<br>仅适用于币币杠杆订单"
},
"tgtCcy": {
"type": "string",
"description": "非必填<br>市价单委托数量的类型<br>交易货币:`base_ccy`<br>计价货币:`quote_ccy`<br>仅适用于币币订单"
}
}
},
"examples": {
"1": {
"summary": "币币限价下单",
"value": {
"instId": "BTC-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "limit",
"px": "1000",
"sz": "0.01"
}
},
"2": {
"summary": "币币市价下单",
"value": {
"instId": "BTC-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "market",
"sz": "100"
}
},
"3": {
"summary": "高级限价post_only委托",
"value": {
"instId": "BTC-USDT",
"ordType": "post_only",
"px": "1000",
"side": "buy",
"sz": "1",
"tdMode": "cash"
}
},
"4": {
"summary": "高级限价fok委托",
"value": {
"instId": "BTC-USDT",
"ordType": "fok",
"px": "1000",
"side": "buy",
"sz": "1",
"tdMode": "cash"
}
},
"5": {
"summary": "高级限价ioc委托",
"value": {
"instId": "BTC-USDT",
"ordType": "ioc",
"px": "1000",
"side": "buy",
"sz": "1",
"tdMode": "cash"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "oktswap6",
"ordId": "12345689",
"tag": "",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
},
"get": {
"tags": [
"Trade"
],
"summary": "获取订单信息",
"parameters": [
{
"name": "instId",
"in": "query",
"description": "产品ID如 `BTC-USDT`",
"required": true,
"schema": {
"type": "string"
},
"example": "BTC-USDT"
},
{
"name": "ordId",
"in": "query",
"description": "订单IDordId和clOrdId必须传一个若传两个以ordId为主",
"schema": {
"type": "string"
}
},
{
"name": "clOrdId",
"in": "query",
"description": "用户自定义ID",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"ccy": "",
"ordId": "123445",
"clOrdId": "b1",
"tag": "",
"px": "999",
"sz": "3",
"pnl": "5",
"ordType": "limit",
"side": "buy",
"posSide": "long",
"tdMode": "isolated",
"accFillSz": "0",
"fillPx": "0",
"tradeId": "0",
"fillSz": "0",
"fillTime": "0",
"state": "live",
"avgPx": "0",
"lever": "20",
"tpTriggerPx": "",
"tpOrdPx": "",
"slTriggerPx": "",
"slOrdPx": "",
"feeCcy": "",
"fee": "",
"rebateCcy": "",
"rebate": "",
"tgtCcy": "",
"category": "",
"uTime": "1597026383085",
"cTime": "1597026383085"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/batch-orders": {
"post": {
"tags": [
"Trade"
],
"summary": "批量下单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId",
"tdMode",
"side",
"ordType",
"sz"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"tdMode": {
"type": "string",
"description": "必填<br>交易模式<br>保证金模式:`isolated`:逐仓 `cross`<br>全仓非保证金模式:`cash`:非保证金"
},
"side": {
"type": "string",
"description": "必填<br>订单方向。买:`buy` 卖:`sell`"
},
"ordType": {
"type": "string",
"description": "必填<br>订单类型。<br>市价单:`market`<br>限价单:`limit`<br>只做maker单`post_only`<br>全部成交或立即取消:`fok`<br>立即成交并取消剩余:`ioc`<br>市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)"
},
"sz": {
"type": "string",
"description": "必填<br>委托数量"
},
"px": {
"type": "string",
"description": "可选<br>委托价格<br>仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单"
},
"posSide": {
"type": "string",
"description": "可选<br>持仓方向<br>在双向持仓模式下必填,且仅可选择 `long` 或 `short`"
},
"ccy": {
"type": "string",
"description": "非必填<br>保证金币种USDT<br>仅适用于单币种保证金模式下的全仓杠杆订单"
},
"clOrdId": {
"type": "string",
"description": "非必填<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
},
"tag": {
"type": "string",
"description": "非必填<br>订单标签<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度在1-8位之间。"
},
"reduceOnly": {
"type": "boolean",
"description": "非必填<br>是否只减仓,`true` 或 `false`,默认`false`<br>仅适用于币币杠杆订单"
},
"tgtCcy": {
"type": "string",
"description": "非必填<br>市价单委托数量的类型<br>交易货币:`base_ccy`<br>计价货币:`quote_ccy`<br>仅适用于币币订单"
}
}
},
"example": [
{
"instId": "BTC-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "limit",
"px": "1000",
"sz": "0.01"
},
{
"instId": "BTC-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "limit",
"px": "1200",
"sz": "0.02"
}
]
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "oktswap6",
"ordId": "12345689",
"tag": "",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/cancel-order": {
"post": {
"tags": [
"Trade"
],
"summary": "撤单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"ordId": {
"type": "string",
"description": "可选<br>订单ID ordId和clOrdId必须传一个若传两个以ordId为主。"
},
"clOrdId": {
"type": "string",
"description": "可选<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
}
}
},
"examples": {
"1": {
"summary": "按ordId撤单",
"value": {
"ordId": "string",
"instId": "BTC-USDT"
}
},
"2": {
"summary": "按clOrdId撤单",
"value": {
"clOrdId": "string",
"instId": "BTC-USDT"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "string",
"ordId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/cancel-batch-orders": {
"post": {
"tags": [
"Trade"
],
"summary": "批量撤单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items":{
"$ref": "#/components/schemas/CancelBatchOrder"
}
},
"example": [
{
"ordId": "string",
"instId": "BTC-USDT"
},
{
"ordId": "string",
"instId": "BTC-USDT"
}
]
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "string",
"ordId": "string",
"sCode": "0",
"sMsg": ""
},
{
"clOrdId": "string",
"ordId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/amend-order": {
"post": {
"tags": [
"Trade"
],
"summary": "改单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"ordId": {
"type": "string",
"description": "可选<br>订单ID ordId和clOrdId必须传一个若传两个以ordId为主。"
},
"clOrdId": {
"type": "string",
"description": "可选<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
},
"newSz": {
"type": "string",
"description": "可选<br>修改的新数量newSz和newPx不可同时为空。对于部分成交订单该数量应包含已成交数量。"
},
"newPx": {
"type": "string",
"description": "可选<br>修改的新价格"
},
"cxlOnFail": {
"type": "boolean",
"description": "非必填<br>`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`"
},
"reqId": {
"type": "string",
"description": "非必填<br>用户自定义修改事件ID字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
}
}
},
"example": {
"ordId": "string",
"newSz": "0.2",
"instId": "BTC-USDT"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "",
"ordId": "string",
"reqId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/amend-batch-orders": {
"post": {
"tags": [
"Trade"
],
"summary": "批量改单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"ordId": {
"type": "string",
"description": "可选<br>订单ID ordId和clOrdId必须传一个若传两个以ordId为主。"
},
"clOrdId": {
"type": "string",
"description": "可选<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
},
"newSz": {
"type": "string",
"description": "可选<br>修改的新数量newSz和newPx不可同时为空。对于部分成交订单该数量应包含已成交数量。"
},
"newPx": {
"type": "string",
"description": "可选<br>修改的新价格"
},
"cxlOnFail": {
"type": "boolean",
"description": "非必填<br>`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`"
},
"reqId": {
"type": "string",
"description": "非必填<br>用户自定义修改事件ID字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
}
}
},
"example": [
{
"ordId": "string",
"newSz": "0.1",
"instId": "BTC-USDT"
},
{
"ordId": "string",
"newSz": "0.2",
"instId": "BTC-USDT"
}
]
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "string",
"ordId": "string",
"reqId": "string",
"sCode": "0",
"sMsg": ""
},
{
"clOrdId": "string",
"ordId": "string",
"reqId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/close-position": {
"post": {
"tags": [
"Trade"
],
"summary": "仓位市价全平",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId",
"mgnMode"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT-SWAP`"
},
"mgnMode": {
"type": "string",
"description": "必填<br>保证金模式。全仓:`cross`;逐仓:`isolated`"
},
"posSide": {
"type": "string",
"description": "可选<br>持仓方向<br>单向持仓模式下:可不填写此参数,默认值`net`,如果填写,仅可以填写`net`<br>双向持仓模式下: 必须填写此参数,且仅可以填写 `long`:平多 `short`:平空"
},
"ccy": {
"type": "string",
"description": "可选<br>保证金币种,如:`USDT`。单币种保证金模式的全仓币币杠杆平仓必填"
}
}
},
"example": {
"instId": "BTC-USDT-SWAP",
"mgnMode": "cross",
"posSide": "long"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"clOrdId": "",
"ordId": "string",
"reqId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/orders-pending": {
"get": {
"tags": [
"Trade"
],
"summary": "获取未成交订单列表",
"parameters": [
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "instType",
"in": "query",
"description": "产品类型。<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "uly",
"in": "query",
"description": "合约标的指数,如`BTC-USD`",
"schema": {
"type": "string"
}
},
{
"name": "ordType",
"in": "query",
"description": "订单类型<br>`market`:市价单<br>`limit`:限价单<br>`post_only`只做maker单<br>`fok`:全部成交或立即取消<br>`ioc`:立即成交并取消剩余<br>`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"accFillSz": "0",
"avgPx": "",
"cTime": "1618235248028",
"category": "normal",
"ccy": "",
"clOrdId": "",
"fee": "0",
"feeCcy": "BTC",
"fillPx": "",
"fillSz": "0",
"fillTime": "",
"instId": "BTC-USDT",
"instType": "SPOT",
"lever": "5.6",
"ordId": "301835739059335168",
"ordType": "limit",
"pnl": "0",
"posSide": "net",
"px": "59200",
"rebate": "0",
"rebateCcy": "USDT",
"side": "buy",
"slOrdPx": "",
"slTriggerPx": "",
"state": "live",
"sz": "1",
"tag": "",
"tdMode": "cross",
"tgtCcy": "",
"tpOrdPx": "",
"tpTriggerPx": "",
"tradeId": "",
"uTime": "1618235248028"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/orders-history": {
"get": {
"tags": [
"Trade"
],
"summary": "获取历史订单记录(近七天)",
"parameters": [
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"required": true,
"schema": {
"type": "string"
},
"example": "SPOT"
},
{
"name": "uly",
"in": "query",
"description": "合约标的指数,如`BTC-USD`",
"schema": {
"type": "string"
}
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "ordType",
"in": "query",
"description": "订单类型<br>`market`:市价单<br>`limit`:限价单<br>`post_only`只做maker单<br>`fok`:全部成交或立即取消<br>`ioc`:立即成交并取消剩余<br>`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)",
"schema": {
"type": "string"
}
},
{
"name": "state",
"in": "query",
"description": "订单状态<br>`canceled`:撤单成功<br>`filled`:完全成交",
"schema": {
"type": "string"
}
},
{
"name": "category",
"in": "query",
"description": "订单种类<br>`twap`TWAP自动换币<br>`adl`ADL自动减仓<br>`full_liquidation`:强制平仓<br>`partial_liquidation`:强制减仓<br>`delivery`:交割",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"ccy": "",
"ordId": "123445",
"clOrdId": "b1",
"tag": "",
"px": "999",
"sz": "3",
"ordType": "limit",
"side": "buy",
"posSide": "long",
"tdMode": "isolated",
"accFillSz": "0",
"fillPx": "0",
"tradeId": "0",
"fillSz": "0",
"fillTime": "0",
"state": "filled",
"avgPx": "0",
"lever": "20",
"tpTriggerPx": "",
"tpOrdPx": "",
"slTriggerPx": "",
"slOrdPx": "",
"feeCcy": "",
"fee": "",
"rebateCcy": "",
"rebate": "",
"tgtCcy": "",
"pnl": "",
"category": "",
"uTime": "1597026383085",
"cTime": "1597026383085"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/orders-history-archive": {
"get": {
"tags": [
"Trade"
],
"summary": "获取历史订单记录(近三个月)",
"parameters": [
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"required": true,
"schema": {
"type": "string"
},
"example": "SPOT"
},
{
"name": "uly",
"in": "query",
"description": "合约标的指数,如`BTC-USD`",
"schema": {
"type": "string"
}
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "ordType",
"in": "query",
"description": "订单类型<br>`market`:市价单<br>`limit`:限价单<br>`post_only`只做maker单<br>`fok`:全部成交或立即取消<br>`ioc`:立即成交并取消剩余<br>`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)",
"schema": {
"type": "string"
}
},
{
"name": "state",
"in": "query",
"description": "订单状态<br>`canceled`:撤单成功<br>`filled`:完全成交",
"schema": {
"type": "string"
}
},
{
"name": "category",
"in": "query",
"description": "订单种类<br>`twap`TWAP自动换币<br>`adl`ADL自动减仓<br>`full_liquidation`:强制平仓<br>`partial_liquidation`:强制减仓<br>`delivery`:交割",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"ccy": "",
"ordId": "123445",
"clOrdId": "b1",
"tag": "",
"px": "999",
"sz": "3",
"ordType": "limit",
"side": "buy",
"posSide": "long",
"tdMode": "isolated",
"accFillSz": "0",
"fillPx": "0",
"tradeId": "0",
"fillSz": "0",
"fillTime": "0",
"state": "filled",
"avgPx": "0",
"lever": "20",
"tpTriggerPx": "",
"tpOrdPx": "",
"slTriggerPx": "",
"slOrdPx": "",
"feeCcy": "",
"fee": "",
"rebateCcy": "",
"rebate": "",
"tgtCcy": "",
"pnl": "",
"category": "",
"uTime": "1597026383085",
"cTime": "1597026383085"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/fills": {
"get": {
"tags": [
"Trade"
],
"summary": "获取成交明细(近三天)",
"parameters": [
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"required": true,
"schema": {
"type": "string"
},
"example": "SPOT"
},
{
"name": "uly",
"in": "query",
"description": "合约标的指数,如`BTC-USD`",
"schema": {
"type": "string"
}
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "ordId",
"in": "query",
"description": "订单ID",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的`billId`",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的`billId`",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"tradeId": "123",
"ordId": "312269865356374016",
"clOrdId": "b16",
"billId": "1111",
"tag": "",
"fillPx": "999",
"fillSz": "3",
"side": "buy",
"posSide": "long",
"execType": "M",
"feeCcy": "",
"fee": "",
"ts": "1597026383085"
},
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"tradeId": "123",
"ordId": "312269865356374016",
"clOrdId": "b16",
"billId": "1111",
"tag": "",
"fillPx": "999",
"fillSz": "3",
"side": "buy",
"posSide": "long",
"execType": "M",
"feeCcy": "",
"fee": "",
"ts": "1597026383085"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/fills-history": {
"get": {
"tags": [
"Trade"
],
"summary": "获取成交明细(近三个月)",
"parameters": [
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"required": true,
"schema": {
"type": "string"
},
"example": "SPOT"
},
{
"name": "uly",
"in": "query",
"description": "合约标的指数,如`BTC-USD`",
"schema": {
"type": "string"
}
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "ordId",
"in": "query",
"description": "订单ID",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的`billId`",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的`billId`",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"tradeId": "123",
"ordId": "312269865356374016",
"clOrdId": "b16",
"billId": "1111",
"tag": "",
"fillPx": "999",
"fillSz": "3",
"side": "buy",
"posSide": "long",
"execType": "M",
"feeCcy": "",
"fee": "",
"ts": "1597026383085"
},
{
"instType": "FUTURES",
"instId": "BTC-USD-200329",
"tradeId": "123",
"ordId": "312269865356374016",
"clOrdId": "b16",
"billId": "1111",
"tag": "",
"fillPx": "999",
"fillSz": "3",
"side": "buy",
"posSide": "long",
"execType": "M",
"feeCcy": "",
"fee": "",
"ts": "1597026383085"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/order-algo": {
"post": {
"tags": [
"Trade"
],
"summary": "策略委托下单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId",
"tdMode",
"side",
"ordType",
"sz"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"tdMode": {
"type": "string",
"description": "必填<br>交易模式<br>保证金模式:`isolated`:逐仓 `cross`<br>全仓非保证金模式:`cash`:非保证金"
},
"side": {
"type": "string",
"description": "必填<br>订单方向。买:`buy` 卖:`sell`"
},
"ordType": {
"type": "string",
"description": "必填<br>订单类型。<br>`conditional`:单向止盈止损<br>`oco`:双向止盈止损<br>`trigger`:计划委托<br>`iceberg`:冰山委托<br>`twap`:时间加权委托"
},
"sz": {
"type": "string",
"description": "必填<br>委托数量"
},
"posSide": {
"type": "string",
"description": "可选<br>持仓方向<br>在双向持仓模式下必填,且仅可选择 `long` 或 `short`"
},
"ccy": {
"type": "string",
"description": "非必填<br>保证金币种USDT<br>仅适用于单币种保证金模式下的全仓杠杆订单"
},
"reduceOnly": {
"type": "boolean",
"description": "非必填<br>是否只减仓,`true` 或 `false`,默认`false`<br>仅适用于币币杠杆订单"
},
"tgtCcy": {
"type": "string",
"description": "非必填<br>市价单委托数量的类型<br>交易货币:`base_ccy`<br>计价货币:`quote_ccy`<br>仅适用于币币订单"
},
"tpTriggerPx": {
"type": "string",
"description": "非必填<br>止盈触发价,如果填写此参数,必须填写止盈委托价<br>适用于`止盈止损委托`"
},
"tpOrdPx": {
"type": "string",
"description": "非必填<br>止盈委托价,如果填写此参数,必须填写止盈触发价<br>委托价格为-1时执行市价止盈<br>适用于`止盈止损委托`"
},
"slTriggerPx": {
"type": "string",
"description": "非必填<br>止损触发价,如果填写此参数,必须填写止损委托价<br>适用于`止盈止损委托`"
},
"slOrdPx": {
"type": "string",
"description": "非必填<br>止损委托价,如果填写此参数,必须填写止损触发价<br>委托价格为-1时执行市价止损<br>适用于`止盈止损委托`"
},
"triggerPx": {
"type": "string",
"description": "非必填<br>计划委托触发价格<br>适用于`计划委托`"
},
"orderPx": {
"type": "string",
"description": "非必填<br>委托价格<br>委托价格为-1时执行市价委托<br>适用于`计划委托`"
},
"pxVar": {
"type": "string",
"description": "非必填<br>距离盘口的比例<br>pxVar和pxSpread只能传入一个<br>适用于`冰山委托`和`时间加权委托`"
},
"pxSpread": {
"type": "string",
"description": "非必填<br>距离盘口的比例价距<br>适用于`冰山委托`和`时间加权委托`"
},
"szLimit": {
"type": "string",
"description": "非必填<br>单笔数量<br>适用于`冰山委托`和`时间加权委托`"
},
"pxLimit": {
"type": "string",
"description": "非必填<br>挂单限制价<br>适用于`冰山委托`和`时间加权委托`"
},
"timeInterval": {
"type": "string",
"description": "非必填<br>挂单限制价<br>适用于`时间加权委托`"
}
}
},
"examples": {
"1": {
"summary": "单向止盈止损conditional委托",
"value": {
"instId": "BTC-USDT-SWAP",
"ordType": "conditional",
"posSide": "long",
"side": "buy",
"sz": "1",
"tdMode": "isolated",
"tpOrdPx": "1000.0",
"tpTriggerPx": "1000.0"
}
},
"2": {
"summary": "双向止盈止损oco委托",
"value": {
"instId": "BTC-USDT-SWAP",
"ordType": "oco",
"posSide": "long",
"side": "buy",
"sz": "1",
"tdMode": "isolated",
"tpOrdPx": "10000.0",
"tpTriggerPx": "10000.0",
"slOrdPx": "100000.0",
"slTriggerPx": "100000.0"
}
},
"3": {
"summary": "计划trigger委托",
"value": {
"instId": "BTC-USDT-SWAP",
"ordType": "trigger",
"orderPx": "1000",
"posSide": "long",
"side": "buy",
"sz": "1",
"tdMode": "isolated",
"triggerPx": "1000.0"
}
},
"4": {
"summary": "冰山iceberg委托",
"value": {
"instId": "BTC-USDT-SWAP",
"ordType": "iceberg",
"side": "buy",
"posSide": "long",
"pxLimit": "30000.0",
"pxSpread": "10.0",
"sz": "10",
"szLimit": "2",
"tdMode": "isolated"
}
},
"5": {
"summary": "时间加权twap委托",
"value": {
"instId": "BTC-USDT-SWAP",
"ordType": "twap",
"side": "buy",
"posSide": "long",
"pxLimit": "30000.0",
"pxSpread": "10.0",
"sz": "10",
"szLimit": "2",
"tdMode": "isolated",
"timeInterval": "5"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"algoId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/cancel-algos": {
"post": {
"tags": [
"Trade"
],
"summary": "撤销策略委托订单",
"description": "撤销策略委托订单不包含冰山委托、时间加权等高级策略订单每次最多可以撤销10个策略委托单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CancelAlgoOrder"
}
},
"example": [
{
"algoId": "string",
"instId": "BTC-USDT-SWAP"
},
{
"algoId": "string",
"instId": "BTC-USDT-SWAP"
}
]
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"algoId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/cancel-advance-algos": {
"post": {
"tags": [
"Trade"
],
"summary": "撤销高级策略委托订单",
"description": "撤销冰山委托、时间加权等高级策略委托订单每次最多可以撤销10个策略委托单",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"instId",
"algoId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"algoId": {
"type": "string",
"description": "必填<br>策略委托单ID"
}
}
},
"example": [
{
"algoId": "string",
"instId": "BTC-USDT"
},
{
"algoId": "string",
"instId": "BTC-USDT"
}
]
}
},
"required": true
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {}
},
"example": {
"code": "0",
"msg": "",
"data": [
{
"algoId": "string",
"sCode": "0",
"sMsg": ""
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/orders-algo-pending": {
"get": {
"tags": [
"Trade"
],
"summary": "获取未完成策略委托单列表",
"parameters": [
{
"name": "ordType",
"in": "query",
"description": "订单类型<br>`conditional`:单向止盈止损<br>`oco`:双向止盈止损<br>`trigger`:计划委托<br>`iceberg`:冰山委托<br>`twap`:时间加权委托",
"schema": {
"type": "string"
},
"required": true,
"example": "conditional"
},
{
"name": "algoId",
"in": "query",
"description": "策略委托单ID",
"schema": {
"type": "string"
}
},
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"schema": {
"type": "string"
}
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "string",
"ccy": "BTC",
"algoId": "string",
"sz": "10",
"ordType": "oco",
"side": "buy",
"posSide": "long",
"tdMode": "cross",
"tgtCcy": "",
"state": "1",
"lever": "20",
"tpTriggerPx": "",
"tpOrdPx": "",
"slTriggerPx": "",
"triggerPx": "99",
"ordPx": "12",
"actualSz": "",
"actualPx": "",
"actualSide": "",
"pxVar": "",
"pxSpread": "",
"pxLimit": "",
"szLimit": "",
"timeInterval": "",
"triggerTime": "1597026383085",
"cTime": "1597026383000"
}
]
}
}
}
}
}
}
}
},
"/api/v5/trade/orders-algo-history": {
"get": {
"tags": [
"Trade"
],
"summary": "获取历史策略委托单列表",
"parameters": [
{
"name": "ordType",
"in": "query",
"description": "订单类型<br>`conditional`:单向止盈止损,`oco`:双向止盈止损,`trigger`:计划委托,`iceberg`:冰山委托,`twap`:时间加权委托",
"schema": {
"type": "string"
},
"required": true,
"example": "conditional"
},
{
"name": "algoId",
"in": "query",
"description": "策略委托单ID<br>`state`和`algoId`必填且只能填其一",
"schema": {
"type": "string"
}
},
{
"name": "state",
"in": "query",
"description": "订单状态<br>`effective`:已生效,`canceled`:已经撤销,`order_failed`:委托失败<br>`state`和`algoId`必填且只能填其一",
"schema": {
"type": "string"
}
},
{
"name": "instType",
"in": "query",
"description": "产品类型<br>`SPOT`:币币<br>`MARGIN`:币币杠杆<br>`SWAP`:永续合约<br>`FUTURES`:交割合约<br>`OPTION`:期权",
"schema": {
"type": "string"
},
"example": "SPOT"
},
{
"name": "instId",
"in": "query",
"description": "产品ID如`BTC-USDT-SWAP`",
"schema": {
"type": "string"
}
},
{
"name": "after",
"in": "query",
"description": "请求此ID之前更旧的数据的分页内容传的值为对应接口的ordId",
"schema": {
"type": "string"
}
},
{
"name": "before",
"in": "query",
"description": "请求此ID之后更新的数据的分页内容传的值为对应接口的`ordId`",
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "返回结果的数量默认100条",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"code": "0",
"msg": "",
"data": [
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "string",
"ccy": "BTC",
"algoId": "string",
"sz": "10",
"ordType": "oco",
"side": "buy",
"posSide": "long",
"tdMode": "cross",
"tgtCcy": "",
"state": "effective",
"lever": "20",
"tpTriggerPx": "",
"tpOrdPx": "",
"slTriggerPx": "",
"triggerPx": "99",
"ordPx": "12",
"actualSz": "",
"actualPx": "",
"actualSide": "",
"pxVar": "",
"pxSpread": "",
"pxLimit": "",
"szLimit": "",
"timeInterval": "",
"triggerTime": "1597026383085",
"cTime": "1597026383000"
}
]
}
}
}
}
}
}
}
}
},
"components": {
"schemas":{
"CancelBatchOrder":{
"type": "object",
"required": [
"instId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"ordId": {
"type": "string",
"description": "可选<br>订单ID ordId和clOrdId必须传一个若传两个以ordId为主。"
},
"clOrdId": {
"type": "string",
"description": "可选<br>客户自定义订单ID<br>字母区分大小写与数字的组合可以是纯字母、纯数字且长度要在1-32位之间。"
}
}
},
"CancelAlgoOrder": {
"type": "object",
"required": [
"instId",
"algoId"
],
"properties": {
"instId": {
"type": "string",
"description": "必填<br>产品ID`BTC-USDT`"
},
"algoId": {
"type": "string",
"description": "必填<br>策略委托单ID"
}
}
}
}
}
}
}