{ "openapi": "3.0.1", "info": { "title": "REST API", "version": "1.0", "description": "# 使用说明 \n 该功能接口用户需先登陆,接口只会请求模拟环境

*Parameters* 面板中点击`Try it out`按钮,编辑请求参数,点击`Execute`按钮发送请求。*Responses* 面板中查看请求结果。
" }, "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": "必填
产品ID,如:`BTC-USDT`" }, "tdMode": { "type": "string", "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" }, "side": { "type": "string", "description": "必填
订单方向。买:`buy` 卖:`sell`" }, "ordType": { "type": "string", "description": "必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)" }, "sz": { "type": "string", "description": "必填
委托数量" }, "px": { "type": "string", "description": "可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单" }, "posSide": { "type": "string", "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" }, "ccy": { "type": "string", "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" }, "clOrdId": { "type": "string", "description": "非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" }, "tag": { "type": "string", "description": "非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。" }, "reduceOnly": { "type": "boolean", "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" }, "tgtCcy": { "type": "string", "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" } } }, "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": "订单ID,ordId和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": "必填
产品ID,如:`BTC-USDT`" }, "tdMode": { "type": "string", "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" }, "side": { "type": "string", "description": "必填
订单方向。买:`buy` 卖:`sell`" }, "ordType": { "type": "string", "description": "必填
订单类型。
市价单:`market`
限价单:`limit`
只做maker单:`post_only`
全部成交或立即取消:`fok`
立即成交并取消剩余:`ioc`
市价委托立即成交并取消剩余:`optimal_limit_ioc`(仅适用交割、永续)" }, "sz": { "type": "string", "description": "必填
委托数量" }, "px": { "type": "string", "description": "可选
委托价格
仅适用于`limit`、`post_only`、`fok`、`ioc`类型的订单" }, "posSide": { "type": "string", "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" }, "ccy": { "type": "string", "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" }, "clOrdId": { "type": "string", "description": "非必填
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" }, "tag": { "type": "string", "description": "非必填
订单标签
字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。" }, "reduceOnly": { "type": "boolean", "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" }, "tgtCcy": { "type": "string", "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" } } }, "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": "必填
产品ID,如:`BTC-USDT`" }, "ordId": { "type": "string", "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" }, "clOrdId": { "type": "string", "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在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": "必填
产品ID,如:`BTC-USDT`" }, "ordId": { "type": "string", "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" }, "clOrdId": { "type": "string", "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" }, "newSz": { "type": "string", "description": "可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。" }, "newPx": { "type": "string", "description": "可选
修改的新价格" }, "cxlOnFail": { "type": "boolean", "description": "非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`" }, "reqId": { "type": "string", "description": "非必填
用户自定义修改事件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": "必填
产品ID,如:`BTC-USDT`" }, "ordId": { "type": "string", "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" }, "clOrdId": { "type": "string", "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" }, "newSz": { "type": "string", "description": "可选
修改的新数量,newSz和newPx不可同时为空。对于部分成交订单,该数量应包含已成交数量。" }, "newPx": { "type": "string", "description": "可选
修改的新价格" }, "cxlOnFail": { "type": "boolean", "description": "非必填
`false`:不自动撤单 `true`:自动撤单 当订单修改失败时,该订单是否需要自动撤销。默认为`false`" }, "reqId": { "type": "string", "description": "非必填
用户自定义修改事件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": "必填
产品ID,如:`BTC-USDT-SWAP`" }, "mgnMode": { "type": "string", "description": "必填
保证金模式。全仓:`cross`;逐仓:`isolated`" }, "posSide": { "type": "string", "description": "可选
持仓方向
单向持仓模式下:可不填写此参数,默认值`net`,如果填写,仅可以填写`net`
双向持仓模式下: 必须填写此参数,且仅可以填写 `long`:平多 ,`short`:平空" }, "ccy": { "type": "string", "description": "可选
保证金币种,如:`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": "产品类型。
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`OPTION`:期权", "required": false, "schema": { "type": "string" } }, { "name": "uly", "in": "query", "description": "合约标的指数,如`BTC-USD`", "schema": { "type": "string" } }, { "name": "ordType", "in": "query", "description": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`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": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)", "schema": { "type": "string" } }, { "name": "state", "in": "query", "description": "订单状态
`canceled`:撤单成功
`filled`:完全成交", "schema": { "type": "string" } }, { "name": "category", "in": "query", "description": "订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`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": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "订单类型
`market`:市价单
`limit`:限价单
`post_only`:只做maker单
`fok`:全部成交或立即取消
`ioc`:立即成交并取消剩余
`optimal_limit_ioc`:市价委托立即成交并取消剩余(仅适用交割、永续)", "schema": { "type": "string" } }, { "name": "state", "in": "query", "description": "订单状态
`canceled`:撤单成功
`filled`:完全成交", "schema": { "type": "string" } }, { "name": "category", "in": "query", "description": "订单种类
`twap`:TWAP自动换币
`adl`:ADL自动减仓
`full_liquidation`:强制平仓
`partial_liquidation`:强制减仓
`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": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "必填
产品ID,如:`BTC-USDT`" }, "tdMode": { "type": "string", "description": "必填
交易模式
保证金模式:`isolated`:逐仓 ;`cross`
全仓非保证金模式:`cash`:非保证金" }, "side": { "type": "string", "description": "必填
订单方向。买:`buy` 卖:`sell`" }, "ordType": { "type": "string", "description": "必填
订单类型。
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托" }, "sz": { "type": "string", "description": "必填
委托数量" }, "posSide": { "type": "string", "description": "可选
持仓方向
在双向持仓模式下必填,且仅可选择 `long` 或 `short`" }, "ccy": { "type": "string", "description": "非必填
保证金币种,如:USDT
仅适用于单币种保证金模式下的全仓杠杆订单" }, "reduceOnly": { "type": "boolean", "description": "非必填
是否只减仓,`true` 或 `false`,默认`false`
仅适用于币币杠杆订单" }, "tgtCcy": { "type": "string", "description": "非必填
市价单委托数量的类型
交易货币:`base_ccy`
计价货币:`quote_ccy`
仅适用于币币订单" }, "tpTriggerPx": { "type": "string", "description": "非必填
止盈触发价,如果填写此参数,必须填写止盈委托价
适用于`止盈止损委托`" }, "tpOrdPx": { "type": "string", "description": "非必填
止盈委托价,如果填写此参数,必须填写止盈触发价
委托价格为-1时,执行市价止盈
适用于`止盈止损委托`" }, "slTriggerPx": { "type": "string", "description": "非必填
止损触发价,如果填写此参数,必须填写止损委托价
适用于`止盈止损委托`" }, "slOrdPx": { "type": "string", "description": "非必填
止损委托价,如果填写此参数,必须填写止损触发价
委托价格为-1时,执行市价止损
适用于`止盈止损委托`" }, "triggerPx": { "type": "string", "description": "非必填
计划委托触发价格
适用于`计划委托`" }, "orderPx": { "type": "string", "description": "非必填
委托价格
委托价格为-1时,执行市价委托
适用于`计划委托`" }, "pxVar": { "type": "string", "description": "非必填
距离盘口的比例
pxVar和pxSpread只能传入一个
适用于`冰山委托`和`时间加权委托`" }, "pxSpread": { "type": "string", "description": "非必填
距离盘口的比例价距
适用于`冰山委托`和`时间加权委托`" }, "szLimit": { "type": "string", "description": "非必填
单笔数量
适用于`冰山委托`和`时间加权委托`" }, "pxLimit": { "type": "string", "description": "非必填
挂单限制价
适用于`冰山委托`和`时间加权委托`" }, "timeInterval": { "type": "string", "description": "非必填
挂单限制价
适用于`时间加权委托`" } } }, "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": "必填
产品ID,如:`BTC-USDT`" }, "algoId": { "type": "string", "description": "必填
策略委托单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": "订单类型
`conditional`:单向止盈止损
`oco`:双向止盈止损
`trigger`:计划委托
`iceberg`:冰山委托
`twap`:时间加权委托", "schema": { "type": "string" }, "required": true, "example": "conditional" }, { "name": "algoId", "in": "query", "description": "策略委托单ID", "schema": { "type": "string" } }, { "name": "instType", "in": "query", "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "订单类型
`conditional`:单向止盈止损,`oco`:双向止盈止损,`trigger`:计划委托,`iceberg`:冰山委托,`twap`:时间加权委托", "schema": { "type": "string" }, "required": true, "example": "conditional" }, { "name": "algoId", "in": "query", "description": "策略委托单ID
`state`和`algoId`必填且只能填其一", "schema": { "type": "string" } }, { "name": "state", "in": "query", "description": "订单状态
`effective`:已生效,`canceled`:已经撤销,`order_failed`:委托失败
`state`和`algoId`必填且只能填其一", "schema": { "type": "string" } }, { "name": "instType", "in": "query", "description": "产品类型
`SPOT`:币币
`MARGIN`:币币杠杆
`SWAP`:永续合约
`FUTURES`:交割合约
`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": "必填
产品ID,如:`BTC-USDT`" }, "ordId": { "type": "string", "description": "可选
订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主。" }, "clOrdId": { "type": "string", "description": "可选
客户自定义订单ID
字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。" } } }, "CancelAlgoOrder": { "type": "object", "required": [ "instId", "algoId" ], "properties": { "instId": { "type": "string", "description": "必填
产品ID,如:`BTC-USDT`" }, "algoId": { "type": "string", "description": "必填
策略委托单ID" } } } } } } }