Welcome
欢迎来到Bitget API文档,点击这里直接开始
近期接口变更预告
编号 | 接口 | 上线日期 | 功能描述 |
---|
更新日志
2023年03月28日
- 新增接口 获取仓位档位配置
- 新增接口 交易员查看自己交易数据指标统计
- 新增接口 跟单用户查看跟单设置
- 新增接口 跟单用户跟单设置
- 新增接口 跟单用户根据跟单号平仓
- 新增接口 跟单用户根据币对、方向、仓位模式、保证金平仓
- 新增接口 跟单用户设置止盈止损
2023年03月17日
- 新增接口 获取成交明细
- 新增接口 按symbol撤单
- 新增接口 计划委托(止盈止损)按symbol撤单
2023年03月15日
- /api/mix/v1/market/ticker 与 /api/mix/v1/market/tickers 新增响应字段: 'indexPrice', 'fundingRate', 'holdingAmount'
- /api/mix/v1/market/candles 请求参数 'limit' 最大值: 1000
- /api/mix/v1/account/account and /api/mix/v1/account/accounts 新增响应字段 'unrealizedPL', 'bonus'
- /api/mix/v1/account/sub-account-contract-assets 新增响应字段 'bonus'
- /api/mix/v1/order/cancel-order 新增请求参数 'clientOid'
- /api/mix/v1/order/cancel-batch-orders 新增请求字段: 'clientOids', 新增响应字段: 'client_order_ids'
- /api/mix/v1/order/current 新增响应字段: 'priceAvg', 'filledAmount', 'leverage', 'marginMode', 'reduceOnly', 'enterPointSource', 'tradeSide', 'holdMode', 'uTime'
- /api/mix/v1/order/history and /api/mix/v1/order/historyProductType 新增请求字段: 'clientOid'; 新增响应字段: : reduceOnly', 'enterPointSource', 'tradeSide', 'holdMode'
- /api/mix/v1/order/detail 新增响应字段: 'leverage', 'marginMode', 'reduceOnly', 'enterPointSource', 'tradeSide', 'holdMode'
- /api/mix/v1/order/fills and /api/mix/v1/order/allFills 新增响应字段:: 'enterPointSource', 'tradeSide', 'holdMode','takerMakerFlag'
- /api/mix/v1/plan/modifyPlan, /api/mix/v1/plan/modifyPlanPreset, /api/mix/v1/plan/placeTPSL, /api/mix/v1/plan/placeTrailStop, /api/mix/v1/plan/placePositionsTPSL, /api/mix/v1/plan/modifyTPSLPlan, /api/mix/v1/plan/cancelPlan, 新增请求字段 'clientOid'
- /api/mix/v1/plan/currentPlan and /api/mix/v1/plan/historyPlan added response fields: 'clientOid', 'rangeRate', 'enterPointSource', 'tradeSide', 'holdMode'
- 订单频道 新增推送字段 'hM', 'eps', 'tS', 'low',
- 计划委托频道 新增推送字段 'hM', 'eps', 'triggerTime', 'userId', 'version', 'triggerPxType', 'key'
- RestAPI错误代码 与 WebSocket错误代码 新增error code
2023年02月28日
- business 新增类型: 'contract_settle_fee': 资金费率
2023年02月13日
- 新增接口 VIP 费率
- 接口 /api/mix/v1/order/fills /api/mix/v1/order/allFills 文档补充响应字段 profit/fillAmount
2023年01月30日
- /api/mix/v1/plan/placePlan 新增参数: 'reduceOnly'
- /api/mix/v1/plan/modifyTPSLPlan 参数 'triggerPrice' 必填
- /api/mix/v1/trace/modifyTPSL 更新参数描述: 'stopProfitPrice' & 'stopLossPrice'
2023年01月27日
- 获取所有子账户合约资产信息 响应参数添加unrealizedPL
- 止盈止损下单 请求参数triggerType描述更新
2023年01月11日
2022年12月28日
- 切换官方telegram群
- business 添加 'burst_long_loss_query', 'burst_short_loss_query'
- Websocket -> account channel -> 推送数据:删除crossMaxAvailable和fixedMaxAvailable,替换成maxOpenPosAvailable
2022年12月21日
- /api/mix/v1/plan/placeTrailStop 补充参数side
2022年12月16日
- /api/mix/v1/account/setPositionMode 更新curl示例中的请求参数
- /api/mix/v1/order/placeOrder clientOid 幂等有效期 30 天
- 交易员创建订单限速: 1/s
- /api/mix/v1/trace/currentTrack 说明最大 pageSize
- /api/mix/v1/account/setMargin 说明 'amount' 的用法
- /api/mix/v1/order/batch-orders 说明最大批量下单数量: 50
2022年12月07日
- 以下接口指定限定planType值:
- /api/mix/v1/plan/placeTPSL
- /api/mix/v1/plan/placePositionsTPSL
- /api/mix/v1/plan/modifyTPSLPlan
- /api/mix/v1/plan/cancelPlan
2022年12月06日
- RestAPI -> 账户接口 -> added 获取所有子账户合约资产信息
- WebsocketAPI -> 私有频道 -> 订单频道 -> 推送数据参数 -> 'status' 补充枚举: 'init'
- WebsocketAPI -> 公共频道 -> 行情频道 -> 推送数据参数 -> 新增 'bidSz', 'askSz'等字段
2022年11月23日
2022年11月11日
- 新增接口 RestAPI -> 账户接口 -> 调节单双向持仓模式
- 补充说明单向持仓时的 下单 逻辑
- 补充说明单向持仓时的 一键反手 逻辑
- 订单状态补充: 'init' 状态
- 新增单向持仓相关类型 side 值,新增trade side
2022年10月27日
- 新增channel WebSocketAPI -> 公共频道 -> 交易详情频道
- WebSocketAPI -> 公共频道 -> 深度频道 新增 channel值:books1
- WebSocketAPI -> 私有频道 -> 计划委托频道 新增推送字段 websocket plantype
2022年10月14日
2022年9月15日
2022年9月6日
2022年8月29日
2022年8月19日
行情接口
->获取K线数据
新增UTC0 时区节点查询行情接口
->单个Ticker行情获取
,全部ticker行情获取
新增openUtc
,chgUtc
UTC0 时区价格
2022年8月16日
-
合约信息接口
新增sizeMultiplier
数量乘数字段
2022年8月15日
- Get 请求方式禁止在
RequestBody
传递参数, 请以QueryString
方式传递参数
2022年8月11日
跟单接口
->获取交易员跟单交易对
新增响应参数,交易员最小开仓数量
2022年8月08日
- 增加加密代码示例
2022年8月06日
- 增加PostMan 请求demo
2022年8月03日
- 每个接口新增请求示例
2022年8月01日
- /api/mix/v1/account/accountBusinessBill 新增根据业务线查询流水
2022年7月22日
- 新增支持USDC 合约
- /api/mix/v1/order/marginCoinCurrent 保证金参数改为 非必传, 可以获取当前业务线下所有当前委托
- /api/mix/v1/order/allFills 新增根据业务线查询成交明细
2022年7月21日
- Websocket 连接增加规则, 请参考 连接 目录
2022年07月20日
- 接口响应
requestTime
字段已废弃,请不要在使用此字段
2022年07月8日
- 增加计划委托websocket频道
2022年06月24日
/api/mix/v1/trace/modifyTPSL
增加交易员修改止盈止损接口
2022年06月10日
/api/mix/v1/order/detail
增加clientOid
参数
2022年04月02日
- 新增合约账户流水接口
/followerOrder
跟单交易接口增加保证金字段
2022年03月04日
- 仓位接口增加
keepMarginRate
维持保证金率
2022年02月25日
- 止盈止损下单新增 根据数量下单
size
非必填 - 获取全部成交明细新增
lastEndId
查询分页
2022年02月12日
- 新增查询交易对杠杆倍数 获取交易对支持的杠杆
- 获取成交明细支持查询全部明细 查询成交明细
2022年1月05日【限频规则修改新增域名】
- 去掉https://capi.bitgetapi.com
新增域名 https://api.bitget.com
- 限频规则修改
请求路径 | 规则 |
---|---|
/api/mix/v1/account/setLeverage | 5c/1s |
/api/mix/v1/account/setMargin | 5c/1s |
/api/mix/v1/account/setMarginMode | 5c/1s |
/api/mix/v1/account/setPositionMode | 5c/1s |
/api/mix/v1/position/allPosition | 5c/1s |
2021年12月08日【专业合约WebSocket私有频道上线】
- 专业合约私有频道接口上线
2021年10月26日【新增接口】
- 跟单接口增加跟随者查看跟单接口
- 交易员查看平仓跟单交易对信息接口
- 交易员设置跟单交易对接口
- Golang SDK 上线
- Nodejs SDK 上线
2021年9月26日【专业合约WebSocket公共频道上线】
- 专业合约公共频道接口上线
- 仓位接口新增爆仓价字段
2021年9月08日【合约列表和Ticker行情】
- 获取全部合约列表和获取全部ticker行情接口需要传入productType参数,支持模拟盘交易
2021年9月06日【新增账户列表查询】
2021年7月27日【新增混合合约V1文档】
- 新增V1文档
- 错误信息支持中/英
简介
API 简介
欢迎使用Bitget开发者文档!
此文档是Bitget API的唯一官方文档,Bitget API提供的能力会在此持续更新,请大家及时关注。
你可以通过点击上方菜单来切换获取不同业务的API,还可通过点击右上方的语言按钮来切换文档语言。
文档右侧是针对请求参数以及响应结果的示例。
市商/量化
欢迎有优秀 maker 策略且交易量大的用户参与长期做市商项目。请提供以下信息发送邮件至:
- API@bitget.com 合约做市商申请。
- 提供 UID (需不存在返佣关系的 UID);
- 提供其他交易平台 maker 交易量截图证明(比如30天内成交量);
- 请简要阐述做市方法,不需要细节。
更新关注
关于API新增、更新、下线等信息Bitget会提前发布公告进行通知,建议您关注和订阅我们的公告,及时获取相关信息。
您可以点击 这里 订阅公告。
联系我们
使用过程中如有问题或者建议,您可选择以下方式联系我们:
- 发送邮件至 API@bitget.com。
- Telegram 点击加入
常见问题
- Q1: 交易员为什么不能平仓?
A : 交易员平仓不能调用 下单接口,需要调用 交易员平仓接口
- Q2: 下单交易对我是传 BTCUSDT_UMCBL 还是传 BTCUSDT ?
A : 下单接口所有的 symbol
参数都是传 合约信息接口接口的 symbol
返回的值
Q3 : websocket 订阅时
instId
传的是什么?A :
instId
传的是 合约信息接口symbolName
Q4: 接口
symbol
区分大小写吗?A :
symbol
区分大小写 必须一律大写
快速入门
接入准备
如需使用API ,请先登录网页端,完成API key的申请和权限配置,再据此文档详情进行开发和交易。
您可以点击 这里 创建 API Key。
每个用户可创建10组Api Key,每个Api Key可对应设置读取、交易两种权限。
权限说明如下:
- 读取权限:读取权限用于对数据的查询,例如:行情数据。
- 交易权限:交易权限用于下单、撤单等接口。
- 划转权限:划转权限用于在Bitget用户账户之间划转加密货币。
- 提币权限:提币权限用于从Bitget账户转出资产。
请注意,您只能通过IP白名单提币。
创建成功后请务必记住以下信息:
APIKey
API交易的身份标识,随机算法生成。Secretkey
私钥,由系统随机生成,用于签名的生成。Passphrase
口令,由用户自己设定,需要注意的是,Passphrase忘记之后是无法找回的,需要重新创建APIKey。
SDK/代码示例
SDK(推荐)
Java | Python | Golang | NodeJs | PHP
PostMan(推荐) PostMan
您应该首先在 PostMan 左侧的环境选项卡中配置 API 密钥、密钥和密码。
接口类型
本章节主要为接口类型分以下两个方面:
- 公共接口
- 私有接口
公共接口
公共接口可用于获取配置信息和行情数据。公共请求无需认证即可调用。
私有接口
私有接口可用于订单管理和账户管理。每个私有请求必须使用规范的验证形式进行签名。
私有接口需要使用您的APIKey进行验证。
访问限制
本章节主要为访问限制:
- Rest API 当访问超过频率限制时,将返回429状态:请求太频繁。
Rest API
如果传入有效的APIKey 用APIKey限速;如果没有则拿公网IP限速。
限速规则:各个接口上有单独的说明,如果没有一般接口限速为 10次/秒。
特殊说明:批量下单时,若下4个币对,每个币对10个订单时,计为一次请求。
API域名
您可以自行使用Rest API接入方式进行操作。
域名 | REST API | 建议使用 |
---|---|---|
域名1 | https://api.bitget.com | 主域名 |
域名2 | https://capi.bitget.com | 旧域名,测试用 |
API验证
发起请求
所有REST请求的header都必须包含以下key:
- ACCESS-KEY:API KEY作为一个字符串。
- ACCESS-SIGN:使用base64编码签名(请参阅签名消息)。
- ACCESS-TIMESTAMP:您请求的时间戳。
- ACCESS-PASSPHRASE:您在创建API KEY时设置的口令。
- Content-Type:统一设置为application/json。
- locale: 支持多语言, 如:中文(zh-CN),英语(en-US)
//Java
System.currentTimeMillis();
//python
import time
time.time_ns() / 1000000
//Golang
import (
"time"
)
int64(time.Now().UnixNano()/1000000)
//Javascript
Math.round(new Date())
//PHP
microtime(true) * 1000;
签名
ACCESS-SIGN的请求头是对 timestamp + method.toUpperCase() + requestPath + "?" + queryString + body
字符串(+表示字符串连接)使用 HMAC SHA256 方法加密,通过BASE64 编码输出而得到的。
签名各字段说明
- timestamp:与 ACCESS-TIMESTAMP 请求头相同。
- method:请求方法(POST/GET),字母全部大写。
- requestPath:请求接口路径。
- queryString:请求URL中(?后的请求参数)的查询字符串。
- body:请求主体对应的字符串,如果请求没有主体(通常为GET请求)则body可省略。
queryString为空时,签名格式
timestamp + method.toUpperCase() + requestPath + body
queryString不为空时,签名格式
timestamp + method.toUpperCase() + requestPath + "?" + queryString + body
举例说明
获取合约深度信息,以 BTCUSDT_UMCBL 为例:
- Timestamp = 16273667805456
- Method = "GET"
- requestPath = "/api/mix/V1/market/depth"
- queryString= "?symbol=BTCUSDT_UMCBL&limit=20"
生成待签名的字符串:
'16273667805456GET/api/mix/v1/market/depth?symbol=BTCUSDT_UMCBL&limit=20'
合约下单,以 BTCUSDT_UMCBL 为例:
- Timestamp = 16273667805456
- Method = "POST"
- requestPath = "/api/mix/v1/order/placeOrder"
- body = {"symbol":"BTCUSDT_UMCBL","size":"8","side":"open_long","orderType":"limit","client_oid":"bitget#123456"}
生成待签名的字符串:
'16273667805456POST/api/mix/v1/order/placeOrder{"symbol":"BTCUSDT_UMCBL","size":"8","side":"open_long","order_type":"limit","client_oid":"bitget#123456"}'
生成最终签名的步骤
第1步,将待签名字符串使用私钥secretkey进行hmac sha256加密
Signature = hmac_sha256(secretkey, Message)
第2步,对于Signature进行base64编码
Signature = base64.encode(Signature)
签名示例
Java
public static String generate(String timestamp, String method, String requestPath,
String queryString, String body, String secretKey)
throws CloneNotSupportedException, InvalidKeyException, UnsupportedEncodingException {
method = method.toUpperCase();
body = StringUtils.defaultIfBlank(body, StringUtils.EMPTY);
queryString = StringUtils.isBlank(queryString) ? StringUtils.EMPTY : "?" + queryString;
String preHash = timestamp + method + requestPath + queryString + body;
System.out.println(preHash);
byte[] secretKeyBytes = secretKey.getBytes(SignatureUtils.CHARSET);
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKeyBytes, SignatureUtils.HMAC_SHA256);
Mac mac = (Mac) SignatureUtils.MAC.clone();
mac.init(secretKeySpec);
return Base64.getEncoder().encodeToString(mac.doFinal(preHash.getBytes(SignatureUtils.CHARSET)));
}
public static void main(String[] args) throws Exception {
String msg=generate("1659927638003","POST","/api/mix/v1/order/placeOrder" ,null,"{"symbol":"TRXUSDT_UMCBL","side":"open_long","orderType":"limit","force":"normal","price":"0.046317","quantity":"1212"}","");
System.out.println(msg);
}
Python
def sign(message, secret_key):
mac = hmac.new(bytes(secret_key, encoding='utf8'), bytes(message, encoding='utf-8'), digestmod='sha256')
d = mac.digest()
return base64.b64encode(d)
def pre_hash(timestamp, method, request_path, body):
return str(timestamp) + str.upper(method) + request_path + body
if __name__ == '__main__':
signStr = sign(pre_hash('1659927638003', 'POST', '/api/mix/v1/order/placeOrder', str('{"symbol":"TRXUSDT_SPBL","side":"open_long","orderType":"limit","force":"normal","price":"0.046317","quantity":"1212"}')), '')
print(signStr)
请求交互
所有请求基于Https协议,POST 请求头信息中Content-Type 需要统一设置为: 'application/json'。
请求交互说明
- 请求参数:根据接口请求参数规定进行参数封装。
- 提交请求参数:将封装好的请求参数通过GET/POST方式提交至服务器。
- 服务器响应:服务器首先对用户请求数据进行参数安全校验,通过校验后根据业务逻辑将响应数据以JSON格式返回给用户。
- 数据处理:对服务器响应数据进行处理。
成功
HTTP状态码200表示成功响应,并可能包含内容。如果响应含有内容,则将显示在相应的返回内容里面。
常见错误码
- 400 Bad Request – Invalid request format 请求格式无效
- 401 Unauthorized – Invalid API Key 无效的API Key
- 403 Forbidden – You do not have access to the requested resource 请求无权限
- 404 Not Found 没有找到请求
- 429 Too Many Requests 请求太频繁被系统限流
- 500 Internal Server Error – We had a problem with our server 服务器内部错误
- 如果失败body带有错误描述信息
标准规范
时间戳
请求签名中的ACCESS-TIMESTAMP的单位是毫秒。请求的时间戳必须在API服务时间的30秒内,否则请求将被视为过期并被拒绝。 如果本地服务器时间和API服务器时间之间存在较大的偏差,那么我们建议您使用通过查询API服务器时间来更新http header。
限频规则
如果请求过于频繁系统将自动限制请求,并在http header中返回429 too many requests状态码。
- 公共接口:如行情接口,统一限频为1秒最多20个请求。
- 授权接口:通过apikey限制授权接口的调用,参考每个接口的限频规则限频。
请求格式
目前只有两种格式的请求方法:GET和POST
- GET: 参数通过queryString在路径中传输到服务器。
- POST: 参数按照json格式发送body传输到服务器。
API 公共参数
side(交易指令)
字段 | 说明 |
---|---|
open_long | 开多 |
open_short | 开空 |
close_long | 平多 |
close_short | 平空 |
buy_single | 单向持仓买 |
sell_single | 单向持仓卖 |
business(记录类型)
字段 | 说明 |
---|---|
open_long | 开多 |
open_short | 开空 |
close_long | 平多 |
close_short | 平空 |
trans_from_exchange | 由现货账户转入 |
trans_to_exchange | 转出至现货账户 |
contract_settle_fee | 资金费率 |
contract_main_settle_fee | 全仓资金费率 |
contract_margin_settle_fee | 逐仓资金费率 |
tracking_trader_income | 带单分润 |
burst_long_loss_query | 爆仓平多 |
burst_short_loss_query | 爆仓平空 |
tradeSide(交易方向)
double_hold 的交易方向
字段 | 说明 |
---|---|
open_long | 开多 |
open_short | 开空 |
close_long | 平多 |
close_short | 平空 |
reduce_close_long | 强制减多 |
reduce_close_short | 强制减空 |
offset_close_long | 轧差强制减多 |
offset_close_short | 轧差强制减空 |
burst_close_long | 爆仓平多 |
burst_close_short | 爆仓平空 |
delivery_close_long | 多头交割 |
delivery_close_short | 空头交割 |
single_hold 的交易方向
字段 | 说明 |
---|---|
buy_single | 单边持仓时买 |
sell_single | 单边持仓时卖 |
reduce_buy_single | 单边持仓时减仓买 |
reduce_sell_single | 单边持仓时减仓卖 |
burst_buy_single | 爆仓买 |
burst_sell_single | 爆仓卖 |
delivery_buy_single | 单边持仓时多头交割 |
delivery_sell_single | 单边持仓时空头交割 |
orderType(交易类型)
字段 | 说明 |
---|---|
limit | 限价 |
market | 市价 |
timeInForceValue(订单有效期)
字段 | 说明 |
---|---|
normal | 普通订单 |
post_only | 订单会一直有效,直到被成交或者取消 |
ioc | 无法立即成交的部分就撤销 |
fok | 无法全部立即成交就撤销 |
triggerType(触发类型)
字段 | 说明 |
---|---|
fill_price | 成交价触发 |
market_price | 标记价 mark price 触发 |
planType(计划委托类型)
planType 的交易方向
字段 | 说明 |
---|---|
normal_plan | 普通计划 |
profit_plan | 止盈计划 |
loss_plan | 止损计划 |
pos_profit | 仓位止盈 |
pos_loss | 仓位止损 |
moving_plan | 移动止盈止损 |
track_plan | 追踪委托 |
holdSide(持仓方向)
字段 | 说明 |
---|---|
long | 多仓 |
short | 空仓 |
marginMode(仓位模式)
字段 | 说明 |
---|---|
fixed | 逐仓 |
crossed | 全仓 |
holdMode(持仓模式)
字段 | 说明 |
---|---|
single_hold | 单向持仓 |
double_hold | 双向持仓 |
planStatus(计划委托状态)
字段 | 说明 |
---|---|
no_trigger | 未触发 |
triggered | 已触发 |
fail_trigger | 触发失败 |
cancel | 已撤销 |
productType(产品线类型)
字段 | 说明 |
---|---|
umcbl | USDT专业合约 |
dmcbl | 混合合约 |
cmcbl | USDC专业合约 |
sumcbl | USDT专业合约模拟盘 |
sdmcbl | 混合合约模拟盘 |
scmcbl | USDC专业合约模拟盘 |
state(订单状态)
字段 | 说明 |
---|---|
init | 初始订单,插入DB成功 |
new | 新建订单,orderbook中等待撮合 |
partially_filled | 部分成交 |
filled | 全部成交 |
canceled | 已撤销 |
isPlan(获取计划委托类型)
字段 | 说明 |
---|---|
plan | 计划委托 |
profit_loss | 止盈止损 |
granularity(K线类别)
- 1min(1分钟)
- 5min(5分钟)
- 15min(15分钟)
- 30min(30分钟)
- 1h(1小时)
- 4h(4小时)
- 6h(6小时)
- 12h(12小时)
- 1day(1天)
- 3day (3天)
- 1week(1周)
- 1M (月线)
- 6Hutc (零时区 6小时线)
- 12Hutc (零时区12小时线)
- 1Dutc (零时区 1日线)
- 3Dutc (零时区 3日线)
- 1Wutc (零时区 周线)
- 1Mutc (零时区 月线)
老分类,不建议再使用
- 60(1minute)
- 300(5minute)
- 900(15minute)
- 1800(30minute)
- 3600(1hour)
- 14400(4hour)
- 43200(12hour)
- 86400(1day)
- 604800(1week)
Websocket planType
- pl: 默认值, 当新增/撤消/修改/触发计划委托时推送
- tp: 部分止盈, 当新增/撤消/修改/触发部分止盈止损时推送
- sl: 部分止损, 当新增/撤消/修改/触发部分止盈止损时推送
- ptp: 仓位止盈, 当新增/撤消/修改/触发仓位止盈止损时推送
- psl: 仓位止损, 当新增/撤消/修改/触发仓位止盈止损时推送
symbolStatus
- normal 正常
- maintain 维护
- off 下架
enterPointSource
Words | Description |
---|---|
WEB | 自Web端创建的订单 |
API | 自API端创建的订单 |
SYS | 系统托管订单, 通常由强制平仓逻辑生成 |
ANDROID | 自Android系统端创建的订单 |
IOS | 自IOS系统端创建的订单 |
RestAPI
行情接口
合约信息接口
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/contracts
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/contracts?productType=umcbl"
返回数据
{
"code": "00000",
"data": [
{
"baseCoin": "BTC",
"buyLimitPriceRatio": "0.01",
"feeRateUpRatio": "0.005",
"makerFeeRate": "0.0002",
"minTradeNum": "0.001",
"openCostUpRatio": "0.01",
"priceEndStep": "5",
"pricePlace": "1",
"quoteCoin": "USDT",
"sellLimitPriceRatio": "0.01",
"sizeMultiplier": "0.001",
"supportMarginCoins": [
"USDT"
],
"symbol": "BTCUSDT_UMCBL",
"takerFeeRate": "0.0006",
"volumePlace": "3",
"symbolType":"delivery",
"symbolStatus": "normal",
"offTime": "-1",
"limitOpenTime": "-1"
}
],
"msg": "success",
"requestTime": 1627114525850
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 产品id |
symbolName | 产品名称 |
baseCoin | 左币 |
quoteCoin | 右币 |
buyLimitPriceRatio | 买价限价比例 |
sellLimitPriceRatio | 卖价限价比例 |
feeRateUpRatio | 手续费上浮比例 |
makerFeeRate | market手续费率 |
takerFeeRate | taker手续费率 |
openCostUpRatio | 开仓成本上浮比例 |
supportMarginCoins | 支持保证金币种 |
minTradeNum | 最小开单数量(左币) |
priceEndStep | 价格步长 |
volumePlace | 数量小数位 |
pricePlace | 价格小数位 |
sizeMultiplier | 数量乘数 下单数量要大于 minTradeNum 并且满足 sizeMultiplier 的倍数 |
symbolType | 合约类型 perpetual 永续 delivery交割 |
symbolStatus | Symbol Status |
offTime | 下架时间, '-1' 表示正常 |
limitOpenTime | 限制开仓时间, '-1' 表示正常; 其它值表示symbol正在/计划维护,指定时间后禁止交易 |
深度行情接口
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/depth
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
limit | String | 否 | 深度档位 100,5 15 50 100 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/depth?symbol=BTCUSDT_UMCBL&limit=100"
返回数据
{
"code":"00000",
"data":{
"asks":[
[
"30002",
"0.2300000000000000"
],
[
"30002.5",
"0.91"
],
[
"30003",
"0.18"
]
],
"bids":[
[
"29987",
"0.28"
],
[
"300",
"0.3333000000000000"
]
],
"timestamp":"1627115809358"
},
"msg":"success",
"requestTime":1627115809358
}
返回的量价数值可能用科学计数法表示
["1.937E+4","156.814"]
["0.000010934","1.2224E+8"]
请调整您的代码以处理用科学计数法表示的返回值
单个Ticker行情获取
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/ticker
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/ticker?symbol=BTCUSDT_UMCBL"
返回数据
{
"code": "00000",
"msg": "success",
"data": {
"symbol": "BTCUSDT_UMCBL",
"last": "23990.5",
"bestAsk": "23991",
"bestBid": "23989.5",
"bidSz": "2.154",
"askSz": "176.623",
"high24h": "24131.5",
"low24h": "23660.5",
"timestamp": "1660705778888",
"priceChangePercent": "0.00442",
"baseVolume": "156243.358",
"quoteVolume": "3735854069.908",
"usdtVolume": "3735854069.908",
"openUtc": "23841.5",
"chgUtc": "0.00625",
"indexPrice": "22381.253737",
"fundingRate": "0.000072",
"holdingAmount": "85862.241"
}
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
last | 最新价 |
bestAsk | 卖一价 |
bestBid | 买一价 |
bidSz | 买一量 |
askSz | 卖一量 |
high24h | 24小时最高价 |
low24h | 24小时最低价 |
timestamp | 时间戳(毫秒) |
priceChangePercent | 价格涨跌幅(24小时) |
baseVolume | 交易币交易量 |
quoteVolume | 计价币交易量 |
usdtVolume | usdt成交量 |
openUtc | UTC0 开盘价 |
chgUtc | UTC0 24小时涨跌幅 |
indexPrice | 指数价格 |
fundingRate | 资金费率 |
holdingAmount | 当前持仓, 单位是base coin |
全部Ticker行情获取
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/tickers
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/tickers?productType=umcbl"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 0,
"data": [{
"symbol": "BTCUSDT_UMCBL",
"last": "23990.5",
"bestAsk": "23991",
"bestBid": "23989.5",
"bidSz": "2.154",
"askSz": "176.623",
"high24h": "24131.5",
"low24h": "23660.5",
"timestamp": "1660705778888",
"priceChangePercent": "0.00442",
"baseVolume": "156243.358",
"quoteVolume": "3735854069.908",
"usdtVolume": "3735854069.908",
"openUtc": "23841.5",
"chgUtc": "0.00625",
"indexPrice": "22381.253737",
"fundingRate": "0.000072",
"holdingAmount": "85862.241"
}]
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 必须大写 |
last | 最新价 |
bestAsk | 卖一价 |
bestBid | 买一价 |
bidSz | 买一量 |
askSz | 卖一量 |
high24h | 24小时最高价 |
low24h | 24小时最低价 |
timestamp | 时间戳(毫秒) |
priceChangePercent | 价格涨跌幅(24小时) |
baseVolume | 交易币交易量 |
quoteVolume | 计价币交易量 |
usdtVolume | usdt成交量 |
openUtc | UTC0 开盘价 |
chgUtc | UTC0 24小时价格涨跌幅 |
indexPrice | 指数价格 |
fundingRate | 资金费率 |
holdingAmount | 当前持仓, 单位是base coin |
VIP费率
限速规则:10次/1s
HTTP请求
获取VIP费率数据
- GET /api/mix/v1/market/contract-vip-level
请求示例
curl "https://api.bitget.com/api/mix/v1/market/contract-vip-level"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 1676254232207,
"data": [
{
"level": 1,
"dealAmount": "1000000",
"assetAmount": "50000",
"takerFeeRate": "0.000475",
"makerFeeRate": "0.00006",
"withdrawAmount": "300",
"withdrawAmountUSDT": "5000000"
}
]
}
返回值说明
参数名 | 参数类型 | 是否必须 | 字段说明 |
---|---|---|---|
level | Integer | Yes | VIP等级 |
dealAmount | BigDecimal | Yes | 近30日累计成交额,USDT |
assetAmount | BigDecimal | Yes | 资产总额,USDT |
takerFeeRate | BigDecimal | Yes | taker费率, '0.000425' 表示 万4.25 |
makerFeeRate | BigDecimal | Yes | maker费率, '0.00006' 表示 万0.6 |
withdrawAmount | BigDecimal | Yes | 24小时提币限额 (BTC) |
withdrawAmountUSDT | BigDecimal | Yes | 24小时提币限额 (USDT) |
获取最近成交明细
获取最近100条成交记录
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/fills
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
limit | String | 否 | 查询条数 默认100 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/fills?symbol=BTCUSDT_UMCBL&limit=100"
返回数据
{
"code":"00000",
"data":[
{
"tradeId":"802751431994691585",
"price":"29990.5",
"size":"0.0166",
"side":"sell",
"timestamp":"1627116776464",
"symbol":"BTCUSDT_UMCBL"
},
{
"tradeId":"802750695521046529",
"price":"30007.0",
"size":"0.0166",
"side":"buy",
"timestamp":"1627116600875",
"symbol":"BTCUSDT_UMCBL"
}
],
"msg":"success",
"requestTime":1627116936176
}
返回值说明
返回字段 | 字段说明 |
---|---|
tradeId | tradeId |
price | 价格 |
size | 数量 |
side | 交易方向 |
timestamp | 时间,ms |
symbol | 币对名称 |
获取成交明细
限速规则: 10次/1s (IP)
HTTP请求
获取近30天成交数据,数据会按请求参数缓存10分钟,请修改endTime以获取最近的成交记录
- GET /api/mix/v1/market/fills-history
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
limit | String | 否 | 查询条数 默认500, 最大1000 |
tradeId | String | 否 | 交易ID, 返回小于给定值的记录 |
startTime | String | 否 | 开始时间, ms |
endTime | String | 否 | 结束时间, ms |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/fills-history?symbol=BTCUSDT_UMCBL&limit=12&tradeId=1020224189048217601&startTime&endTime"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 0,
"data": [
{
"tradeId": "1020224187601182723",
"price": "21341",
"size": "23.296",
"side": "Buy",
"timestamp": "1678966321000",
"symbol": "BTCUSDT_UMCBL"
},
{
"tradeId": "1020224187055923213",
"price": "21341",
"size": "0.804",
"side": "Sell",
"timestamp": "1678966321000",
"symbol": "BTCUSDT_UMCBL"
}
]
}
返回值说明
返回字段 | 字段说明 |
---|---|
tradeId | tradeId, 降序排列 |
price | 价格 |
size | 数量, base coin |
side | 交易方向, Sell/Buy |
timestamp | 时间,ms |
symbol | 币对名称 |
获取K线数据
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/candles
支持‘1m’查询30天内的数据,默认返回100条记录
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
granularity | String | 是 | k线类别 |
startTime | String | 是 | 开始时间(时间戳毫秒,大于等于),根据granularity向下取整, 即granularity=1m时: 1672410799436(2022-12-30 22:33:19) 向下取整为 1672410780000 (2022-12-30 22:33:00) |
endTime | String | 是 | 结束时间(时间戳毫秒,小于等于),根据granularity向下取整, 即granularity=1m时: 1672410799436(2022-12-30 22:33:19) 向下取整为 1672408800000 (2022-12-30 22:00:00) |
limit | String | 否 | 默认 100, 最大 1000 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/candles?symbol=BTCUSDT_UMCBL&granularity=300&startTime=1659406928000&endTime=1659410528000"
返回数据
[
[
"1627008780000",
"24016",
"24016",
"24016",
"24016",
"0",
"0"
],
[
"1627008840000",
"24016",
"24016",
"24016",
"24016",
"0",
"0"
]
]
返回值说明
返回字段 | Index |
---|---|
时间戳 | 0 |
开盘价 | 1 |
最高价 | 2 |
最低价 | 3 |
收盘价,最新一个收盘价可能还在持续更新,请订阅websocket跟踪最新价 | 4 |
交易币成交量 | 5 |
计价币成交量 | 6 |
granularity(candles interval)
- 1m(1minute)
- 3m(3minute)
- 5m(5minute)
- 15m(15minute)
- 30m(30minute)
- 1H(1hour)
- 2H (2hour)
- 4H (4hour)
- 6H (6hour)
- 12H (12hour)
- 1D (1day)
- 3D (3day)
- 1W(1week)
- 1M (1month)
- 6Hutc (UTC0 6hour)
- 12Hutc (UTC0 12hour)
- 1Dutc (UTC0 1day)
- 3Dutc (UTC0 3day)
- 1Wutc (UTC0 1 week)
- 1Mutc (UTC0 1 month)
获取币种指数
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/index
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/index?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"index":"35000",
"timestamp":"1627291836179"
},
"msg":"success",
"requestTime":1627291836179
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
index | 指数价格 |
timestamp | 时间戳 |
获取合约下一次结算时间
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/funding-time
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/funding-time?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"fundingTime":"1627311600000"
},
"msg":"success",
"requestTime":1627291915767
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
fundingTime | 下次结算时间 |
获取历史资金费率
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/history-fundRate
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
pageSize | int | 否 | 查询条数 默认20 |
pageNo | Int | 否 | 页码 |
nextPage | Boolean | 否 | 是否查询下一页 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/history-fundRate?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":[
{
"symbol":"BTCUSDT",
"fundingRate":"0",
"settleTime":"1627369200000"
}
],
"msg":"success",
"requestTime":1627389063463
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
fundingRate | 资金费率 |
settleTime | 结算时间 |
获取当前资金费率
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/current-fundRate
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/current-fundRate?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"fundingRate":"0.0002"
},
"msg":"success",
"requestTime":1627291969594
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
fundingRate | 当前资金费率 |
获取平台总持仓量
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/open-interest
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/open-interest?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"amount":"757.8338",
"timestamp":"1627292005913"
},
"msg":"success",
"requestTime":1627292005913
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
amount | 平台总持仓量 |
timsetamp | 时间戳(毫秒) |
获取合约标记价格
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/mark-price
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/mark-price?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"markPrice":"35000",
"timestamp":"1627292076687"
},
"msg":"success",
"requestTime":1627292076687
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
markPrice | 标记价格 |
timsetamp | 时间戳(毫秒) |
获取交易对支持的杠杆
限速规则: 20次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/symbol-leverage
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/symbol-leverage?symbol=BTCUSDT_UMCBL"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"minLeverage":"1",
"maxLeverage":"125"
},
"msg":"success",
"requestTime":1627292076687
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
minLeverage | 最小杠杆 |
maxLeverage | 最大杠杆 |
获取仓位档位梯度配置
限速规则: 10次/1s (IP)
HTTP请求
- GET /api/mix/v1/market/queryPositionLever
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
symbol | String | 是 | 币对ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/market/queryPositionLever?symbol=BTCUSDT_UMCBL&productType=UMCBL"
返回数据
{
"code":"00000",
"data":[
{
"level": 1,
"startUnit": 0,
"endUnit": 150000,
"leverage": 125,
"keepMarginRate": "0.004"
}
],
"msg":"success",
"requestTime":1627292076687
}
返回值说明
返回字段 | 字段说明 |
---|---|
level | 阶梯档位 |
startUnit | 价值下限 |
endUnit | 价值上限 |
leverage | 杠杆倍数 |
keepMarginRate | 维持保证金率,持仓档位对应的数值,当仓位的保证金率小于维持保证金率时,将会触发强制减仓或爆仓 |
账户接口
单个币种账户信息
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/account/account
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 |
请求示例
curl "https://api.bitget.com/api/mix/v1/account/account?symbol=BTCUSDT_UMCBL&marginCoin=USDT" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"marginCoin":"USDT",
"locked":0,
"available":13168.86110692,
"crossMaxAvailable":13168.86110692,
"fixedMaxAvailable":13168.86110692,
"maxTransferOut":13168.86110692,
"equity":13178.86110692,
"usdtEquity":13178.861106922,
"btcEquity":0.344746495477,
"crossRiskRate":0,
"crossMarginLeverage":20,
"fixedLongLeverage":20,
"fixedShortLeverage":20,
"marginMode":"crossed",
"holdMode":"double_hold",
"unrealizedPL": null,
"bonus": "0"
},
"msg":"success",
"requestTime":1627292199523
}
返回值说明
返回字段 | 字段说明 |
---|---|
marginCoin | 保证金币种 |
locked | 锁定数量(保证金币种),有平仓单时会lock |
available | 账户可用数量 |
crossMaxAvailable | 全仓最大可用来开仓余额(保证金币种) |
fixedMaxAvailable | 逐仓最大可用来开仓余额(保证金币种) |
maxTransferOut | 最大可转出 |
equity | 账户权益(保证金币种) |
usdtEquity | 折算USDT账户权益 |
btcEquity | 折算BTC账户权益 |
crossRiskRate | 全仓时风险率 |
crossMarginLeverage | 全仓时杠杆倍数 |
fixedLongLeverage | 逐仓时多头杠杆 |
fixedShortLeverage | 逐仓时空头杠杆 |
marginMode | 保证金模式 |
holdMode | 持仓模式 |
unrealizedPL | 未实现盈亏 |
bonus | 体验金 |
获取账户信息列表
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/account/accounts
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
请求示例
curl "https://api.bitget.com/api/mix/v1/account/accounts?productType=umcbl" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"marginCoin":"USDT",
"locked":"0.31876482",
"available":"10575.26735771",
"crossMaxAvailable":"10580.56434289",
"fixedMaxAvailable":"10580.56434289",
"maxTransferOut":"10572.92904289",
"equity":"10582.90265771",
"usdtEquity":"10582.902657719473",
"btcEquity":"0.204885807029",
"crossRiskRate": "0",
"unrealizedPL": null,
"bonus": "0"
}
],
"msg":"success",
"requestTime":1630901215622
}
返回值说明
返回字段 | 字段说明 |
---|---|
marginCoin | 保证金币种 |
locked | 锁定数量(保证金币种) |
available | 账户可用数量 |
crossMaxAvailable | 全仓最大可用来开仓余额(保证金币种) |
fixedMaxAvailable | 逐仓最大可用来开仓余额(保证金币种) |
maxTransferOut | 最大可转出 |
equity | 账户权益(保证金币种) |
usdtEquity | 折算USDT账户权益 |
btcEquity | 折算BTC账户权益 |
crossRiskRate | 全仓时风险率 |
unrealizedPL | 未实现盈亏 |
bonus | 体验金 |
获取所有子账户合约资产信息
限速规则: 1次/10s (uid)
HTTP请求
- POST /api/mix/v1/account/sub-account-contract-assets
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/sub-account-contract-assets" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"productType": "umcbl"}'
返回数据
{
"code":"00000",
"data":[
{
"userId": 4351550450,
"contractAssetsList": [
{
"marginCoin": "USDT",
"locked": "0",
"available": "23.123",
"crossMaxAvailable": "23.123",
"fixedMaxAvailable": "23.123",
"maxTransferOut": "23.123",
"equity": "23.123",
"usdtEquity": "23.123",
"btcEquity": "0.001403612744",
"unrealizedPL": "0",
"bonus": null
}
]
},
{
"userId": 9465254769,
"contractAssetsList": [
{
"marginCoin": "USDT",
"locked": "0",
"available": "11",
"crossMaxAvailable": "11",
"fixedMaxAvailable": "11",
"maxTransferOut": "11",
"equity": "11",
"usdtEquity": "11",
"btcEquity": "0.000667722189",
"unrealizedPL": "0",
"bonus": null
}
]
}
],
"msg":"success",
"requestTime":1630901215622
}
返回值说明
返回字段 | 字段说明 |
---|---|
marginCoin | 保证金币种 |
locked | 锁定数量(保证金币种) |
available | 账户可用数量 |
crossMaxAvailable | 全仓最大可用来开仓余额(保证金币种) |
fixedMaxAvailable | 逐仓最大可用来开仓余额(保证金币种) |
maxTransferOut | 最大可转出 |
equity | 账户权益(保证金币种) |
usdtEquity | 折算USDT账户权益 |
btcEquity | 折算BTC账户权益 |
unrealizedPL | 未平仓损益 |
bonus | 体验金 |
获取可开数量
限速规则: 20次/1s (IP)
此接口只是默认用户没有持仓时,来计算能开仓的最大可开数量,结果并不代表实际开仓数量
HTTP请求
- POST /api/mix/v1/account/open-count
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 |
openPrice | BigDecimal | 是 | 开仓价格 |
leverage | BigDecimal | 否 | 杠杆倍数默认20 |
openAmount | BigDecimal | 是 | 开仓金额 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/open-count" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","openPrice": "23189.5","leverage": "20","openAmount":"5000"}'
返回数据
{
"code":"00000",
"data":{
"openCount":"2000"
},
"msg":"success",
"requestTime":1627293049406
}
调整杠杆
限速规则: 5次/1s (uid)
HTTP请求
- POST /api/mix/v1/account/setLeverage
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
leverage | String | 是 | 杠杆倍数 |
holdSide | String | 否 | 持仓方向(全仓不传) |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/setLeverage" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","leverage": "20"}'
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"marginCoin":"USDT",
"longLeverage":25,
"shortLeverage":20,
"marginMode":"crossed"
},
"msg":"success",
"requestTime":1627293049406
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
marginCoin | 保证金币种 |
longLeverage | 多仓杠杆 |
shortLeveage | 空仓杠杆 |
marginMode | 保证金模式 |
- holdSide
- long 多仓
- short 空仓
调整保证金
限速规则: 5次/1s (uid)
全仓时, 保证金不能调整
HTTP请求
- POST /api/mix/v1/account/setMargin
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
holdSide | String | 否 | 持仓方向(全仓不传) |
amount | String | 是 | 保证金金额 正增加 负减少 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/setMargin" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","amount": "-10"}'
返回数据
{
"code":"00000",
"data":{
"result":true
},
"msg":"success",
"requestTime":1627293357336
}
holdSide
- long 多仓
- short 空仓
调节保证金模式
限速规则: 5次/1s (uid)
HTTP请求
- POST /api/mix/v1/account/setMarginMode
请求参数(Request Body)
有持仓或委托时不能调用本接口
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
marginMode | String | 是 | 保证金模式 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/setMarginMode" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","marginMode": "corssed"}'
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"marginCoin":"USDT",
"longLeverage":25,
"shortLeverage":20,
"marginMode":"corssed"
},
"msg":"success",
"requestTime":1627293445916
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
marginCoin | 保证金币种 |
longLeverage | 多仓杠杆 |
shortLeveage | 空仓杠杆 |
marginMode | 保证金模式 |
- marginMode
- fixed 逐仓模式
- crossed 全仓模式
调节单双向持仓模式
注意:产品类型下有仓位/委托时不能调整持仓模式
限速规则: 5次/1s (uid)
HTTP请求
- POST /api/mix/v1/account/setPositionMode
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
holdMode | String | 是 | 单双向持仓模式:"single_hold"或"double_hold" |
指定productType任意币对任意side存在仓位/委托的情况下,请求会失败
{
"code": "40920",
"msg": "Currently holding a position, the position mode cannot be switched",
"requestTime": 1675335833730,
"data": null
}
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/account/setPositionMode" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"productType": "umcbl","holdMode": "double_hold"}'
返回数据
{
"code":"00000",
"msg":"success",
"data":{
"symbol":"BTCUSDT_UMCBL",
"marginCoin":"USDT",
"dualSidePosition":true
},
"requestTime":1627293445916
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
marginCoin | 保证金币种 |
dualSidePosition | boolean, true: 双向持仓; false: 单向持仓 |
获取单个合约仓位信息
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/position/singlePosition
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 否 | 保证金币种 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/position/singlePosition?symbol=BTCUSDT_UMCBL&marginCoin=USDT" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"marginCoin":"USDT",
"symbol":"BTCUSDT_UMCBL",
"holdSide":"long",
"openDelegateCount":"0",
"margin":"10",
"available":"0",
"locked":"0",
"total":"0",
"leverage":25,
"achievedProfits":"0",
"averageOpenPrice":"0",
"marginMode":"fixed",
"holdMode":"double_hold",
"unrealizedPL":"0",
"marketPrice":"0",
"keepMarginRate":"0.0015",
"cTime":"1626232130664"
}
],
"msg":"success",
"requestTime":1627293612502
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
marginCoin | 保证金币种 |
holdSide | 持仓方向 |
openDelegateCount | 当前委托待成交的数量(交易币) |
margin | 保证金数量 (保证金币种) |
available | 仓位可用(计价币) |
locked | 仓位冻结(计价币) |
total | 仓位总数量(available + locked) |
leverage | 杠杆倍数 |
achievedProfits | 已实现盈亏 |
averageOpenPrice | 平均开仓价 |
marginMode | 保证金模式 |
holdMode | 持仓模式 |
unrealizedPL | 未实现盈亏 |
keepMarginRate | 维持保证金率 |
marketPrice | 标记价格 |
cTime | 最近更新时间 时间戳 毫秒 |
获取全部合约仓位信息
限速规则: 5次/1s (uid)
HTTP请求
- GET /api/mix/v1/position/allPosition
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
marginCoin | String | 否 | 保证金币种 必须大写 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/position/allPosition?productType=umcbl&marginCoin=USDT" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"marginCoin":"USDT",
"symbol":"BTCUSDT_UMCBL",
"holdSide":"long",
"openDelegateCount":"0",
"margin":"10",
"available":"0",
"locked":"0",
"total":"0",
"leverage":25,
"achievedProfits":"0",
"averageOpenPrice":"0",
"marginMode":"fixed",
"holdMode":"double_hold",
"unrealizedPL":"0",
"keepMarginRate":"0.0015",
"marketPrice":"0",
"cTime":"1626232130664"
}
],
"msg":"success",
"requestTime":1627293612502
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 币对名称 |
marginCoin | 保证金币种 |
holdSide | 持仓方向 |
openDelegateCount | 当前委托待成交的数量(交易币) |
margin | 保证金数量 (保证金币种) |
available | 仓位可用(计价币) |
locked | 仓位冻结(计价币) |
total | 仓位总数量(available + locked) |
leverage | 杠杆倍数 |
achievedProfits | 已实现盈亏 |
averageOpenPrice | 平均开仓价 |
marginMode | 保证金模式 |
holdMode | 持仓模式 |
unrealizedPL | 未实现盈亏 |
keepMarginRate | 维持保证金率 |
marketPrice | 标记价格 |
cTime | 最近更新时间 时间戳 毫秒 |
获取财务记录
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/account/accountBill
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
startTime | String | 是 | 开始时间 (时间戳毫秒) |
endTime | String | 是 | 结束时间 (时间戳毫秒) |
pageSize | int | 否 | 显示条数 默认20 最大 100 |
lastEndId | String | 否 | 上次查询的id |
next | boolean | 否 | 是否查询下一页 默认false |
请求示例
curl "https://api.bitget.com/api/mix/v1/account/accountBill?symbol=BTCUSDT_UMCBL&marginCoin=USDT&startTime=1659403328000&endTime=1659406928000&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code": "00000",
"msg": "success",
"data": {
"result": [
{
"id": "892962903462432768",
"symbol": "BTCUSDT_UMCBL",
"marginCoin": "USDT",
"amount": "0",
"fee": "-0.1765104",
"feeByCoupon": "",
"feeCoin": "USDT",
"business": "open_long",
"ctime": "1648624867354"
}
],
"endId": "885353495773458432",
"nextFlag": false,
"preFlag": false
}
}
返回值说明
返回字段 | 字段说明 |
---|---|
id | 财务记录号 |
symbol | 产品Id |
marginCoin | 保证金币种 |
amount | 金额 |
fee | 手续费 |
feeByCoupon | 手续费抵扣 |
feeCoin | 手续费币种 |
business | 记录类型 |
cTime | 创建时间 |
lastEndId | 上次查询的Id |
获取业务线财务记录
限速规则: 5次/1s (uid)
HTTP请求
- GET /api/mix/v1/account/accountBusinessBill
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
startTime | String | 是 | 开始时间 (时间戳毫秒) |
endTime | String | 是 | 结束时间 (时间戳毫秒) |
pageSize | int | 否 | 显示条数 默认20 最大 100 |
lastEndId | String | 否 | 上次查询的id |
next | boolean | 否 | 是否查询下一页 默认false |
请求示例
curl "https://api.bitget.com/api/mix/v1/account/accountBusinessBill?productType=umcbl&startTime=1659403328000&endTime=1659406928000&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code": "00000",
"msg": "success",
"data": {
"result": [
{
"id": "892962903462432768",
"symbol": "ETHUSDT_UMCBL",
"marginCoin": "USDT",
"amount": "0",
"fee": "-0.1765104",
"feeByCoupon": "",
"feeCoin": "USDT",
"business": "open_long",
"ctime": "1648624867354"
}
],
"endId": "885353495773458432",
"nextFlag": false,
"preFlag": false
}
}
返回值说明
返回字段 | 字段说明 |
---|---|
id | 财务记录号 |
symbol | 产品Id |
marginCoin | 保证金币种 |
amount | 金额 |
fee | 手续费 |
feeByCoupon | 手续费抵扣 |
feeCoin | 手续费币种 |
business | 记录类型 |
cTime | 创建时间 |
lastEndId | 上次查询的Id |
交易接口
下单
限速规则: 10次/1s (uid)
交易员限速规则: 1次/1s (uid)
如果你是交易员只能使用此接口进行开仓, 平仓操作需要调用 跟单接口
-> 交易员平仓接口
下单的价格和数量需要满足 pricePlace
和 priceEndStep
volumePlace
sizeMultiplier
minTradeNum
, 此字段从 行情接口
-> 合约信息接口
举例说明:
BTCUSDT_UMCBL
的 pricePlace
为 1 , priceEndStep
为 5, 则下单时委托的价格需要满足 0.5的倍数, 比如价格应该是 23455.0, 23455.5, 23446.0
volumePlace
是数量小数位, minTradeNum
是最小下单数量, sizeMultiplier
是数量乘数,下单数量要满足 大于minTradeNum
并且满足 sizeMultiplier
的倍数
会有两种情况出现此错误,
- 账户余额不足
- 当前交易对当前杠杆仓位梯度已满,具体仓位梯度请参考 这里
平仓常见异常:
可能的原因有两个
- 仓位为0
- 仓位不为0,但平仓时指定的side错误,如当前持多仓,但平仓指令side=close_short
特别地,当平仓时指定的size大于持仓size时,下单会成功,持仓仓位会全平,即:只减仓,不会反向开仓。
示例:
- 您持有 1.0 个 BTCUSDT 多仓
- 尝试以市场价(Market Price)平多 2.0个 BTCUSDT
- 下单接口会返回成功,但是从Websocket的订单(
orders
)频道将收到一个基础币数额 size = 1 的消息推送,而非 size = 2
未知错误
HTTP请求
- POST /api/mix/v1/order/placeOrder
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
size | String | 是 | 下单数量,base coin |
price | String | 否 | 下单价格(市价时不传) |
side | String | 是 | 开单方向 |
orderType | String | 是 | 订单类型 limit/market |
timeInForceValue | String | 否 | 订单有效期 |
clientOid | String | 否 | 客户端标识 唯一 |
reduceOnly | Boolean | 否 | 默认false; 只减仓,单项持仓平仓时仓位价值小于5USDT则需要设置为true, 双向持仓时不生效 |
presetTakeProfitPrice | String | 否 | 预设止盈价格 |
presetStopLossPrice | String | 否 | 预设止损价格 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/placeOrder" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","size": "0.01","price": "23145.5","side":"open_long","orderType":"limit","timeInForceValue":"normal","clientOid":"test@483939290000"}'
返回数据
{
"code":"00000",
"data":{
"orderId":"1627293504612",
"clientOid":"BITGET#1627293504612"
},
"msg":"success",
"requestTime":1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单Id |
clientOid | 客户端自定义Id |
如果客户端没有传递 clientOid 字段,需要提醒用户注意订单可能会重复。因为这个字段是客户端和服务器之间唯一的幂等承诺字段。
clientOid重复时响应示例
{
"code":"40786",
"msg":"Duplicate clientOid",
"requestTime":1627293504612
}
- side
- open_long
- open_short
- close_long
- close_short
- buy_single
- sell_single
- timeInForceValue
- normal 成交为止 订单会一直有效,直到被成交或者取消。
- post_only 只做marker
- fok 无法全部立即成交就撤销
- ioc 无法立即成交的部分就撤销
- orderType
- limit
- market
一键反手
限速规则: 10次/1s (uid) - 与下单共同计算频率
单/双向持仓模式下的反手逻辑是不同的:
双向持仓模式:
)通常需要指定size(size值介于0和position size之间), 指定的size会市价平仓,并在反向市价开仓
2)side值:close_short 或 close_long
单向持仓模式:
1)size参数会被忽略,此时只能市价全平,然后按同样数量的size反向市价开仓,注意开仓可能会因保证金不足而失败
2)side值:原仓位是 sell_single 则反手时设置为 buy_single;原仓位是buy_single则反手时设置为sell_single
反手操作:已有仓位会市价平仓,然后在反向开同样数量的仓位。
如果平仓的结算金额+可用余额不足以开到指定的反向仓位,或者在开仓时仓位价值不足5U,则市价平仓成功,开仓失败;
反手操作可能因 保证金,市场波动或其它原因失败。
你必须在已持仓的情况下进行反手操作,否则服务器会返回:"可用仓位不足"
Not enough position
{
"code": "40757",
"msg": "可用仓位不足",
"requestTime": 1665454799692,
"data": null
}
反手的size参数通常应设置为原持仓的1倍。例如:原仓位数量为100, 反手下单时应将size设置为100,服务器会平仓100,然后反向市价开仓100
- 反手 - 1倍size
- [反手下单的size] = [市价平仓size] = [反向市价开仓size]
- 原持仓:1 long BTCUSDT
- 反手size: 1 close_long BTCUSDT
- 理想状态下,原持仓1 long BTCUSDT 会市价平仓,反手市价1 short BTCUSDT 开仓
反手的size可以设置为超过原持仓数量的1.5倍甚至3倍或更多,但反手行为和1倍size时一致:服务器会先行市价平仓,然后根据客户的保证金状况进行反向市价建仓,开仓仓位数量和原持仓数量一致(即反手的size超过原持仓1倍的,按1倍处理)
- 反手 - 1.5倍size
- 原持仓:1 long BTCUSDT
- 反手size: 1.50 close_long BTCUSDT
- 理想状态下,原持仓1 long BTCUSDT 会市价平仓,反手市价1 short BTCUSDT 开仓
特别地:反手的size也可以设置为原持仓数量的0倍至1倍之间,假设反手指定0.5倍原持仓size,反手行为则有所不同:服务器会先行市价平多0.5倍的仓位,然后根据客户的保证金状况进行反向市价建仓0.5倍
- 反手 - 0.5倍size
- 原持仓:1 long BTCUSDT
- 反手size: 0.5 close_long BTCUSDT
- 理想状态下,原持仓1 long BTCUSDT 会市价平多0.5,变成0.5个Long BTCUSDT;反手市价short开空0.5 BTCUSDT
orderType
必须指定为 market, 限价单limit在反手中会被当做市价处理
原开仓订单参数
{
"size": "100",
"side": "open_long",
"orderType": "market",
"timeInForceValue": "normal",
"symbol": "TRXUSDT_UMCBL",
"marginCoin": "USDT"
}
反手示例
{
"size": "100",
"side": "close_long",
"orderType": "market",
"timeInForceValue": "normal",
"symbol": "TRXUSDT_UMCBL",
"marginCoin": "USDT",
"reverse":true
}
如原持仓方向为open_long, 则反手操作中应设置参数side
为 close_long;
如原持仓方向为open_short, 则反手操作中应设置参数side
为 close_short;
如原持仓方向为buy_single, 则反手操作中应设置参数side
为 sell_single;
如原持仓方向为sell_single, 则反手操作中应设置参数side
为 buy_single;
右边的示例演示了一个反手操作。理想状态下,你最终应该持仓 100 TRXUSDT short
HTTP请求
- POST /api/mix/v1/order/placeOrder
一键反手与下单共享同一个接口
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | Yes | 产品ID 必须大写 |
marginCoin | String | Yes | 保证金币种 必须大写 |
size | String | No | 下单数量=平仓size=反手开仓size, 单向持仓模式下size参数会补充忽略 |
side | String | Yes | 开单方向 双向持仓:close_long 或 close_short;单向持仓:sell_single 或 buy_single |
orderType | String | Yes | 订单类型: market |
clientOid | String | No | 客户端标识 唯一 |
timeInForceValue | String | No | 订单有效期 |
reverse | Boolean | No | 是否反手订单: 不传时默认为false(正常下单操作); true:表示这是反手操作 |
反手请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/placeOrder" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","size": "0.01","side":"open_long","orderType":"market","timeInForceValue":"normal","clientOid":"reverse@483939290002","reverse":true}'
反手返回数据
{
"code":"00000",
"data":{
"orderId":"1627293504612",
"clientOid":"BITGET#1627293504612"
},
"msg":"success",
"requestTime":1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单Id |
clientOid | Client custom Id |
批量下单
限速规则: 10次/1s (uid)
交易员限速规则: 1次/1s (uid)
HTTP请求
- POST /api/mix/v1/order/batch-orders
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
orderDataList | List | 是 | 下单集合,最大长度:50 |
orderDataList
最多50个订单
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
size | String | 是 | 下单数量 |
price | String | 否 | 下单价格 |
type | String | 是 | 开单方向 |
orderType | String | 是 | 订单类型 |
timeInForceValue | String | 否 | 订单有效期 |
clientOid | String | 否 | 客户端标识 唯一 |
presetTakeProfitPrice | String | 否 | 预设止盈价格 |
presetStopLossPrice | String | 否 | 预设止损价格 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/batch-orders" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT", "orderDataList":[{"size": "0.01","price": "23145.5","side":"open_long","orderType":"limit","timeInForceValue":"normal","clientOid":"test@483939290000"}] }'
返回数据
{
"code": "00000",
"data": {
"orderInfo": [
{
"orderId": "1627293504612",
"clientOid": "BITGET#1627293504612"
}
],
"failure":[
{
"orderId": "1627293504611",
"clientOid": "BITGET#1627293504611",
"errorMsg":"Duplicate clientOid"
}
]
},
"msg": "success",
"requestTime": 1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderInfo | 成功下单响应array |
> orderId | 订单Id |
> clientOid | 客户端自定义Id |
failure | 失败下单array |
> orderId | 订单Id |
> clientOid | 客户端自定义Id |
> errorMsg | 错误信息 |
- side
- open_long
- open_short
- close_long
- close_short
timeInForceValue
- normal
- post_only
- fok
- ioc
- normal
orderType
- limit
- market
撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/order/cancel-order
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
orderId | String | 否 | 订单号, int64类型字符串, 'orderId' or 'clientOid' 必需提供一个 |
clientOid | String | 否 | 用户自定义ID, 'orderId' or 'clientOid' 必需提供一个 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/cancel-order" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","orderId":"1627293504612"}'
返回数据
{
"code":"00000",
"data":{
"orderId":"1627293504612",
"clientOid":"BITGET#1627293504612"
},
"msg":"success",
"requestTime":1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单Id |
clientOid | 客户端自定义Id |
批量撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/order/cancel-batch-orders
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
orderIds | List | 是 | 订单号集合 |
orderIds | List | 否 | 订单ID list, 字符串类型的int64, 'orderIds' 或 'clientOids' 必需提供一个 |
clientOids | List | 否 | Client Order Id list, 'orderIds' 或 'clientOids' 必需提供一个 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/cancel-batch-orders" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","orderIds":["1627293504612"]}'
返回数据
{
"code": "00000",
"data": {
"symbol": "BTCUSDT_UMCBL",
"order_ids": [
"1627293504612"
],
"client_order_ids":[
"xxx001"
],
"fail_infos": [
{
"order_id": "",
"err_code": "",
"err_msg": ""
}
]
},
"msg": "success",
"requestTime": 1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 产品ID |
order_ids | 订单号数组 |
client_order_ids | ClientOid 数组 |
fail_infos | 失败信息集合 |
> order_id | 失败单号 |
> err_code | 错误代码 |
> err_msg | 错误消息 |
按symbol撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/order/cancel-symbol-orders
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/cancel-symbol-orders" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT"}'
返回数据
{
"code": "00000",
"data": {
"symbol": "BTCUSDT_UMCBL",
"order_ids": [
"1627293504612"
],
"client_order_ids":[
"xxx001"
],
"fail_infos": [
{
"order_id": "",
"err_code": "",
"err_msg": ""
}
]
},
"msg": "success",
"requestTime": 1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 产品ID |
order_ids | 订单号数组 |
client_order_ids | ClientOid 数组 |
fail_infos | 失败信息集合 |
> order_id | 失败单号 |
> err_code | 错误代码 |
> err_msg | 错误消息 |
一键全撤
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/order/cancel-all-orders
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
marginCoin | String | 是 | 保证金币种 必须大写 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/order/cancel-all-orders" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"productType": "umcbl","marginCoin": "USDT"}'
返回数据
{
"code": "00000",
"data": {
"order_ids": [
"1627293504612"
],
"fail_infos": [
{
"order_id": "",
"err_code": "",
"err_msg": ""
}
]
},
"msg": "success",
"requestTime": 1627293504612
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单Id |
clientOid | 客户端自定义Id |
获取当前委托
限速规则: 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/current
获取一个symbol的当前委托
注意,历史委托请使用 获取历史委托 接口
止盈止损委托请使用 获取当前计划委托(止盈止损)列表 接口
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/current?symbol=BTCUSDT_UMCBL" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"nextFlag":false,
"endId":"802355881591844864",
"orderList":[
{
"symbol":"BTCUSDT_UMCBL",
"size":1,
"orderId":"802382049422487552",
"clientOid":"RFIut#1627028708738",
"filledQty":0,
"fee":0,
"price":23999.3,
"priceAvg": 23999.00,
"state":"filled",
"side":"open_long",
"timeInForce":"normal",
"totalProfits":0,
"posSide":"long",
"marginCoin":"USDT",
"filledAmount": 48.4520,
"leverage": "6",
"marginMode": "fixed",
"reduceOnly": false,
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"orderType":"limit",
"cTime": "1678779464831",
"uTime": "1678779464891"
}
]
},
"msg":"success",
"requestTime":1627299486707
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对名称 |
size | 委托数量 |
orderId | 订单号 |
clientOid | 客户端自定义id |
filledQty | 成交数量,左币 |
fee | 手续费 |
price | 委托价格 |
priceAvg | 平均成交价格 |
state | 订单状态 |
side | 开单方向 |
timeInForce | 订单有效期 |
totalProfits | 总盈亏 |
posSide | 持仓方向 |
marginCoin | 保证金币种 |
filledAmount | 成交金额, 右币 |
leverage | 杠杆倍数 |
marginMode | Margin mode |
reduceOnly | 是否只减仓 |
enterPointSource | enterPointSource |
tradeSide | Trade Side |
holdMode | Hold mode |
orderType | 订单类型 |
cTime | 创建时间 |
uTime | 最近更新时间 |
获取全部当前委托
限速规则: 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/marginCoinCurrent
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
marginCoin | String | 是 | 保证金币种 |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/marginCoinCurrent?productType=umcbl&marginCoin=USDT" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"nextFlag":false,
"endId":"802355881591844864",
"orderList":[
{
"symbol":"BTCUSDT_UMCBL",
"size":1,
"orderId":"802382049422487552",
"clientOid":"RFIut#1627028708738",
"filledQty":0,
"fee":0,
"price":23999.3,
"state":"canceled",
"side":"open_long",
"timeInForce":"normal",
"totalProfits":0,
"posSide":"long",
"marginCoin":"USDT",
"orderType":"limit",
"cTime":1627028708807
}
]
},
"msg":"success",
"requestTime":1627299486707
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对名称 |
size | 委托数量 |
orderId | 订单号 |
clientOid | 客户端自定义id |
filledQty | 成交数量 |
fee | 手续费 |
price | 委托价格 |
state | 订单状态 |
side | 开单方向 |
timeInForce | 订单有效期 |
totalProfits | 总盈亏 |
posSide | 持仓方向 |
marginCoin | 保证金币种 |
orderType | 订单类型 |
cTime | 最近更新时间 |
获取历史委托
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/history
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
startTime | String | 是 | 开始时间(时间戳) |
endTime | String | 是 | 结束时间(时间戳) |
pageSize | String | 是 | 查询条数 |
lastEndId | String | 否 | 上一次的查询orderId |
clientOid | String | 否 | 精确匹配 |
isPre | Boolean | 否 | 是否查询上一页(默认false) |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/history?symbol=BTCUSDT_UMCBL&startTime=1659403328000&endTime=1659410528000&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"nextFlag":false,
"endId":"802355881591844864",
"orderList":[
{
"symbol":"BTCUSDT_UMCBL",
"size":1,
"orderId":"802382049422487552",
"clientOid":"RFIut#1627028708738",
"filledQty":0,
"fee":0,
"price":23999.3,
"priceAvg": 23999.3,
"state":"filled",
"side":"open_long",
"timeInForce":"normal",
"totalProfits":0,
"posSide":"long",
"marginCoin":"USDT",
"filledAmount": 31.4421,
"leverage":"20",
"marginMode":"crossed",
"orderType":"limit",
"reduceOnly": false,
"enterPointSource": "WEB",
"tradeSide": "open_long",
"holdMode": "double_hold",
"cTime": "1665452796883",
"uTime": "1665452797002"
}
]
},
"msg":"success",
"requestTime":1627299486707
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对名称 |
size | 委托数量 |
orderId | 订单号 |
clientOid | 客户端自定义id |
filledQty | 成交数量,左币 |
fee | 手续费 |
price | 委托价格 |
priceAvg | 成交均价 |
state | 订单状态 |
side | 开单方向 |
timeInForce | 订单有效期 |
totalProfits | 总盈亏 |
posSide | 持仓方向 |
marginCoin | 保证金币种 |
filledAmount | 成交金额,右币 |
leverage | 杠杆倍数 |
marginMode | 账户模式 |
orderType | 订单类型 |
reduceOnly | 只减仓 |
enterPointSource | enterPointSource |
tradeSide | 交易方向 |
holdMode | 持仓模式 single_hold 单向持仓,double_hold双向持仓 |
cTime | 创建时间 |
uTime | 更新时间 |
获取全部历史委托
限速规则: 5次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/historyProductType
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
startTime | String | 是 | 开始时间(时间戳) |
endTime | String | 是 | 结束时间(时间戳) |
pageSize | String | 是 | 查询条数, 最大100 |
lastEndId | String | 否 | 上一次的查询orderId |
clientOid | String | 否 | 精确匹配 |
isPre | Boolean | 否 | 是否查询上一页(默认false) |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/historyProductType?productType=umcbl&startTime=1659403328000&endTime=1659410528000&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"nextFlag":false,
"endId":"802355881591844864",
"orderList":[
{
"symbol":"BTCUSDT_UMCBL",
"size":1,
"orderId":"802382049422487552",
"clientOid":"RFIut#1627028708738",
"filledQty":0,
"fee":0,
"price":23999.3,
"state":"canceled",
"side":"open_long",
"timeInForce":"normal",
"totalProfits":0,
"posSide":"long",
"marginCoin":"USDT",
"leverage":"20",
"marginMode":"crossed",
"orderType":"limit",
"reduceOnly": false,
"enterPointSource": "WEB",
"tradeSide": "open_long",
"holdMode": "double_hold",
"cTime": "1665452796883",
"uTime": "1665452797002"
}
]
},
"msg":"success",
"requestTime":1627299486707
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对名称 |
size | 委托数量 |
orderId | 订单号 |
clientOid | 客户端自定义id |
filledQty | 成交数量 |
fee | 手续费 |
price | 委托价格 |
priceAvg | 成交均价 |
state | 订单状态 |
side | 开单方向 |
timeInForce | 订单有效期 |
totalProfits | 总盈亏 |
posSide | 持仓方向 |
marginCoin | 保证金币种 |
leverage | 订单杠杆 |
marginMode | 账户模式 |
orderType | 订单类型 |
reduceOnly | 只减仓 |
enterPointSource | enterPointSource |
tradeSide | 交易方向 |
holdMode | 持仓模式 single_hold 单向持仓,double_hold双向持仓 |
cTime | 创建时间 |
uTime | 更新时间 |
获取订单详情
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/detail
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
orderId | String | 否 | 订单号, int64类型字符串, 'orderId' or 'clientOid' 必需提供一个 |
clientOid | String | 否 | 用户自定义ID, 'orderId' or 'clientOid' 必需提供一个 |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/detail?symbol=BTCUSDT_UMCBL&orderId=802382049422487552" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"symbol":"BTCUSDT_UMCBL",
"size":1,
"orderId":"802382049422487552",
"clientOid":"RFIut#1627028708738",
"filledQty":0,
"priceAvg":0,
"fee":0,
"price":23999.3,
"state":"canceled",
"side":"open_long",
"timeInForce":"normal",
"totalProfits":0,
"posSide":"long",
"marginCoin":"USDT",
"presetTakeProfitPrice":69582.5,
"presetStopLossPrice":21432.5,
"filledAmount":45838,
"orderType":"limit",
"leverage": "6",
"marginMode": "fixed",
"reduceOnly": false,
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"cTime":1627028708807,
"uTime":1627028717807
},
"msg":"success",
"requestTime":1627300098776
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对名称 |
size | 委托数量 |
orderId | 订单号 |
clientOid | 客户端自定义id |
filledQty | 成交数量 |
priceAvg | 成交均价 |
fee | 手续费 |
price | 委托价格 |
state | 订单状态 |
side | 开单方向 |
timeInForce | 订单有效期 |
totalProfits | 总盈亏 |
posSide | 持仓方向 |
marginCoin | 保证金币种 |
presetTakeProfitPrice | 预设止盈价格 |
presetStopLossPrice | 预设止损价格 |
filledAmount | 成交额度 |
orderType | 交易类型 limit 限价 market 市价 |
leverage | 杠杆倍数 |
marginMode | Margin Mode(仓位模式) |
reduceOnly | 是否只减仓 |
enterPointSource | enterPointSource |
tradeSide | 交易方向(交易方向) |
holdMode | Hold mode(持仓模式) |
cTime | 创建时间, ms |
uTime | 更新时间, ms |
查询成交明细
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/fills
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
orderId | String | 否 | 订单号 |
startTime | String | 否 | 开始时间(时间戳毫秒) 如果orderId为空此字段必传 |
endTime | String | 否 | 结束时间(时间戳毫秒) 如果orderId为空此字段必传 |
lastEndId | String | 否 | 分页参数;上一次查询结果的tradeId,orderId为空时生效 |
请求示例
curl "https://api.bitget.com/api/mix/v1/order/fills?symbol=BTCUSDT_UMCBL&orderId=802382049422487552" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"tradeId":"802377534023585793",
"symbol":"BTCUSDT_UMCBL",
"orderId":"802377533381816325",
"price":"0",
"sizeQty":"0.3247",
"fee":"0E-8",
"side":"burst_close_long",
"fillAmount":"0.3247",
"profit":"0E-8",
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"takerMakerFlag": "taker",
"cTime":"1627027632241"
}
],
"msg":"success",
"requestTime":1627386245672
}
返回值说明
返回字段 | 字段说明 |
---|---|
tradeId | 成交id |
symbol | 交易对名称 |
orderId | 订单号 |
price | 成交价格 |
sizeQty | 成交数量 |
fee | 手续费 |
side | 成交类型 |
fillAmount | 成交量 |
profit | 利润 |
enterPointSource | enterPointSource |
tradeSide | 交易方向 |
holdMode | 持仓模式 single_hold 单向持仓,double_hold双向持仓 |
takerMakerFlag | taker |
cTime | 成交时间 |
side
- open_long
- open_short
- close_long
- close_short
- burst_close_long
- burst_close_short
- offset_close_long
- offset_close_short
- open_long
查询业务线成交明细
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/order/allFills
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 umcbl 合约业务 dmcbl 币本位 |
startTime | String | 是 | 开始时间(时间戳毫秒) 如果查询全部明细此字段必传 |
endTime | String | 是 | 结束时间(时间戳毫秒) 如果查询全部明细此字段必传 |
lastEndId | String | 否 | 查询上一次的tradeId |
默认查询100条
请求示例
curl "https://api.bitget.com/api/mix/v1/order/allFills?productType=umcbl&startTime=1659406928000&endTime=1659410528000" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"tradeId":"802377534023585793",
"symbol":"BTCUSDT_UMCBL",
"orderId":"802377533381816325",
"price":"0",
"sizeQty":"0.3247",
"fee":"0E-8",
"side":"burst_close_long",
"fillAmount":"0.3247",
"profit":"0E-8",
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"takerMakerFlag": "taker",
"cTime":"1627027632241"
}
],
"msg":"success",
"requestTime":1627386245672
}
返回值说明
返回字段 | 字段说明 |
---|---|
tradeId | 成交id |
symbol | 交易对名称 |
orderId | 订单号 |
price | 成交价格 |
sizeQty | 成交数量 |
fee | 手续费 |
side | 成交类型 |
fillAmount | 成交量 |
profit | 利润 |
enterPointSource | enterPointSource |
tradeSide | 交易方向 |
holdMode | 持仓模式 single_hold 单向持仓,double_hold双向持仓 |
takerMakerFlag | taker |
cTime | 成交时间 |
- side
- open_long
- open_short
- close_long
- close_short
- burst_close_long
- burst_close_short
- offset_close_long
- offset_close_short
- open_long
计划委托下单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/placePlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 必须大写 |
size | String | 是 | 下单数量 |
executePrice | String | 否 | 执行价格, orderType=limit时, 必填 |
triggerPrice | String | 是 | 触发价格 |
side | String | 是 | 开单方向 |
orderType | String | 是 | 订单类型 |
triggerType | String | 是 | 触发类型 |
clientOid | String | 否 | 客户端标识 唯一 |
presetTakeProfitPrice | String | 否 | 预设止盈价格 |
presetStopLossPrice | String | 否 | 预设止损价格 |
reduceOnly | String | 否 | 默认false; 只减仓,单项持仓平仓时仓位价值小于5USDT则需要设置为true, 双向持仓时不生效 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/placePlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","size": "0.01","executePrice": "23145.5","triggerPrice":"23555.5","side":"open_long","orderType":"limit","timeInForceValue":"normal","triggerType":"market_price","clientOid":"test@483939290000"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
- side
- open_long
- open_short
- close_long
- close_short
- buy_single
- sell_single
timeInForceValue
- normal
- postOnly
- fok
- ioc
- normal
orderType
- limit
- market
triggerType
- fill_price
- market_price
修改计划委托
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/modifyPlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
orderId | String | 否 | 计划委托订单号, 'orderId' 与 'clientOid' 必需提供一个 |
clientOid | String | 否 | 'orderId' 与 'clientOid' 必需提供一个 |
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
executePrice | String | 否 | 执行价格, orderType=limit时, 必填 |
triggerPrice | String | 是 | 触发价格 |
triggerType | String | 是 | 触发类型 |
orderType | String | 是 | 交易类型 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/modifyPlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"orderId":"803521986049314816","symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","executePrice": "23145.5","triggerPrice":"23555.5","orderType":"limit","triggerType":"market_price"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
- orderType
- limit
- market
- triggerType
- fill_price
- market_price
修改计划委托预设止盈止损
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/modifyPlanPreset
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
orderId | String | 否 | 计划委托订单号, 'orderId' 与 'clientOid' 必需提供一个 |
clientOid | String | 否 | 'orderId' 与 'clientOid' 必需提供一个 |
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
presetTakeProfitPrice | String | 否 | 止盈价格 如果为空则取消止盈 |
presetStopLossPrice | String | 否 | 止损价格 如果为空则取消止损 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/modifyPlanPreset" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"orderId":"803521986049314816","symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","presetTakeProfitPrice": "23145.5","presetStopLossPrice":"23555.5"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
止盈止损下单
限速规则: 10次/1s (uid)
目前止盈止损/移动止盈止损下单, 只支持市价, 且触发类型为成交价触发
HTTP请求
- POST /api/mix/v1/plan/placeTPSL
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
planType | String | 是 | 止盈止损类型 planType,请使用"profit_plan"、"loss_plan" and "moving_plan" |
triggerPrice | String | 是 | 触发价格 |
triggerType | String | 否 | 触发类型, fill_price(成交价)/market_price(标记价) 默认成交价 |
holdSide | String | 是 | 本仓位是多仓还是空仓 |
size | String | 否 | 下单数量 默认仓位数量 |
rangeRate | String | 否 | 回调幅度(planType="moving_plan"时使用),“1” 表示 1.0%的价格回调, 最多两位小数 |
clientOid | String | 否 | Client order ID, 幂等控制 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/placeTPSL" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","size": "0.01","planType": "profit_plan","triggerPrice":"23555.5","holdSide":"long"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
- planType
- profit_plan
- loss_plan
- holdSide
- long
- short
追踪委托下单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/placeTrailStop
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
triggerPrice | String | 是 | 触发价格 |
triggerType | String | 否 | 触发类型 fill_price(成交价)/market_price(标记价) 默认成交价 |
side | String | 是 | 开单方向 |
size | String | 是 | 下单数量 不能超过可用仓位数量 |
rangeRate | String | 是 | 回调幅度,planType="moving_plan"时使用;"1" 表示 1.0%的价格回调, 最大10 |
clientOid | String | 否 | Client order ID, 幂等控制 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/placeTrailStop" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","size": "0.01","triggerPrice":"23555.5","side":"open_long","rangeRate":"10"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
仓位止盈止损
限速规则: 10次/1s (uid)
仓位止盈止损触发时默认会以市价委托仓位全部数量
HTTP请求
- POST /api/mix/v1/plan/placePositionsTPSL
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
planType | String | 是 | 仓位止盈止损plan type: 请使用"pos_profit", "pos_loss" |
triggerPrice | String | 是 | 触发价格 |
triggerType | String | 是 | 触发类型 |
holdSide | String | 否 | 本仓位是多仓还是空仓 |
clientOid | String | 否 | Client order ID, 幂等控制 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/placePositionsTPSL" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","planType": "pos_profit","triggerPrice":"23555.5","holdSide":"long"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
- planType
- profit_plan
- loss_plan
- holdSide
- long
- short
修改止盈止损
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/modifyTPSLPlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
orderId | String | 否 | 止盈止损订单号, 'orderId' 与 'clientOid' 必需提供一个 |
clientOid | String | 否 | 'orderId' 与 'clientOid' 必需提供一个 |
marginCoin | String | 是 | 保证金币种 必须大写 |
symbol | String | 是 | 产品ID 必须大写 |
triggerPrice | String | 是 | 触发价格 |
planType | String | 是 | 参考plan type:取值:"pos_profit"、"profit_plan"、"pos_loss"、"loss_plan" |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/modifyTPSLPlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"orderId":"803521986049314816","symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","triggerPrice":"23555.5","planType":"profit_plan"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
计划委托(止盈止损)撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/cancelPlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
orderId | String | 否 | 计划委托订单ID, 'orderId' 或 'clientOid' 必需提供一个 |
clientOid | String | 否 | clientOid, 'orderId' 或 'clientOid' 必需提供一个 |
symbol | String | 是 | 产品ID 必须大写 |
marginCoin | String | 是 | 保证金币种 |
planType | String | 是 | plan type |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/cancelPlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"orderId":"803521986049314816","symbol": "BTCUSDT_UMCBL","marginCoin": "USDT","planType":"loss_plan"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
计划委托(止盈止损)按symbol撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/cancelSymbolPlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
planType | String | 是 | plan type |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/cancelSymbolPlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","planType":"loss_plan"}'
返回数据
{
"code":"00000",
"data":true,
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
data | 撤单指定是否成功接收 |
最终的撤单结果需要通过websocket/当前计划委托查询以确定
策略一键撤单
限速规则: 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/plan/cancelAllPlan
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | 产品类型 |
planType | String | 是 | 撤单类型 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/plan/cancelAllPlan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"productType":"umcbl","planType":"loss_plan"}'
返回数据
{
"code":"00000",
"data":{
"clientOid":"RFIut#1627300490884",
"orderId":"803521986049314816"
},
"msg":"success",
"requestTime":1627300490899
}
返回值说明
返回字段 | 字段说明 |
---|---|
clientOid | 客户端自定义id |
orderId | 订单号 |
planType
- profit_plan
- loss_plan
- normal_plan
- pos_profit
- pos_loss
- track_plan 追踪委托
- moving_plan 移动止盈止损
获取当前计划委托(止盈止损)列表
限速规则: 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/plan/currentPlan
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
isPlan | String | 否 | 查询类型 |
productType | String | 否 | 产品类型 如果查询使用此参数 不需要symbol |
请求示例
curl "https://api.bitget.com/api/mix/v1/plan/currentPlan?symbol=BTCUSDT_UMCBL&isPlan=plan" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"orderId":"803521986049314816",
"clientOid":"xxx001",
"symbol":"BTCUSDT_UMCBL",
"marginCoin":"USDT",
"size":"1",
"executePrice":"38923.1",
"triggerPrice":"45000.3",
"status":"not_trigger",
"orderType":"limit",
"planType":"normal_plan",
"side":"open_long",
"triggerType":"fill_price",
"presetTakeProfitPrice":"0",
"presetTakeLossPrice":"0",
"rangeRate": "",
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"cTime":"1627300490867"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单号 |
clientOid | Client Order Id |
symbol | 币对名称 |
marginCoin | 保证金币种 |
size | 委托数量 |
executePrice | 委托价格 |
triggerPrice | 触发价格 |
status | 订单状态 |
orderType | 交易类型 |
planType | 订单类型 |
side | 开单方向 |
triggerType | 触发类型 |
presetTakeProfitPrice | 预设止盈价格 |
presetTakeLossPrice | 预设止损价格 |
rangeRate | 回调幅度(planType="moving_plan"时有值),“1” 表示 1.0%的价格回调, 最多两位小数 |
enterPointSource | enterPointSource |
tradeSide | Trade Side |
holdMode | Hold Mode |
cTime | 最近更新时间 |
isPlan
- plan
- profit_loss
获取历史计划委托(止盈止损)列表
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/plan/historyPlan
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
startTime | String | 是 | 开始时间 |
endTime | String | 是 | 结束时间 |
pageSize | Integer | 否 | 查询条数 默认100 |
isPre | boolean | 否 | 是否查询上一页 默认false |
isPlan | String | 否 | 查询类型 |
请求示例
curl "https://api.bitget.com/api/mix/v1/plan/historyPlan?symbol=BTCUSDT_UMCBL&startTime=1659406928000&endTime=1659414128000&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"orderId":"803521986049314816",
"clientOid":"xxx001",
"executeOrderId":"3036219460491",
"symbol":"BTCUSDT_UMCBL",
"marginCoin":"USDT",
"size":"1",
"executePrice":"38923.1",
"triggerPrice":"45000.3",
"status":"not_trigger",
"orderType":"limit",
"planType":"normal_plan",
"side":"open_long",
"triggerType":"fill_price",
"presetTakeProfitPrice":"0",
"presetTakeLossPrice":"0",
"rangeRate": "",
"enterPointSource": "WEB",
"tradeSide": "buy_single",
"holdMode": "single_hold",
"cTime":"1627300490867"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
orderId | 订单号 |
clientOid | Client Order Id |
executeOrderId | 触发委托单id |
symbol | 币对名称 |
marginCoin | 保证金币种 |
size | 委托数量 |
executeSize | 执行数量 |
executePrice | 委托价格 |
triggerPrice | 触发价格 |
status | 订单状态 |
orderType | 交易类型 |
planType | 订单类型 |
side | 开单方向 |
triggerType | 触发类型 |
presetTakeProfitPrice | 预设止盈价格 |
presetTakeLossPrice | 预设止损价格 |
rangeRate | 回调幅度(planType="moving_plan"时有值),“1” 表示 1.0%的价格回调, 最多两位小数 |
enterPointSource | enterPointSource |
tradeSide | Trade Side |
holdMode | Hold Mode |
cTime | 最近更新时间 |
- isPlan
- plan
- profit_loss
跟单接口
交易员获取当前带单
限速规则 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/currentTrack
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
productType | String | 是 | 产品类型 |
pageSize | int | 是 | 查询数量,默认20,最大100 |
pageNo | int | 是 | 当前页号 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/currentTrack?symbol=BTCUSDT_UMCBL&productType=umcbl&pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"trackingNo":"699848017573842632",
"openOrderId":"4839999132328",
"symbol":"BTCUSDT_UMCBL",
"holdSide":"long",
"openLeverage":20,
"openAvgPrice":11451.5,
"openTime":1602582690614,
"openDealCount":"10",
"stopProfitPrice":"123.14",
"stopLossPrice":"20.52"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
trackingNo | 跟踪订单号 |
openOrderId | 交易员开仓单号 |
symbol | 交易对名称 |
holdSide | 持仓方向 |
openLeverage | 开仓杠杆 |
openAvgPrice | 开仓均价 |
openTime | 开仓时间 |
openDealCount | 开仓数量 |
stopProfitPrice | 预设止盈价 |
stopLossPrice | 预设止损价 |
跟随者获取跟单信息
限速规则 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/followerOrder
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
productType | String | 是 | 产品类型 |
pageSize | int | 是 | 查询数量 |
pageNo | int | 是 | 当前页号 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerOrder?symbol=BTCUSDT_UMCBL&productType=umcbl&pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"trackingNo":"804641389214179330",
"openOrderId":"804641382428463106",
"closeOrderId":"",
"symbol":"BTCUSDT_UMCBL",
"holdSide":"short",
"openLeverage":47,
"openAvgPrice":39827,
"openTime":1627567376984,
"openDealCount":"0.0010000000000000",
"averageClosePrice":0,
"closeDealCount":"0.0000000000000000",
"openMargin":"21",
"closeTime":0
}
],
"msg":"success",
"requestTime":1634107646972
}
返回值说明
返回字段 | 字段说明 |
---|---|
trackingNo | 跟踪订单号 |
openOrderId | 跟随者开仓单号 |
closeOrderId | 跟随者平仓单号 |
symbol | 交易对名称 |
holdSide | 持仓方向 |
openLeverage | 开仓杠杆 |
OpenAvgPrice | 开仓均价 |
openTime | 开仓时间 |
openDealCount | 开仓数量 |
openMargin | 开仓保证金 |
averageClosePrice | 平仓均价 |
closeDealCount | 平仓数量 |
closeTime | 平仓时间 |
跟随者获取历史跟单信息
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/followerHistoryOrders
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
startTime | String | 是 | 开始时间(毫秒时间戳) |
endTime | String | 是 | 结束时间(毫秒时间戳) |
pageSize | int | 是 | 查询数量,默认100 |
pageNo | int | 是 | 当前页号,默认1 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerHistoryOrders?startTime=1668073994000&endTime=1668073994206&pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"symbol":"BTCUSDT_UMCBL",
"trackingNo":"682799071840175632",
"holdSide":"long",
"openSize":"20",
"closeSize":"20",
"openLevel":20,
"openAvgPrice":"11366.50",
"openTime":1627356444000,
"closeDealCount":"10",
"closeTime":1626838044000,
"closeAvgPrice":"11272.00",
"stopType":"profit",
"achievedProfits":"-0.07650000",
"openFee":"-0.00680910",
"closeFee":"0.000000",
"profitRate":"1",
"netProfit":"1"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
trackingNo | 跟踪订单号 |
openOrderNo | 跟随者开仓单号 |
closeOrderNo | 跟随者平仓单号 |
symbol | 交易对名称 |
holdSide | 持仓方向 |
leverage | 开仓杠杆 |
openAvgPrice | 开仓均价 |
openTime | 开仓时间 |
openSize | 开仓数量 |
closeAvgPrice | 平仓均价 |
closeFee | 平仓手续费 |
openFee | 开仓手续费 |
closeSize | 平仓数量 |
closeTime | 平仓时间 |
profitRate | 收益率 |
netProfit | 跟随净收益 |
achievedProfits | 已实现盈亏 |
交易员平仓接口
限速规则 10次/1s (uid)
交易员平仓需要使用 trackingNo
跟踪订单号,此值不是你的开仓单号,它需要调用 交易员获取当前带单
响应里面会展示 trackingNo
HTTP请求
- POST /api/mix/v1/trace/closeTrackOrder
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 产品ID 必须大写 |
trackingNo | String | 是 | 跟踪订单号 来自当前带单接口的 trackingNo |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/trace/closeTrackOrder" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","trackingNo": "6258224712558517"}'
返回数据
{
"code":"00000",
"data":{
"trackingNo":6258224712558517,
"result":true
},
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
trackingNo | 跟踪订单号 |
result | 处理结果成功 true 失败 false |
交易员修改止盈止损
限速规则 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/trace/modifyTPSL
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
trackingNo | Long | 是 | 带单号 |
symbol | String | 是 | 带单交易对 |
stopProfitPrice | BigDecimal | 否 | 止盈价格,不传表示不设置止盈或取消止盈 |
stopLossPrice | BigDecimal | 否 | 止损价格,不传表示不设置止损或取消止损 |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/trace/modifyTPSL" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","trackingNo": "6258224712558517","stopProfitPrice":"24123.5","stopLossPrice":"21487.5"}'
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 1656066841304,
"data": 924176438170464256
}
交易员获取历史带单
限速规则 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/historyTrack
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
startTime | String | 是 | 开始时间时间戳(毫秒) |
endTime | String | 是 | 结束时间时间戳(毫秒) |
pageSize | int | 是 | 查询数量,默认20,最大100 |
pageNo | int | 是 | 当前页号 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/historyTrack?startTime=1659406928000&endTime=1659414128000&pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"symbol":"BTCUSDT_UMCBL",
"trackingNo":"682799071840175632",
"holdSide":"long",
"openLevel":20,
"openAvgPrice":"11366.50",
"openTime":1627356444000,
"closeDealCount":"10",
"closeTime":1626838044000,
"closeAvgPrice":"11272.00",
"stopType":"profit",
"achievedProfits":"-0.07650000",
"openFee":"-0.00680910",
"closeFee":"0.000000"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
trackingNo | 跟踪订单号 |
symbol | 交易对名称 |
holdSide | 持仓方向 |
openLeverage | 开仓杠杆 |
openAvgPrice | 开仓均价 |
openTime | 开仓时间(毫秒) |
close | 平仓时间(毫秒) |
closeAvgPrice | 平仓均价 |
stopType | 平仓类型 |
achievedProfits | 已实现盈亏 |
openFee | 开仓手续费 |
closeFee | 平仓手续费 |
closeDealCount | 平仓数量 |
交易员分润汇总
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/summary
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/summary" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":{
"yesterdaySplitProfit":"0",
"sumProfit":"0",
"waitProfit":"0",
"yesterdayTimeStamp":"1627354109502"
},
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
yesterdaySplitProfit | 昨日分润(交易员) |
yesterdayTimeStamp | 昨日分润时间(毫秒) |
sumProfit | 累计分润 |
waitProfit | 待分润 |
交易员历史分润汇总(按结算币种)
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/profitSettleTokenIdGroup
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/profitSettleTokenIdGroup" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"settleTokenId":"usdt",
"profit":"0"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
settleTokenId | 结算币种 |
profit | 收益 |
交易员历史分润汇总(按结算币种和日期)
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/profitDateGroupList
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/profitDateGroupList" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"settleTokenId":"usdt",
"profit":"0",
"date":1627354109502
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
settleTokenId | 结算币种 |
profit | 收益 |
date | 分润时间(毫秒) |
交易员历史分润明细
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/profitDateList
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
marginCoin | String | 是 | 保证金币种 |
date | String | 是 | 分润时间 |
pageSize | int | 是 | 查询数量,默认20 最大100 |
pageNo | int | 是 | 当前页号 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/profitDateList?marginCoin=USDT&date=1627354109502&pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"settleTokenId":"usdt",
"profit":"0",
"nickName":"bitget"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
settleTokenId | 结算币种 |
profit | 已分润 |
nickName | 昵称 |
交易员待分润明细
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/waitProfitDateList
请求参数(Request Param)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
pageSize | int | 是 | 查询数量 默认20 最大100 |
pageNo | int | 是 | 当前页号 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/waitProfitDateList?pageSize=20&pageNo=1" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"settleTokenId":"usdt",
"profit":"0",
"nickName":"bitget"
}
],
"msg":"success",
"requestTime":1627354109502
}
返回值说明
返回字段 | 字段说明 |
---|---|
settleTokenId | 结算币种 |
profit | 分润 |
nickName | 昵称 |
获取交易员跟单交易对
限速规则 20次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/traderSymbols
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/traderSymbols" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code":"00000",
"data":[
{
"symbol": "BTCUSDT_UMCBL",
"minOpenCount": "0.01",
"openTrader": true
}
],
"msg":"success",
"requestTime":1634723284625
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbolId | 产品id |
openTrade | 是否开启跟单 |
minOpenCount | 交易员最小开单数量 |
交易员设置跟单交易对
限速规则 10次/1s (uid)
HTTP请求
- POST /api/mix/v1/trace/setUpCopySymbols
请求参数(Request Body)
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 交易对id |
operation | String | 是 | 增加还是删除 add/delete |
请求示例
curl -X POST "https://api.bitget.com/api/mix/v1/trace/setUpCopySymbols" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{"symbol": "BTCUSDT_UMCBL","operation": "add"}'
返回数据
{
"code":"00000",
"data":"",
"msg":"success",
"requestTime":1627354109502
}
获取交易员列表
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/traderList
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
fullStatus | String | 否 | 是否满员(默认查询所有) |
sortRule | String | 是 | 排序规则 |
sortFlag | String | 是 | 排序倒序 |
languageType | String | 否 | 中英文, 影响结果中的columnList.describe |
pageSize | String | 否 | 查询条数 默认100 |
pageNo | String | 否 | 分页页码 默认1 |
- fullStatus
- full 查询满员的交易员
- all 查询所有
- sortRule
- composite 根据综合情况排序
- roi 根据roi排序
- totalPL 根据总收益排序
- aum 根据aum排序
- sortFlag
- asc
- desc
- languageType
- zh-CN 中文
- en-US 英文
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/traderList?sortRule=composite&sortFlag=asc&pageNo=1&pageSize=20" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 1679453151215,
"data": [
{
"canTrace": false,
"traderUid": "5913396676",
"traderNickName": "VuDucThanhLong",
"maxFollowCount": "1000",
"followCount": "1000",
"profile": "",
"tradingPairsAvailable": [
"BTCUSDT",
"BTCUSD",
"ETHUSDT",
"ETHUSD"
],
"columnList": [
{
"describe": "ROI",
"value": "194.78"
},
{
"describe": "Total P/L 3W",
"value": " $3711.17"
},
{
"describe": "Win Rate 3W",
"value": "51.11"
},
{
"describe": "Total P&L",
"value": " $19051.65"
},
{
"describe": "Accum Followers",
"value": "16008"
},
{
"describe": "AUM",
"value": " $1138288.24"
}
],
"myTrader": false
},
{
"canTrace": true,
"traderUid": "5560017617",
"traderNickName": "Jason",
"maxFollowCount": "500",
"followCount": "484",
"profile": "",
"tradingPairsAvailable": [
"BTCUSDT",
"ETHUSDT"
],
"columnList": [
{
"describe": "ROI",
"value": "909.94"
},
{
"describe": "Total P/L 3W",
"value": " $116.00"
},
{
"describe": "Win Rate 3W",
"value": "82.26"
},
{
"describe": "Total P&L",
"value": " $2455.25"
},
{
"describe": "Accum Followers",
"value": "10460"
},
{
"describe": "AUM",
"value": " $687938.16"
}
],
"myTrader": false
}
]
}
返回值说明
返回字段 | 字段说明 |
---|---|
canTrace | 是否可跟 |
traderUid | 交易员ID |
traderNickName | 交易员昵称 |
maxFollowCount | 最大可跟人数 |
followCount | 目前跟单人数 |
profile | 交易员简介 |
tradingPairsAvailable | 可跟单币对 |
myTrader | 我是否已跟 |
columnList | 交易员交易指标数据 |
columnList
返回字段 | 字段说明 |
---|---|
describe | 指标描述, 根据languageType返回不同语言的描述 |
value | 指标值 |
交易员查看自己交易数据指标统计
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/traderDetail
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/traderDetail" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 1679456559180,
"data": {
"roi": "332.61",
"tradingOrders": "30",
"accFollowers": "1",
"totalpl": "$95.65",
"gainNum": "20",
"lossNum": "10",
"winRate": "66.67",
"tradingPairsAvailable": [
"BTCUSDT",
"ETHUSDT"
],
"lastWeekRoi": [
{
"rate": "48.285216",
"ctime": "1678809600000"
}
],
"lastWeekProfit": [
{
"amount": "86.6389000000000000",
"ctime": "1678809600000"
}
],
"lastMonthRoi": [
{
"rate": "52.414266",
"ctime": "1676822400000"
}
],
"lastMonthProfit": [
{
"amount": "86.6389000000000000",
"ctime": "1676822400000"
}
]
}
}
返回值说明
返回字段 | 字段说明 |
---|---|
roi | roi |
tradingOrders | 总开单数 |
accFollowers | 跟单人数 |
totalpl | 总收益 |
gainNum | 盈利比数 |
lossNum | 亏损比数 |
winRate | 胜率 |
tradingPairsAvailable | 可跟交易对 |
lastWeekRoi | 近一周收益率 |
> rate | 收益率 |
> ctime | 时间 |
lastMonthRoi | 近30天收益率 |
> rate | 收益率 |
> ctime | 时间 |
lastWeekProfit | 近一周收益 |
> amount | 收益, USDT |
> ctime | 时间 |
lastMonthProfit | 近30天收益 |
> amount | 收益, USDT |
> ctime | 时间 |
跟单用户查看跟单设置
限速规则: 10次/1s (uid)
HTTP请求
- GET /api/mix/v1/trace/queryTraceConfig
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
traderId | String | 是 | 跟单的交易员ID |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/queryTraceConfig?traderId=5741955503" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json"
返回数据
{
"code": "00000",
"msg": "success",
"requestTime": 1679465100798,
"data": [
{
"symbol": "ETHUSDT_UMCBL",
"marginType": "specify",
"marginCoin": "USDT",
"leverType": "trader",
"longLeverage": null,
"shortLeverage": null,
"traceType": "percent",
"traceValue": "1",
"maxHoldCount": 50000,
"stopProfitRation": "",
"stopLossRation": ""
}
]
}
返回值说明
返回字段 | 字段说明 |
---|---|
symbol | 交易对 |
marginType | 保证金设置 |
marginCoin | 保证金币种 |
leverType | 杠杆方式 |
longLeverage | 多仓杠杆 |
shortLeverage | 空仓杠杆 |
traceType | 跟单仓位类型 |
traceValue | 跟单仓位值 |
maxHoldCount | 最大跟单张数 |
stopProfitRation | 止盈比例 |
stopLossRation | 止损比例 |
- marginType
- trader 保证金类型跟随交易员
- specify 自己指定保证金类型
- leverType
- position 使用仓位杠杆
- specify 使用指定杠杆
- trader 使用交易员杠杆
- traceType
- percent 设置跟单金额对交易员开仓金额的比例,例如1,则表示跟交易员开仓金额相同,2表示开仓金额是交易员开仓金额的2倍
- amount 跟单金额指定固定金额
- count 跟单金额固定张数
跟单用户跟单设置
限速规则 10次/1s
HTTP请求
- POST /api/mix/v1/trace/followerSetBatchTraceConfig
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
traderId | String | 是 | 跟单的交易员ID |
settings | array | 是 | 跟单的设置(按照交易对) |
settings
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
symbol | String | 是 | 交易对 |
marginType | array | 是 | 保证金类型 |
marginCoin | array | 否 | 保证金币种 |
leverType | array | 是 | 杠杆类型 |
longLeverage | array | 否 | 多仓杠杆 |
shortLeverage | array | 否 | 空仓杠杆 |
traceType | array | 是 | 跟单仓位类型 |
traceValue | array | 否 | 跟单仓位值 |
maxHoldCount | array | 否 | 最大跟单张数 |
stopProfitRation | array | 否 | 止盈比例 |
stopLossRation | array | 否 | 止损比例 |
- marginType
- trader 保证金类型跟随交易员
- specify 自己指定保证金类型
- leverType
- position 使用仓位杠杆
- specify 使用指定杠杆
- trader 使用交易员杠杆
- traceType
- percent 设置跟单金额对交易员开仓金额的比例,例如1,则表示跟交易员开仓金额相同,2表示开仓金额是交易员开仓金额的2倍
- amount 跟单金额指定固定金额
- count 跟单金额固定张数
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerSetBatchTraceConfig" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{
"traderId": "3559776384",
"settings": [{
"symbol": "ETHUSDT_UMCBL",
"marginType": "specify",
"marginCoin": "USDT",
"leverType": "specify",
"longLeverage": "12",
"shortLeverage": "10",
"traceType": "amount",
"traceValue": "1000",
"maxHoldCount": "",
"stopProfitRation": "",
"stopLossRation": ""
}]
}
返回数据
{
"code":"00000",
"msg":"success",
"requestTime":163123213132,
"data":true
}
返回值说明
返回字段 | 字段说明 |
---|
跟单用户根据跟单号平仓
限速规则 10次/1s
HTTP请求
- POST /api/mix/v1/trace/followerCloseByTrackingNo
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
trackingNo | String | 是 | 跟单号 |
productType | String | 是 | product type |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerCloseByTrackingNo" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{
"trackingNo": "35586868769776384",
"productType": "UMCBL"
}
返回数据
{
"code":"00000",
"msg":"success",
"requestTime":163123213132,
"data":true
}
返回值说明
返回字段 | 字段说明 |
---|
跟单用户根据币对、方向、仓位模式、保证金平仓
限速规则 20次/1s
HTTP请求
- POST /api/mix/v1/trace/followerCloseByAll
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
productType | String | 是 | product type |
symbol | String | 是 | 交易对 |
marginCoin | String | 是 | 保证金币种 |
marginMode | String | 是 | 仓位模式 |
holdSide | String | 是 | 持仓方向 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerCloseByAll" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{
"symbol": "ETHUSDT_UMCBL",
"productType": "UMCBL"
}
返回数据
{
"code":"00000",
"msg":"success",
"requestTime":163123213132,
"data":true
}
返回值说明
返回字段 | 字段说明 |
---|
跟单用户设置止盈止损
限速规则 20次/1s
HTTP请求
- POST /api/mix/v1/trace/followerSetTpsl
请求参数
参数名 | 参数类型 | 是否必须 | 描述 |
---|---|---|---|
trackingNo | String | 是 | 跟单号 |
symbol | String | 否 | 交易对 |
stopProfitPrice | String | 否 | 止盈价 |
stopLossPrice | String | 否 | 止损价 |
请求示例
curl "https://api.bitget.com/api/mix/v1/trace/followerSetTpsl" \
-H "ACCESS-KEY:you apiKey" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "locale:en-US" \
-H "Content-Type: application/json" \
-d \'{
"symbol": "ETHUSDT_UMCBL",
"trackingNo": "3284728347239874",
"stopProfitPrice":"2400",
"stopLossPrice":"1600"
}
返回数据
{
"code":"00000",
"msg":"success",
"requestTime":163123213132,
"data":true
}
返回值说明
返回字段 | 字段说明 |
---|
WebSocketAPI
概述
WebSocket是HTML5一种新的协议(Protocol)。它实现了客户端与服务器全双工通信, 使得数据可以快速地双向传播。通过一次简单的握手就 可以建立客户端和服务器连接, 服务器根据业务规则可以主动推送信息给客户端。其优点如下:
- 客户端和服务器进行数据传输时,请求头信息比较小,大概2个字节。
- 客户端和服务器皆可以主动地发送数据给对方。
- 不需要多次创建TCP请求和销毁,节约宽带和服务器的资源。
强烈建议开发者使用WebSocket API获取市场行情和买卖深度等信息。
域名 | WebSocket API | 建议使用 |
---|---|---|
域名1 | wss://ws.bitget.com/mix/v1/stream | 国际 |
连接说明:
连接上ws后30s内订阅或订阅后30s内用户未发送ping指令,系统会自动断开连接
连接
连接说明:
连接限制:1次/秒
订阅限制:240次/小时
如果出现网络问题,系统会自动断开连接
如果连接成功后30s未订阅或订阅后30s内服务器未向用户推送数据,系统会自动断开连接
为了保持连接有效且稳定,建议您进行以下操作:
- 每次接收到消息后,用户设置一个定时器,定时30秒。
- 如果定时器被触发(30秒内没有收到新消息),发送字符串 'ping'。
- 期待一个文字字符串'pong'作为回应。如果在 N秒内未收到,请发出错误或重新连接。
- Websocket服务器每秒最多接受10个消息。消息包括:
- PING帧
- JSON格式的消息,比如订阅,断开订阅。
- 如果用户发送的消息超过限制,连接会被断开连接。反复被断开连接的IP有可能被服务器屏蔽;
- 单个连接最多可以订阅 1000 个Streams;
- 单个IP最多可以创建100个连接。
登录
api_key:用于调用API的用户身份唯一标示,需要用户申请
passphrase:API Key 的密码,如果没有口令的话传入空字符串("")即可
timestamp: 时间戳 是Unix Epoch时间,单位是秒, 时间戳30秒后会过期
sign:为签名字符串,签名规则参照如下:
Message即(待签名字符串)为: timestamp+method+requestPath
其中timestamp示例:const timestamp = '' + Date.now() / 1000
method一律默认为'GET'
requestPath 一律默认为'/user/verify'
请求在时间戳之后30秒会失效,如果您的服务器时间和API服务器时间有偏差,推荐使用 REST API查询API服务器的时间,然后设置时间戳
签名方式说明参考API概述里的验证部分
生成最终签名的步骤
第1步,将待签名字符串使用私钥secretkey进行hmac sha256加密
Signature = hmac_sha256(secretkey, Message)
第2步,对于Signature进行base64编码
Signature = base64.encode(Signature)
如果登录失败会自动断开链接
请求格式说明:
{
"op":"login",
"args":[
{
"apiKey":"<api_key>",
"passphrase":"<passphrase>",
"timestamp":"<timestamp>",
"sign":"<sign>"
}
]
}
请求示例:
{
"op":"login",
"args":[
{
"apiKey":"bg_573af5eca856acd91c230da294ce2105",
"passphrase":"123456",
"timestamp":"1538054050",
"sign":"8RCOqCJAhhEh4PWcZB/96QojLDqMAg4qNynIixFzS3E="
}
]
}
成功返回示例:
{
"event":"login",
"code":"0",
"msg":""
}
失败返回示例:
{
"event":"error",
"code":"30005",
"msg":"login fail"
}
订阅
订阅说明
请求格式说明
{
"op":"subscribe",
"args":[
"<SubscriptionTopic> "
]
}
WebSocket 频道: 公共频道
公共频道
无需登录,包括行情频道,K线频道,交易数据频道,深度数据频道等。
instId
来源 /api/mix/v1/market/contracts,参考响应中的baseCoin + quoteCoin
用户可以选择订阅一个或者多个频道,多个频道总长度不能超过4096个字节。
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"mc",
"channel":"ticker",
"instId":"BTCUSDT"
},
{
"instType":"mc",
"channel":"candle1m",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 否 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名 |
> instId | String | 否 | 产品ID或产品名称 |
返回示例
{
"event":"subscribe",
"arg":{
"instType":"mc",
"channel":"ticker",
"instId":"BTCUSDT"
}
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 否 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 否 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
取消订阅
可以取消一个或者多个频道
请求格式说明
{
"op":"unsubscribe",
"args":[
"< SubscriptionTopic > "
]
}
请求示例
{
"op":"unsubscribe",
"args":[
{
"instType":"MC",
"channel":"ticker",
"instId":"BTCUSDT"
},
{
"instType":"MC",
"channel":"candle1D",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,unsubscribe |
args | Array | 是 | 取消订阅的频道列表 |
instType | String | 是 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名 |
> instId | String | 是 | 产品ID |
返回示例
{
"event":"unsubscribe",
"arg":{
"instType":"MC",
"channel":"ticker",
"instId":"BTCUSDT"
}
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,unsubscribe error |
arg | Object | 否 | 取消订阅的频道 |
> instType | String | 否 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 否 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
Checksum机制
此机制可以帮助用户校验深度数据的准确性。
深度合并
用户订阅增量推送(如:books
)深度频道成功后,首先获取初始全量深度数据,当获取到增量推送数据后,更新本地全量深度数据。
- 如果有相同价格,则比较数量;数量为0删除此深度,数量有变化则替换此数据。
- 如果没有相同价格,则按照价格优劣排序(bids为价格降序,asks为价格升序),将深度信息插入到全量数据中
计算校验和
先用深度合并后前25档bids和asks组成一个字符串(其中ask和bid中的价格和数量以冒号连接),再计算其crc32值(32位有符号整型)。
1.bid和ask超过25档
合并后全量深度数据(在此仅展示2档数据,实际应截取25档数据):
"bids": [
[ 3366.1, 7 ], //bid1
[ 3366 , 6]
]
"asks": [
[ 3366.8, 9], //ask1
[ 3368 , 8]
]
校验字符串:
"3366.1:7:3366.8:9:3366:6:3368:8"
2.bid或ask不足25档
合并后全量深度数据:
"bids": [
[ 3366.1, 7]
]
"asks": [
[ 3366.8, 9],
[ 3368 , 8 ],
[ 3372 , 8 ]
]
校验字符串:
"3366.1:7:3366.8:9:3368:8:3372:8"
- 当bid和ask深度数据超过25档时,截取各自25档数据,要校验的字符串按照bid、ask深度数据交替方式连接。如:bid1[价格:数量]:ask1[价格:数量]:bid2[价格:数量]:ask2[价格:数量]...
- bid或ask深度数据不足25档时,直接忽略缺失的深度。如:bid1[价格:数量]:ask2[价格:数量]:ask3[价格:数量]:ask4[价格:数量]...
公共频道
行情频道
获取产品的最新成交价、买一价、卖一价和24小时交易量等信息,有数据更新推送一次数据
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"MC",
"channel":"ticker",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 | |
---|---|---|---|---|
1 | op | String | 是 | 操作,subscribe unsubscribe |
2 | args | Array | 是 | 请求订阅的频道列表 |
3 | > instType | String | 是 | 产品类型 MC:公共频道 |
4 | > channel | String | 是 | 频道名,ticker |
5 | > instId | String | 是 | 产品名称 |
成功返回示例
{
"event":"subscribe",
"arg":{
"instType":"MC",
"channel":"ticker",
"instId":"BTCUSDT"
}
}
失败返回示例
{
"event":"error",
"code":30003,
"msg":"instType:MC,channel:ticker,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 是 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 是 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送示例
{
"action":"snapshot",
"arg":{
"instType":"mc",
"channel":"ticker",
"instId":"BTCUSDT"
},
"data":[
{
"instId":"BTCUSDT",
"last":"44962.00",
"bestAsk":"44962",
"bestBid":"44961",
"high24h":"45136.50",
"low24h":"43620.00",
"priceChangePercent":"0.02",
"capitalRate":"-0.00010",
"nextSettleTime":1632495600000,
"systemTime":1632470889087,
"markPrice":"44936.21",
"indexPrice":"44959.23",
"holding":"1825.822",
"baseVolume":"39746.470",
"quoteVolume":"1760329683.834",
"openUtc": "17088.5000000000000000",
"chgUTC": "-0.00778",
"symbolType": 1,
"symbolId": "BTCUSDT_UMCBL",
"deliveryPrice": "0",
"bidSz": "10.344",
"askSz": "3.024"
}
]
}
返回参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 订阅成功的频道 |
> instType | String | 产品类型 |
> channel | String | 频道名 |
> instId | String | 产品名称 |
action | String | 推送数据动作,增量推送数据还是全量推送数据snapshot :全量update :增量 |
data | Array | 订阅的数据 |
> instId | String | 产品名称 |
>last | String | 最新价 |
>bestAsk | String | 卖一价 |
>bestBid | String | 买一价 |
>high24h | String | 24小时最高价 |
>low24h | String | 24小时最低价 |
>priceCahngePercent | String | 24小时涨跌幅 |
>capitalRate | String | 资金费率 |
>nextSettleTime | String | 下次资金费率结算时间 时间戳毫秒 |
>systemTime | String | 系统时间 |
>marketPrice | String | 标记价格 |
>indexPrice | String | 指数价格 |
>holding | String | 持仓量 |
>baseVolume | String | 左币交易量 |
>quoteVolume | String | 右币交易量 |
>openUtc | String | UTC 00:00时刻价格 |
>chgUTC | String | 自UTC 00:00涨跌幅 |
>symbolType | String | SymbolType:perpetual->永续 delivery->交割 |
>symbolId | String | Symbol Id |
>deliveryPrice | String | 交割合约交割价,SymbolType=perpetual时为0 |
>bidSz | String | Best bid size |
>askSz | String | Best ask size |
K线频道
获取产品的K线数据。
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"MC",
"channel":"candle1D",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 是 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名,candle1W candle1D candle12H candle4H candle1H candle30m candle15m candle5m candle1m |
> instId | String | 是 | 产品名称 |
成功返回示例
{
"event":"subscribe",
"arg":{
"instType":"MC",
"channel":"candle1D",
"instId":"BTCUSDT"
}
}
失败返回示例
{
"event":"error",
"code":30003,
"msg":"instType:MC,channel:candle1D,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> channel | String | 是 | 频道名 |
> instType | String | 是 | 产品类型 |
> instId | String | 是 | 产品名称 |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送示例
{
"arg":{
"instType":"mc",
"channel":"candle1D",
"instId":"BTCUSDT"
},
"data":[
[
"1597026383085",
"8533.02",
"8553.74",
"8527.17",
"8548.26",
"45247"
]
]
}
返回参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> instId | String | 产品ID |
> instType | String | 产品类型 |
data | Array | 订阅的数据 |
> ts | String | 开始时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> o | String | 开盘价格 |
> h | String | 最高价格 |
> l | String | 最低价格 |
> c | String | 收盘价格 |
> v | String | 数值为左币交易量 |
深度频道
获取深度数据,books
是全量深度频道,books5
是5档频道;
books
首次推全量快照数据,以后增量推送,以后增量推送,即有深度有变化推送一次变化的数据
books1
首次推1档快照数据,以后全量推送,有深度变化推送一次1档数据,即每次都推送1档数据
books5
首次推5档快照数据,以后全量推送,有深度变化推送一次5档数据,即每次都推送5档数据
books15
首次推15档快照数据,以后全量推送,有深度变化推送一次15档数据,即每次都推送15档数据
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"mc",
"channel":"books5",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 是 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名,books books1 books5 books15 |
> instId | String | 是 | 产品ID |
成功返回示例
{
"event":"subscribe",
"arg":{
"instType":"sp",
"channel":"books5",
"instId":"BTCUSDT"
}
}
失败返回示例
{
"event":"error",
"code":30003,
"msg":"instType:MC,channel:books5,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 是 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 是 | 产品名称 |
msg | String | 否 | 错误消息 |
code | String | 否 | 错误码 |
推送示例:全量
{
"action": "snapshot",
"arg": {
"instType": "MC",
"channel": "books",
"instId": "BTCUSDT"
},
"data": [ {
"asks": [
[44849.3, 0.0031]
],
"bids": [
[44845.2, 0.725]
],
"checksum":" -1638549107",
"ts": "1628826748009"
} ]
}
返回参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 订阅成功的频道 |
> instType | String | 产品类型 |
> channel | String | 频道名 |
> instId | String | 产品名称 |
action | String | 推送数据动作,增量推送数据还是全量推送数据snapshot :全量update :增量 |
data | Array | 订阅的数据 |
> asks | Array | 卖方深度 |
> bids | Array | 买方深度 |
> ts | String | 数据更新时间戳,Unix时间戳的毫秒数格式,如 1597026383085 |
> checksum | Integer | 检验和 |
asks和bids值数组举例说明: ["411.8", "10"] 411.8为深度价格,10为此价格的基础币量
交易频道
获取最近的成交数据,有成交数据就推送, 首次推送最近50条成交记录, 后续增量推送
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"MC",
"channel":"trade",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 是 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名,trade |
> instId | String | 是 | 产品ID |
成功返回示例
{
"event":"subscribe",
"arg":[
{
"instType":"MC",
"channel":"trade",
"instId":"BTCUSDT"
}
]
}
失败返回示例
{
"event":"error",
"code":30003,
"msg":"instType:MC,channel:trade,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 是 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 是 | 产品名称 |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送示例
{
"action":"snapshot",
"arg":{
"instType":"mc",
"channel":"trade",
"instId":"BTCUSDT"
},
"data":[
[
"1630585523753",
"45653.5",
"0.0100",
1
],
[
"1630572379706",
"45653.5",
"0.0221",
1
]
]
}
返回参数
参数名 | 类型 | 描述 |
---|---|---|
action | String | snapshot/update |
arg | Object | 订阅成功的频道 |
> instType | String | 产品类型 |
> channel | String | 频道名 |
> instId | String | 产品名称 |
data | Array | 订阅的数据 |
> ts | String | 成交时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> px | String | 成交价格 |
> sz | String | 成交数量 |
> side | String | 成交方向,buy 买 sell卖 |
交易详情频道
获取最近的成交数据,有成交数据就推送, 首次推送最近50条成交记录, 后续增量推送
请求示例
{
"op":"subscribe",
"args":[
{
"instType":"MC",
"channel":"tradeNew",
"instId":"BTCUSDT"
}
]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 是 | 产品类型 MC:公共频道 |
> channel | String | 是 | 频道名,tradeNew |
> instId | String | 是 | 产品ID |
成功返回示例
{
"event":"subscribe",
"arg":[
{
"instType":"MC",
"channel":"tradeNew",
"instId":"BTCUSDT"
}
]
}
失败返回示例
{
"event":"error",
"code":30003,
"msg":"instType:MC,channel:tradeNew,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 是 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 是 | 产品名称 |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送示例 - snapshot
{
"data": [
{
"p": "20221.5",
"c": "0.009",
"ti": "969054894406951028",
"ty": "sell",
"ts": 1666766611672
},
{
"p": "20221.5",
"c": "1.100",
"ti": "969054894406951026",
"ty": "sell",
"ts": 1666766611672
}
],
"arg": {
"instType": "mc",
"instId": "BTCUSDT",
"channel": "tradeNew"
},
"action": "snapshot"
}
推送示例 - update
{
"data": [
{
"p": "20221.0",
"c": "0.249",
"ti": "969054896504102913",
"ty": "buy",
"ts": 1666766612172
}
],
"arg": {
"instType": "mc",
"instId": "BTCUSDT",
"channel": "tradeNew"
},
"action": "update"
}
返回参数
参数名 | 类型 | 描述 |
---|---|---|
action | String | snapshot/update |
arg | Object | 订阅成功的频道 |
> instType | String | 产品类型 |
> channel | String | 频道名 |
> instId | String | 产品名称 |
data | Array | 订阅的数据 |
> ts | String | 成交时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> p | String | 成交价格 |
> c | String | 成交数量 |
> ty | String | 成交方向,buy 买 sell卖 |
> ti | String | tradeId |
私有频道
账户频道
获取账户信息,首次订阅按照订阅维度推送数据,此外,当下单、撤单等事件触发时,推送数据
请求示例
{
"op": "subscribe",
"args": [{
"instType": "UMCBL",
"channel": "account",
"instId": "default"
}]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> instType | String | 是 | 产品类型 UMCBL:专业合约私有频道 DMCBL:混合合约私有频道 |
> channel | String | 是 | 频道名,account |
> instId | String | 是 | 币种, 全部传 default |
成功返回示例
{
"event":"subscribe",
"arg":{
"instType":"UMCBL",
"channel":"account",
"instId":"default"
}
}
失败返回示例
{
"event": "error",
"code": 30003,
"msg": "instType:UMCBL,channel:account,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 操作,subscribe unsubscribe error |
arg | Object | 否 | 订阅的频道 |
> instType | String | 是 | 产品类型 |
> channel | String | 是 | 频道名 |
> instId | String | 否 | 币种 |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送数据参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 请求订阅的频道 |
> instType | String | 产品类型 |
> channel | String | 频道名 |
> instId | String | 币种 |
data | Array | 订阅的数据 |
marginCoin | String | 保证金币种 |
locked | String | 冻结资产 |
available | String | 当前可用资产 |
maxOpenPosAvailable | String | 最大可用开仓余额 |
maxTransferOut | String | 最大可转出 |
equity | String | 账户权益 |
usdtEquity | String | 账户权益美金价值 |
首次推送: 全量推送
增量推送: 推送交易变化
持仓频道
获取持仓信息,首次订阅推送数据,此外,当下单、撤单等事件触发时,推送数据
请求示例
{
"op": "subscribe",
"args": [{
"instType": "UMCBL",
"channel": "positions",
"instId": "default"
}]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> channel | String | 是 | 频道名,positions |
> instType | String | 是 | 产品类型 UMCBL:专业合约私有频道 DMCBL:混合合约私有频道 |
> instId | String | 否 | 产品ID 只支持 default :全部仓位 |
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe errror |
arg | Object | 否 | 订阅的频道 |
> channel | String | 是 | 频道名 |
> instType | String | 是 | 产品类型 |
> instId | String | 否 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送数据参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> instType | String | 产品类型 |
> instId | String | 产品ID |
data | Array | 订阅的数据 |
> posId | String | 持仓ID |
> instId | String | 产品id |
> instName | String | 产品名称 |
> marginCoin | String | 占用保证金的币种 |
> margin | String | 占用保证金 |
>marginMode | String | 保证金模式, crossed :全仓 fixed :逐仓 |
> holdSide | String | 持仓方向 long :多头 short :空头 |
> holdMode | String | 持仓模式 single_hold 单向持仓,double_hold双向持仓 |
> total | String | 持仓数量 |
> available | String | 可平仓数量 |
> locked | String | 冻结数量 |
>averageOpenPrice | String | 开仓平均价 |
> leverage | String | 杠杆倍数 |
> achievedProfits | String | 已实现盈亏 |
> upl | String | 未实现盈亏 |
> uplRate | String | 未实现盈亏率 |
> liqPx | String | 预估强平价 |
> keepMarginRate | String | 维持保证金率 |
> fixedMarginRate | String | 逐仓时,实际保证金率 |
> marginRate | String | 风险率 |
> cTime | String | 持仓创建时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> uTime | String | 最近一次持仓更新时间,Unix时间戳的毫秒数格式,如 1597026383085 |
如果同时成交多个订单,那么将持仓频道的推送尽量进行聚合。
首次推送,只推用户持有的仓位。
定时推送,只推用户持有的仓位。
订单频道
获取订单信息,首次订阅不推送,只有当下单、撤单、强平、成交等事件触发时,推送数据
请求示例
{
"op": "subscribe",
"args": [{
"channel": "orders",
"instType": "UMCBL",
"instId": "default"
}]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> channel | String | 是 | 频道名, orders |
> instType | String | 是 | 产品类型 UMCBL:专业合约私有频道 DMCBL:混合合约私有频道 |
> instId | String | 否 | 目前只支持 default 全部交易对订单 |
成功返回示例
{
"event": "subscribe",
"arg": {
"channel": "orders",
"instType": "UMCBL",
"instId": "default"
}
}
失败返回示例
{
"event": "error",
"code": 30003,
"msg": "instType:UMCBL,channel:orders,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe errror |
arg | Object | 否 | 订阅的频道 |
> channel | String | 是 | 频道名 |
> instType | String | 是 | 产品类型 MC |
> instId | String | 否 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送数据参数
参数名 | 类型 | 描述 |
---|---|---|
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> instType | String | 产品类型 |
> instId | String | 产品ID |
data | Array | 订阅的数据 |
> instId | String | 产品ID |
> ordId | String | 订单ID |
> clOrdId | String | 由用户设置的订单ID来识别您的订单 |
> px | String | 委托价格 |
> sz | String | 原始委托数量,以币为单位 |
> hM | String | Hold Mode |
> eps | String | enterPointSource |
> tS | String | Trade Side |
> notionalUsd | String | 委托单预估美元价值 |
> ordType | String | 订单类型market :市价单limit :限价单 |
> force | String | 订单有效期normal:普通委托post_only : 只做maker单fok :全部成交或立即取消单ioc :立即成交并取消剩余单 |
> side | String | 订单方向,buy sell |
> posSide | String | 持仓方向long :双向持仓多头short :双向持仓空头net :单向持仓 |
> tdMode | String | 交易模式保证金模式 isolated :逐仓 cross :全仓 |
> tgtCcy | String | 保证金币种 |
> fillPx | String | 最新成交价格 |
> tradeId | String | 最新成交ID |
> fillSz | String | 最新成交数量 |
> fillTime | String | 最新成交时间 |
> fillFee | String | 最新一笔成交的手续费, 负数 |
> fillFeeCcy | String | 最新一笔成交的手续费币种 |
> execType | String | 最新一笔成交的流动性方向 T:taker M maker |
> accFillSz | String | 累计成交数量 |
> fillNotionalUsd | String | 委托单已成交的美元价值 |
> avgPx | String | 成交均价,如果成交数量为0,该字段为0;若未成交,该字段也为0 |
> status | String | 订单状态 new:未成交 partial-fill: 部分成交 full-fill:完全成交 cancelled:已撤单 |
> lever | String | 杠杆倍数 |
>orderFee | Array | |
>> feeCcy | String | 交易手续费币种 收取的就是保证金 |
>> fee | String | 订单交易手续费,平台向用户收取的交易手续费 |
> pnl | String | 收益 |
> uTime | String | 订单更新时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> cTime | String | 订单创建时间,Unix时间戳的毫秒数格式,如 1597026383085 |
计划委托频道
获取订单信息,首次订阅不推送,只有当下单、撤单、成交等事件触发时,推送数据
请求示例
{
"op": "subscribe",
"args": [{
"channel": "ordersAlgo",
"instType": "UMCBL",
"instId": "default"
}]
}
请求参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
op | String | 是 | 操作,subscribe unsubscribe |
args | Array | 是 | 请求订阅的频道列表 |
> channel | String | 是 | 频道名, ordersAlgo |
> instType | String | 是 | 产品类型 UMCBL:专业合约私有频道 DMCBL:混合合约私有频道 |
> instId | String | 否 | 目前只支持 default 全部交易对订单 |
成功返回示例
{
"event": "subscribe",
"arg": {
"channel": "ordersAlgo",
"instType": "UMCBL",
"instId": "default"
}
}
失败返回示例
{
"event": "error",
"code": 30003,
"msg": "instType:UMCBL,channel:orders,instId:BTC-USDT Symbol not exists"
}
返回参数
参数 | 类型 | 是否必须 | 描述 |
---|---|---|---|
event | String | 是 | 事件,subscribe unsubscribe errror |
arg | Object | 否 | 订阅的频道 |
> channel | String | 是 | 频道名 |
> instType | String | 是 | 产品类型 MC |
> instId | String | 否 | 产品ID |
code | String | 否 | 错误码 |
msg | String | 否 | 错误消息 |
推送数据参数
参数名 | 类型 | 描述 |
---|---|---|
action | String | 'snapshot' |
arg | Object | 订阅成功的频道 |
> channel | String | 频道名 |
> instType | String | 产品类型 |
> instId | String | 产品ID |
data | Array | 订阅的数据 |
> instId | String | 产品ID |
> id | String | 订单ID |
> cOid | String | 由用户设置的订单ID来识别您的订单 |
> triggerPx | String | 触发价格 |
> planType | String | Websocket planType, 为空时表示 'pl' |
> ordPx | String | 委托价格 |
> sz | String | 原始委托数量,以币为单位 |
> actualSz | String | 实际委托数量 以币为单位 |
> ordType | String | 订单类型market :市价单limit :限价单 |
> side | String | 订单方向,buy sell |
> posSide | String | 持仓方向;long :双向持仓多头,short :双向持仓空头;net :单向持仓 |
> tgtCcy | String | 保证金币种 |
> state | String | 订单状态 not_trigger:未触发 triggered: 已触发 fail_trigger:触发失败 cancel:已撤单 |
> hM | String | Hold mode |
> eps | String | enterPointSource. |
> triggerTime | String | 触发时间, ms |
> userId | String | 用户ID |
> version | Long | 版本号,内部使用 |
> triggerPxType | String | 'mark':标记价格触发; 'last':市价触发 |
> key | String | 内部使用 |
> tS | String | Trade Side(交易方向) |
> uTime | String | 订单更新时间,Unix时间戳的毫秒数格式,如 1597026383085 |
> cTime | String | 订单创建时间,Unix时间戳的毫秒数格式,如 1597026383085 |
RestAPI错误代码
错误提示 | 错误码 | http状态码 |
---|---|---|
请求头"ACCESS_KEY"不能为空 | 40001 | 400 |
请求头"ACCESS_SIGN"不能为空 | 40002 | 400 |
请求头"ACCESS_TIMESTAMP"不能为空 | 40003 | 400 |
无效的ACCESS_TIMESTAMP | 40005 | 400 |
无效的ACCESS_KEY | 40006 | 400 |
无效的Content_Type,请使用“application/json”格式 | 40007 | 400 |
请求时间戳过期 | 40008 | 400 |
api 校验失败 | 40009 | 400 |
请求太频繁 | 429 | 429 |
请求头"ACCESS_PASSPHRASE"不能为空 | 40011 | 400 |
apikey/passphrase不正确 | 40012 | 400 |
用户被冻结 | 40013 | 400 |
权限不正确 | 40014 | 400 |
系统错误 | 40015 | 400 |
用户必须绑定手机或者谷歌 | 40016 | 400 |
参数校验失败 | 40017 | 400 |
非法的ip请求 | 40018 | 400 |
止盈价格需要>当前价格 | 43013 | 400 |
止盈价格需要<当前价格 | 43014 | 400 |
止损价格需要<当前价格 | 43015 | 400 |
止损价格需要>当前价格 | 43016 | 400 |
您当前为交易员身份,暂不支持通过计划委托进行平仓 | 43001 | 400 |
止盈止损单不存在 | 43020 | 400 |
止盈止损单已经处于结束状态 | 43021 | 400 |
预设止盈止损触发失败 | 43022 | 429 |
仓位不足,不能设置止盈或者止损 | 43023 | 400 |
已有委托中的止盈/止损,请在全部撤销后更改 | 43024 | 400 |
计划委托单不存在 | 43025 | 400 |
计划委托单已经处于结束状态 | 43026 | 400 |
持仓数量 + 委托订单大于60 | 45116 | 400 |
您当前为交易员身份,请在当前带单下进行平仓 | 40728 | 400 |
可用仓位不足 | 40757 | 400 |
重复的clientOid | 40786 | 400 |
service return an error | 40725 | 400 |
请求超时 | 40010 | 400 |
参数校验异常 | 40808 | 400 |
参数 {0} 不应该为null | 40811 | 400 |
条件 {0} 未满足 | 40812 | 400 |
参数 {0} 异常 | 40020 | 400 |
用户禁止提币 | 40021 | 400 |
此账号该业务已被限制 | 40022 | 400 |
此账号该业务已被限制 | 40023 | 400 |
参数 {0} 不能为空 | 40019 | 400 |
账户余额不足 | 43012 | 400 |
该交易对已下线 | 41113 | 400 |
当前交易对停盘中,具体开放时间请留意官方公告 | 41114 | 400 |
参数错误 {0} | 43111 | 400 |
提币金额小于手续费 {0} | 43112 | 400 |
委托价格高于最高买价 | 40815 | 400 |
委托价格低于于最低卖价 | 40816 | 400 |
触发最小下单数量 | 45111 | 400 |
您输入的价格应该是 {0} 的倍数 | 45115 | 400 |
该币种限制买入额度{0},还剩{1} | 43122 | 400 |
未知错误 | 45001 | 400 |
WebSocket错误代码
错误提示 | 错误码 |
---|---|
频道不存在 | 30001 |
不合法的请求 | 30002 |
无效op | 30003 |
用户需要登录 | 30004 |
登录失败 | 30005 |
请求频繁 | 30006 |
请求超限,连接关闭 | 30007 |
无效的ACCESS_KEY | 30011 |
无效的ACCESS_PASSPHRASE | 30012 |
无效的ACCESS_TIMESTAMP | 30013 |
请求时间戳过期 | 30014 |
无效的签名 | 30015 |