NAV Navbar
json

更新日志

版本 时间 更新内容
V0.1.7.0
2023 SEP 30
* GET /um/v1/transactions 新增流水类型 usdx-funding-settlement
接口/linear/v1/user/trades 和websocket频道user_trade 新增closed_pnl字段
V0.1.6.1
2023 JUN 2
* 下单接口 POST /linear/v1/orders 支持 twap_market
V0.1.6.0
2023 MAR 15
* 使用费率等级, 废弃下面接口里面分费率.
GET /linear/v1/configs
GET /linear/v1/account_configs
* 在 GET /linear/v1/account_configs 增加费率等级信息
V0.1.5.6
2023 FEB 17
* GET /um/v1/accounts 响应添加字段 total_future_value, total_option_value, future_value
V0.1.5.5
2022 JAN 18
* API跟instrument_id/currency有关的接口增加字段: display name, 给界面展示使用.
V0.1.5.4
2022 DEC 15
* 增加杠杆率接口:
GET /linear/v1/leverage_ratio
POST /linear/v1/leverage_ratio
* POST /linear/v1/orders 增加触发类型 trigger_type
* API查询返回的 order 新增内部字段 "tp_price" & "sl_price"
V0.1.5.3
2022 NOV 2
* 支持U本位blocktrade:
POST /linear/v1/blocktrades
GET /linear/v1/blocktrades
GET /linear/v1/platform_blocktrades
GET /linear/v1/user/info

* 支持U本位MMP功能:
下单可以指定mmp字段
GET /linear/v1/mmp_state
POST /linear/v1/update_mmp_config
POST /linear/v1/reset_mmp

* 新增U本位 websocket mmp_frozen 频道
V0.1.5.2
2022 OCT 30
删除 USDT-M 内容
V0.1.5.1
2022 SEP 29
查询统一账户支持输出pair margin信息
V0.1.5
2022 JUL 29
USD期权 API变更:
* 支持数据分片. order_id/trade_id/transaction id不再是全局唯一.(instrument+id才是唯一,请查看 分片文档页面)
* 支持USD期权自动价格
* 新增GET /linear/v1/option_pairs
* 因为分片,废弃分页的响应数据has_more
* GET /linear/v1/user/settlements: 参数 currency 改为 settlement_currency, 同时删去 category参数(只有futures才有settlement)
* 新增 GET /linear/v1/user/deliveries
* 新增 GET /linear/v1/market/deliveries
V0.1.4
2022 JUL 18
* POST /linear/v1/amend_orders: instrument_id 必填
POST /linear/v1/amend_batchorders: instrument_id 必填
POST /linear/v1/cancel_orders: order_id_list更改格式; 如果用户撤销order_id,必须同时也提供instrument_id
V0.1.3
2022 JUL 8
* 支持 USD futures.
* /linear/v1/cancel_orders: 撤销条件单时必须输入instrument_id
* REST API GET /um/v1/accounts 和 websocket um_account 频道增加 total_position_pnl
V0.1.2
2022 JUN 2
* K线增加精度(minutes): 360, 720
V0.1.1
2022-04-22
* USD-M/USDT-M支持条件单;
* GET /um/v1/accounts 金额字段的单位改为USD。原来的USDT字段为了兼容旧客户端还会保留,但是数值等于USD字段。不再显示USDC余额(USDC已经被移除);
V0.0.1 2022-03-02 正式发布
V0.0.1 2022-01-27 初始版本

介绍

欢迎访问bit.com的API文档,您可以通过API形式获取市场数据、完成交易、管理您的账户。 本篇为USD本位合约&期权的API接口说明。USD本位合约&期权用户要求账户类型为UM类型,经典账户用户无法交易USD本位合约&期权产品。

测试环境访问地址

生产环境访问地址

访问限制

USD本位合约&期权所有接口分三类限频:公有接口,私有接口(交易)、私有接口(其他);与币本位合约&期权、现货接口分开限频。每个接口限频类别参考接口列表。公有接口按IP进行频率限制,私有接口按UID进行频率限制。当请求频率超限时,会返加“429 too many requests” 提示。

鉴权

私有接口必填字段


如果鉴权失败,会返回错误码412“AkID is valid”。

签名算法

    #########
    # Python code to calc BIT.COM API signature
    #########
    import hashlib
    import hmac

    def encode_list(self, item_list):
        list_val = []
        for item in item_list:
            obj_val = self.encode_object(item)
            list_val.append(obj_val)
        sorted_list = sorted(list_val)
        output = '&'.join(sorted_list)
        output = '[' + output + ']'
        return output

    def encode_object(self, obj):
        if isinstance(obj, (str, int)):
            return obj

        # treat obj as dict
        sorted_keys = sorted(obj.keys())
        ret_list = []
        for key in sorted_keys:
            val = obj[key]
            if isinstance(val, list):
                list_val = self.encode_list(val)
                ret_list.append(f'{key}={list_val}')
            elif isinstance(val, dict):
                # call encode_object recursively
                dict_val = self.encode_object(val)
                ret_list.append(f'{key}={dict_val}')
            elif isinstance(val, bool):
                bool_val = str(val).lower()
                ret_list.append(f'{key}={bool_val}')
            else:
                general_val = str(val)
                ret_list.append(f'{key}={general_val}')

        sorted_list = sorted(ret_list)
        output = '&'.join(sorted_list)
        return output

    def get_signature(self, http_method, api_path, param_map):
        str_to_sign = api_path + '&' + self.encode_object(param_map)
        print('str_to_sign = ' + str_to_sign)
        sig = hmac.new(self.secret_key.encode('utf-8'), str_to_sign.encode('utf-8'), digestmod=hashlib.sha256).hexdigest()
        return sig

    #########
    # END
    #########

  1. 请求参数:POST为JSON,其余部分为查询字符串
  2. 对签名进行编码,对于简单的json对象,请按字母顺序对参数进行排序,并把他们用“&”连接,如'param1=value1&param2=value2', then get str_to_sign = api_path + '&' + 'param1=value1&param2=value2'
  3. 对嵌套数组对象,对每个对象进行编码,并按字母顺序进行排序,使用“&”符号连接,并用[ ]括起来,如 str_to_sign = api_path + '&' + 'param1=value1&array_key1=[array_item1&array_item2]', 参见下面的例子
  4. 签名使用哈希算法,hex(hmac_sha256(str_to_sign, secret_key))
  5. 在请求参数中添加签名字段:对查询字符串,添加“&signature=YOUR_SIGNATURE”, 对JOSN请求体, 添加 {'signature':YOUR_SIGNATURE}


































GET 请求示例:

*Secret Key: eabc3108-dd2b-43df-a98d-3e2054049b73
*HTTP method: GET
*API Path: /v1/margins
*Query string: price=8000&qty=30&instrument_id=BTC-PERPETUAL&timestamp=1588242614000
*得到 str_to_sign = /v1/margins&instrument_id=BTC-PERPETUAL&price=8000&qty=30&timestamp=1588242614000

> echo -n "/v1/margins&instrument_id=BTC-PERPETUAL&price=8000&qty=30&timestamp=1588242614000" | openssl dgst -sha256 -hmac "eabc3108-dd2b-43df-a98d-3e2054049b73"

> e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d

sig = hex(hmac_sha256(str_to_sign, secret_key)) = e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d

*最后JSON请求体为: { "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000, "signature": "e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d" }

POST 请求示例:

Secret Key: eabc3108-dd2b-43df-a98d-3e2054049b73
HTTP method: POST
API Path: /v1/orders
JSON body:
{ "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000 }

得到 str_to_sign = /v1/orders&auto_price=&auto_price_type=&instrument_id=BTC-27MAR20-9000-C&order_type=limit&price=0.021&qty=3.14&side=buy&stop_price=&stop_price_trigger=&time_in_force=gtc&timestamp=1588242614000

> echo -n "/v1/orders&auto_price=&auto_price_type=&instrument_id=BTC-27MAR20-9000-C&order_type=limit&price=0.021&qty=3.14&side=buy&stop_price=&stop_price_trigger=&time_in_force=gtc&timestamp=1588242614000" | openssl dgst -sha256 -hmac "eabc3108-dd2b-43df-a98d-3e2054049b73"

> 34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817

sig = hex(hmac_sha256(str_to_sign, secret_key)) = 34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817

最后JSON请求体为: { "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000, "signature": "34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817" }

POST 请求带 boolean 字段

例如以POST /v1/orders 为例 (post_only 字段),

例子

request

得到 string to sign

POST 请求带 array 字段

for item in object_array:
    str_list.add(encode(item))
str_list.sorted()
str_to_sign = '&'.join(str_list)

以 POST /v1/blocktrades 为例:

私钥是 eabc3108-dd2b-43df-a98d-3e2054049b73

例子

request

得到 string to sign

数据分片

USD-M/USDT-M系统里面,产品是储存在不同的数据库分片

Id的全局唯一性

因为数据产品是储存在不同的数据库分片, 因此order_id/trade_id/transaction id 不是全局唯一的.

数据查询分页

因为数据库分片, 数据是从不同db采集聚合的, offset已经不可用。我们保留了limit指定返回记录条数。

接口目录

路径 方法 描述 范围 限速归类 权限
/linear/v1/orders POST 下单 private trade USD-M/USDT-M trade
/linear/v1/cancel_orders POST 撤销订单 private trade USD-M/USDT-M trade
/linear/v1/close_positions POST 平仓 private trade USD-M/USDT-M trade
/linear/v1/amend_orders POST 修改订单 private trade USD-M/USDT-M trade
/linear/v1/batchorders POST 批量下单 private trade USD-M/USDT-M trade
/linear/v1/amend_batchorders POST 批量改单 private trade USD-M/USDT-M trade
/linear/v1/update_mmp_config POST 更新 MMP 配置 private trade USD-M/USDT-M trade
/linear/v1/reset_mmp POST 重置 MMP 状态 private trade USD-M/USDT-M trade
/linear/v1/open_orders GET 查询未结订单 private others read
/linear/v1/orders GET 查询订单历史 private others read
/linear/v1/margins GET 查询预估保证金 private others read
/um/v1/account_mode GET 查询账户类型 private UM-others read
/um/v1/accounts GET 统一 UM 账户信息 private UM-others read
/um/v1/transactions GET 统一 UM 交易日志 private UM-others read
/um/v1/interest_records GET 查询计息记录 private UM-others read
/linear/v1/user/trades GET 查询用户交易记录 private others read
/linear/v1/positions GET 查询仓位 private others read
/linear/v1/user/deliveries GET 查询用户交割记录 private others read
/linear/v1/user/settlements GET 查询用户结算记录 private others read
/linear/v1/mmp_state GET 查询 MMP 状态 private others read
/linear/v1/leverage_ratio GET 查询用户杠杆率 private others read
/linear/v1/leverage_ratio POST 更新用户杠杆率 private others USD-M/USDT-M trade
/linear/v1/blocktrades POST block trade 下单 private block_trade block_trade
/linear/v1/blocktrades GET 查询当前用户的 block trade private block_trade block_trade
/linear/v1/platform_blocktrades GET 查询平台的 block trade private block_trade block_trade
/linear/v1/user/info GET blocktrade 权限查询用户信息 private block_trade block_trade
/linear/v1/system/time GET 查询服务器时间戳 public public /
/linear/v1/system/version GET 查询 API 版本 public public /
/linear/v1/system/cancel_only_status GET 查询 cancel only 状态 public public /
/linear/v1/instruments GET 查询产品列表 public public /
/linear/v1/market/summary GET 查询市场价格汇总 public public /
/linear/v1/tickers GET 查询市场 ticker public public /
/linear/v1/orderbooks GET 查询市场深度 public public /
/linear/v1/market/trades GET 查询市场最新交易 public public /
/linear/v1/klines GET 查询 kline public public /
/linear/v1/funding_rate GET 查询资金费率 public public /
/linear/v1/funding_rate_history GET 查询资金费率历史 public public /
/linear/v1/settlement_prices GET 获取市场结算价格信息 public public /
/linear/v1/total_volumes GET 获取市场全币种 24 小时成交量 public public /
/linear/v1/option_pairs GET 获取上架期权的币对 public public /
/um/v1/index_price GET 查询指数价格 public public /
/um/v1/loan_rates GET 查询借币利率 public public /

系统接口

查询服务器时间

GET /linear/v1/system/time

curl "https://betaapi.bitexch.dev/linear/v1/system/time"

返回数据

{
  "code": 0,
  "message": "",
  "data": 1587884283175
}

查询服务器时间。

请求参数

None

返回数据

字段名称 数据类型 说明
data integer 服务器时间戳

查询API版本

GET /linear/v1/system/version

curl "https://betaapi.bitexch.dev/v1/system/version"

返回数据

{
  "code": 0,
  "message": "",
  "data": "v1.0"
}

查询API版本。

请求参数

None

返回数据

字段名称 数据类型 说明
data string API 版本

查询 cancel only 状态

GET /linear/v1/system/cancel_only_status

curl "https://betaapi.bitexch.dev/linear/v1/system/cancel_only_status"

返回数据


{
    "code": 0,
    "message": "",
    "data": {
        "status": 0,
        "remain_ms": 0
    }
}

当bit.com在进行系统维护、升级等特殊时期,整个系统会处于只允许撤销订单,不能下新订单的状态(即cancel only状态)。此接口用于查询系统是否处于cancel-only 状态,还有多长时间结束。

status
status=1: cancel-only生效中
status=0: cancel-only已经结束,可以下单

remain_ms
Cancel-only 还有多长时间结束(毫秒)

请求参数

None

返回数据

字段名称 数据类型 说明
status integer Cancel-only 状态
remain_ms integer Cancel-only 还有多长时间结束(毫秒)

公共市场数据

获取指数

GET /um/v1/index_price

curl "https://betaapi.bitexch.dev/um/v1/index_price?currency=BTC&quote_currency=USDT"

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "index_name": "BTC-USDT",
            "index_price": "50000"
        }
    ]
}

获取指数。

currency: 活跃现货交易对的交易货币币种(base currency);

quote_currency: 活跃现货交易对的计价货币币种(quote currency);

币种参数currency为非必填,如果币种currency传入为空,则返回某计价币种quote_currency下的所有币对指数。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string false "" 币种
quote_currency string true "" 计价币种

返回数据

参数名称 数据类型 说明
index_name string 指数名称
index_price string 指数价格

获取配置信息

GET /linear/v1/configs

curl "https://betaapi.bitexch.dev/linear/v1/configs"

Response

{
    "code": 0,
    "message": "",
    "data": {
        "pairs": [
            {
                "base_ccy": "BTC",
                "quote_ccy": "USD",
                "base_display_name": "BTC",
                "quote_display_name": "USD",
                "perpetual_liquidation_fee_rate": "0.00100000",
                "option_liquidation_fee_rate": "0.01000000",
                "option_max_delivery_fee_rate": "0.00125000",
                "future_min_order_price": "0.00050000",
                "future_max_order_price": "1000000.00000000",
                "future_min_order_qty": "0.00010000",
                "future_max_order_qty": "1000000.00000000",
                "future_price_step": "0.01000000",
                "future_size_step": "0.00010000",
                "order_book_groups": "1,10,100,1000",
                "option_min_order_price": "1.00000000",
                "option_max_put_price": "900000.00000000",
                "option_min_order_qty": "0.01000000",
                "option_max_order_qty": "100000.00000000",
                "option_price_step_base": "0.00100000",
                "option_price_step_quote": "1.00000000",
                "option_size_step": "0.01000000",
                "perpetual_taker_fee_rate": "0.00080000",
                "perpetual_maker_fee_rate": "-0.00020000",
                "option_taker_fee_rate": "0.00100000",
                "option_maker_fee_rate": "0.00050000",
                "option_max_order_fee_rate": "0.12500000",
                "future_pos_limit_by_pair": "500000.00000000",
                "option_pos_limit_by_pair": "1000000.00000000",
                "option_range_factor": "0.02000000",
                "iv_min_value": "0.00000000",
                "iv_max_value": "500.00000000",
                "blocktrade_future_min_order_price": "0.00010000",
                "blocktrade_future_max_order_price": "1000000.00000000",
                "blocktrade_future_min_order_qty": "0.00010000",
                "blocktrade_future_max_order_qty": "1000000.00000000",
                "blocktrade_future_price_step": "0.00010000",
                "blocktrade_future_size_step": "0.00010000",
                "blocktrade_option_min_order_price": "0.00010000",
                "blocktrade_option_max_put_price": "1000000.00000000",
                "blocktrade_option_min_order_qty": "0.00010000",
                "blocktrade_option_max_order_qty": "1000000.00000000",
                "blocktrade_option_price_step": "0.00010000",
                "blocktrade_option_size_step": "0.00010000",
                "non_pm_linear_im_rate": "0.02000000",
                "non_pm_linear_mm_rate": "0.01500000",
                "non_pm_linear_scaling_rate": "0.00015000",
                "mi_perp_limit_price_floating_rate": "0.01500000",
                "mi_perp_mark_anchored_upper_limit_rate": "0.00500000",
                "mi_perp_mark_anchored_lower_limit_rate": "0.00500000",
                "mi_max_funding_rate": "0.00500000",
                "option_im_lower_rate": "0.10000000",
                "option_im_upper_rate": "0.15000000",
                "option_mm_rate": "0.07500000",
                "option_mm_coeff": "0.07500000",
                "is_display": true,
                "allow_for_pm": true,
                "option_precision": ""
            }
            // ....
        ],
        "ccy_open_order_params": [
            {
                "ccy": "USD",
                "ccy_display_name": "USD",
                "regular_max_open_count": 1000,
                "regular_max_option_open_count_by_ccy": 1000,
                "regular_max_option_open_count_by_instrument": 50,
                "regular_max_future_open_count_by_ccy": 1000,
                "regular_max_future_open_count_by_instrument": 100,
                "regular_max_option_total_usd_pos_by_ccy": "10000000.00000000",
                "regular_max_future_total_usd_pos_by_ccy": "10000000000.00000000",
                "regular_max_total_usd_pos_by_ccy": "10000000.00000000",
                "regular_max_stop_open_count": 50,
                "pm_max_open_count": 1000,
                "pm_max_option_open_count_by_ccy": 1000,
                "pm_max_option_open_count_by_instrument": 20,
                "pm_max_future_open_count_by_ccy": 1000,
                "pm_max_future_open_count_by_instrument": 100,
                "pm_max_option_total_usd_pos_by_ccy": "5000000000.00000000",
                "pm_max_future_total_usd_pos_by_ccy": "5000000000.00000000",
                "pm_max_total_usd_pos_by_ccy": "5000000000.00000000",
                "pm_max_stop_open_count": 50
            },
            {
                "ccy": "USDT",
                "ccy_display_name": "USDT",
                "regular_max_open_count": 50,
                "regular_max_option_open_count_by_ccy": 50,
                "regular_max_option_open_count_by_instrument": 20,
                "regular_max_future_open_count_by_ccy": 50,
                "regular_max_future_open_count_by_instrument": 50,
                "regular_max_option_total_usd_pos_by_ccy": "10000000.00000000",
                "regular_max_future_total_usd_pos_by_ccy": "10000000.00000000",
                "regular_max_total_usd_pos_by_ccy": "10000000.00000000",
                "regular_max_stop_open_count": 50,
                "pm_max_open_count": 50,
                "pm_max_option_open_count_by_ccy": 50,
                "pm_max_option_open_count_by_instrument": 20,
                "pm_max_future_open_count_by_ccy": 50,
                "pm_max_future_open_count_by_instrument": 50,
                "pm_max_option_total_usd_pos_by_ccy": "10000000.00000000",
                "pm_max_future_total_usd_pos_by_ccy": "10000000.00000000",
                "pm_max_total_usd_pos_by_ccy": "10000000.00000000",
                "pm_max_stop_open_count": 50
            }
        ]
    }
}

查询U本位currency/pair 级别配置信息。

请求参数

NONE

返回数据

字段名称 数据类型 说明
pairs array 币对配置
ccy_open_order_params array currency open order 配置
字段名称 数据类型 说明
base_ccy string 基础币种
quote_ccy string 报价币种
base_display_name string 基础币种显示名称
quote_display_name string 报价币种显示名称
perpetual_liquidation_fee_rate string 永续强平费率
option_liquidation_fee_rate string 期权强平费率
option_max_delivery_fee_rate string 期权最大交割费率
future_min_order_price string 期货最小下单价格
future_max_order_price string 期货最大下单价格
future_min_order_qty string 期货最小下单数量
future_max_order_qty string 期货最大下单数量
future_price_step string 期货下单价格步长
future_size_step string 期货下单数量步长
order_book_groups string Order book 分组配置
option_min_order_price string 期权最小下单价格
option_max_put_price string 期权PUT最大下单价格(max call = underlying)
option_min_order_qty string 期权最小下单数量
option_max_order_qty string 期权最大下单数量
option_price_step_base string 期权下单base价格步长
option_price_step_quote string 期权下单quote价格步长
option_size_step string 期权下单数量步长
perpetual_taker_fee_rate string 永续taker费率(已废弃,目前使用vip费率等级)
perpetual_maker_fee_rate string 永续maker费率(已废弃,目前使用vip费率等级)
option_taker_fee_rate string 期权taker费率(已废弃,目前使用vip费率等级)
option_maker_fee_rate string 期权maker费率(已废弃,目前使用vip费率等级)
option_max_order_fee_rate string 期权最大下单费率
future_pos_limit_by_pair string 期货币对级别仓位上限
option_pos_limit_by_pair string 期权币对级别仓位上限
option_range_factor string 期权价格范围参数
iv_min_value string 最小Iv
iv_max_value string 最大Iv
blocktrade_future_min_order_price string Blocktrade 期货最小下单价格
blocktrade_future_max_order_price string Blocktrade 期货最大下单价格
blocktrade_future_min_order_qty string Blocktrade 期货最小下单数量
blocktrade_future_max_order_qty string Blocktrade 期货最大下单数量
blocktrade_future_price_step string Blocktrade 期货下单价格步长
blocktrade_future_size_step string Blocktrade 期货下单数量步长
blocktrade_option_min_order_price string Blocktrade 期权最小下单价格
blocktrade_option_max_put_price string Blocktrade 期权PUT最大下单价格(max call = underlying)
blocktrade_option_min_order_qty string Blocktrade 期权最小下单数量
blocktrade_option_max_order_qty string Blocktrade 期权最大下单数量
blocktrade_option_price_step string Blocktrade 期权下单价格步长(quote)
blocktrade_option_size_step string Blocktrade 期权下单数量步长
non_pm_linear_im_rate string Non pm linear im rate(内部使用)
non_pm_linear_mm_rate string Non pm linear mm rate(内部使用)
non_pm_linear_scaling_rate string Non pm linear scaling rate(内部使用)
mi_perp_limit_price_floating_rate string Mi perp limit price floating rate(内部使用)
mi_perp_mark_anchored_upper_limit_rate string Mi perp mark anchored upper limit rate(内部使用)
mi_perp_mark_anchored_lower_limit_rate string Mi perp mark anchored lower limit rate(内部使用)
mi_max_funding_rate string Mi max funding rate(内部使用)
option_im_lower_rate string 期权 im lower rate(内部使用)
option_im_upper_rate string 期权 im upper rate(内部使用)
option_mm_rate string 期权 mm rate(内部使用)
option_mm_coeff string 期权 mm coeff(内部使用)
is_display bool 是否展示
allow_for_pm bool 是否支持pm模式
option_precision string 期权精度
字段名称 数据类型 说明
ccy string 计价币种
ccy_display_name string 币种显示名字
regular_max_open_count integer Regular模式最大未结订单数量
regular_max_option_open_count_by_ccy integer Regular模式最大期权未结订单数量(ccy)
regular_max_option_open_count_by_instrument integer Regular模式最大期权未结订单数量(instrument)
regular_max_future_open_count_by_ccy integer Regular模式最大期货未结订单数量(ccy)
regular_max_future_open_count_by_instrument integer Regular模式最大期货未结订单数量(instrument)
regular_max_option_total_usd_pos_by_ccy string Regular模式最大期权持仓价值(ccy)
regular_max_future_total_usd_pos_by_ccy string Regular模式最大期货持仓价值(ccy)
regular_max_total_usd_pos_by_ccy string Regular模式最大持仓价值(ccy, 期权+期货)
regular_max_stop_open_count integer Regular模式最大条件单未结订单数量
pm_max_open_count integer Pm模式最大未结订单数量
pm_max_option_open_count_by_ccy integer Pm模式最大期权未结订单数量(ccy)
pm_max_option_open_count_by_instrument integer Pm模式最大期权未结订单数量(instrument)
pm_max_future_open_count_by_ccy integer Pm模式最大期货未结订单数量(ccy)
pm_max_future_open_count_by_instrument integer Pm模式最大期货未结订单数量(instrument)
pm_max_option_total_usd_pos_by_ccy string Pm模式最大期权持仓价值(ccy)
pm_max_future_total_usd_pos_by_ccy string Pm模式最大期货持仓价值(ccy)
pm_max_total_usd_pos_by_ccy string Pm模式最大最大持仓价值(ccy, 期权+期货)
pm_max_stop_open_count integer Pm模式最大条件单未结订单数量

获取产品信息

GET /linear/v1/instruments

curl "https://betaapi.bitexch.dev/linear/v1/instruments?currency=USDT"

Response

{
  "code": 0,
  "message": "",
  "data": [
    {
      "instrument_id": "BTC-USDT-PERPETUAL",
      "created_at": 1640944328750,
      "updated_at": 1640944328750,
      "base_currency": "BTC",
      "quote_currency": "USDT",
      "strike_price": "",
      "expiration_at": 4102444800000,
      "option_type": "",
      "category": "future",
      "min_price": "0.00050000",
      "max_price": "1000000.00000000",
      "price_step": "0.01000000",
      "min_size": "0.00010000",
      "size_step": "0.00010000",
      "delivery_fee_rate": "",
      "contract_size": "",
      "contract_size_currency": "BTC",
      "active": true,
      "status": "online",
      "groups": [
        1,
        10,
        100,
        10000
      ],
      "group_steps": [
        "0.01000000",
        "0.10000000",
        "1.00000000",
        "100.00000000"
      ],
      "display_at": 1640944328422,
      "is_display": true
    }
  ]
}

获取产品(期货/期权) 信息, 查询条件: 币种/产品种类。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
category string false "future" 产品种类, 输入"option"查询期权产品
active boolean false true 是否查询活跃产品
count int false 5000 最大返回条数,只适用于有到期日的合约,不适用于永续

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
category string 产品种类
created_at integer 创建时间戳
updated_at integer 更新时间戳
expiration_at integer 到期时间戳 (永续的到期时间设置为2100-01-01)
base_currency string Base币种
quote_currency string Quote币种
option_type string 期权种类: Call/put
strike_price string 期权执行价格
min_price string 最小下单价格(订单价格还受限于 min sell/max buy)
max_price string 最大下单价格(订单价格还受限于 min sell/max buy)
price_step string 价格步长
min_size string 最小下单数量
size_step string 数量步长
delivery_fee_rate string 合约交割费率
contract_size string 合约乘数
contract_size_currency string 合约乘数币种
active bool 是否活跃
status string 产品状态
groups array orderbook 输出精度控制
group_steps array orderbook 输出精度控制
display_at integer 内部使用
is_display bool 内部使用

查询上架期权币对

GET /linear/v1/option_pairs

curl "https://betaapi.bitexch.dev/linear/v1/option_pairs?currency=USDT"

Response


{
    "code": 0,
    "message": "",
    "data": [
        "BTC-USDT",
        "ETH-USDT"
    ]
}

查询有上架期权的币对列表.

Query parameters

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种

Response

字段名称 数据类型 说明
data array 币对列表

获取行情信息

GET /linear/v1/tickers

curl "https://betaapi.bitexch.dev/linear/v1/tickers?instrument_id=BTC-USDT-28APR23-25000-C"

Response


{
    "code": 0,
    "message": "",
    "data": {
        "time": 1680751572771,
        "instrument_id": "BTC-USDT-28APR23-25000-C",
        "best_bid": "3155.00000000",
        "best_ask": "",
        "best_bid_qty": "0.10000000",
        "best_ask_qty": "",
        "ask_sigma": "",
        "bid_sigma": "0.14172180",
        "last_price": "0.00000000",
        "last_qty": "0.00000000",
        "open24h": "2618.00000000",
        "high24h": "2618.00000000",
        "low24h": "2618.00000000",
        "price_change24h": "0.00000000",
        "volume24h": "0.00000000",
        "volume_usd24h": "0.00000000",
        "open_interest": "0.00000000",
        "underlying_name": "BTC-USDT",
        "underlying_price": "28154.92000000",
        "mark_price": "3235.76757442",
        "index_price": "28085.79850000",
        "sigma": "0.34255983",
        "delta": "0.92637271",
        "vega": "9.68923779",
        "theta": "-7.47882399",
        "gamma": "0.00005869",
        "min_sell": "2672.00000000",
        "max_buy": "3799.00000000",
        "display_name": "BTC-USDT-28APR23-25000-C"
    }
}

根据产品名称获取tickers信息。

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
last_price string 最新成交价
last_qty string 最新成交量
open24h string 24小时开盘价
high24h string 24小时最高价
low24h string 24小时最低价
volume24h string 24小时成交量(币)
volume_usd24h string 24小时成交量(USD)
price_change24h string 24小时价格变动
open_interest string 未平仓量
best_bid string 最佳买入价
best_ask string 最佳卖出价
best_bid_qty string 最佳买入数量
best_ask_qty string 最佳卖出数量
bid_sigma string 买入sigma (期权)
ask_sigma string 卖出sigma (期权)
underlying_name string 标的指数(期权)
underlying_price string 标的价格(期权)
funding_rate string 资金费率 (永续)
funding_rate8h string 过去8小时的平均资金费率 (永续)
mark_price string 报价
index_price string 指数价格
sigma string 报价sigma值(期权)
delta string 报价delta值(期权)
vega string 报价vega值(期权)
theta string 报价theta值(期权)
gamma string 报价gamma值(期权)
max_buy string 最大买入价
min_sell string 最小卖出价

获取市场深度

GET /linear/v1/orderbooks

curl "https://betaapi.bitexch.dev/linear/v1/orderbooks?instrument_id=BTC-USDT-PERPETUAL"

返回数据

{
  "code": 0,
  "message": "",
  "data": {
    "instrument_id": "BTC-USDT-PERPETUAL",
    "timestamp": 1642994567453,
    "bids": [
      ["35324.15000000","0.47000000"],
      ["35324.10000000","1.67000000"],
      ["35321.95000000","2.40000000"],
      ["35321.90000000","4.36000000"],
      ["35321.85000000","1.24000000"]
    ],
    "asks": [
      ["35325.15000000","4.68000000"],
      ["35327.80000000","0.53000000"],
      ["35351.00000000","1.00000000"],
      ["35352.00000000","1.00000000"],
      ["35353.00000000","1.00000000"]
    ]
  }
}

根据产品名称获取市场深度。

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
level int false 5 深度层数,范围:[1,50]

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
timestamp integer 时间戳(数据时间)
asks string Asks 队列 [price, qty]
bids string Bids 队列 [price, qty]

获取市场成交记录

GET /linear/v1/market/trades

curl "https://betaapi.bitexch.dev/linear/v1/market/trades?currency=USDT"

返回数据

{
  "code": 0,
  "message": "",
  "data": [
    {
      "created_at": 1642994704633,
      "trade_id": 1005483402,
      "instrument_id": "ETH-USDT-PERPETUAL",
      "price": "2449.20000000",
      "qty": "1.00000000",
      "side": "sell",
      "sigma": "0.00000000",
      "index_price": "2447.79750000",
      "underlying_price": "0.00000000",
      "is_block_trade": false
    },
    {
      "created_at": 1642994704241,
      "trade_id": 1005483400,
      "instrument_id": "ETH-USDT-PERPETUAL",
      "price": "2449.20000000",
      "qty": "1.00000000",
      "side": "sell",
      "sigma": "0.00000000",
      "index_price": "2447.79750000",
      "underlying_price": "0.00000000",
      "is_block_trade": false
    }
  ]
}

获取市场成交记录。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string true "" 币对
category string false "" 产品种类
instrument_id string false "" 产品名称
start_time integer false 开始时间戳
end_time integer false 结束时间戳
count int false 100 返回记录条数(max 500)

返回数据

字段名称 数据类型 说明
trade_id integer 交易ID
instrument_id string 产品名称
created_at integer 成交时间戳
price string 成交价格
qty string 成交数量
side string 方向
index_price string 指数价格
sigma string 隐含波动率 (期权)
underlying_price string 标的价格 (期权)
is_block_trade bool 是否为block trade

获取K线

GET /linear/v1/klines

curl "https://betaapi.bitexch.dev/linear/v1/klines?instrument_id=BTC-USDT-PERPETUAL&timeframe_min=1d"

返回数据

{
  "code": 0,
  "message": "",
  "data": {
    "volume": [
      61311.6006,
      162957.1496,
      170906.31,
      167930.3642,
      57211.0637,
      95668.4807,
      129106.4048,
      87194.38,
      108983.3256,
      47231.55,
      2616.79
    ],
    "timestamps": [
      1642118400000,
      1642204800000,
      1642291200000,
      1642377600000,
      1642464000000,
      1642550400000,
      1642636800000,
      1642723200000,
      1642809600000,
      1642896000000,
      1642982400000
    ],
    "open": [
      42440,
      43069.2,
      43084.9,
      43074.6,
      42208.6,
      41637.7,
      41673.7,
      40705.05,
      36476.35,
      35068,
      36257.45
    ],
    "low": [
      42440,
      42588.3,
      42606.7,
      41557.9,
      41482.2,
      41000,
      40587,
      35556.25,
      34000.45,
      34688.5,
      35194.6
    ],
    "high": [
      43426.5,
      43773.4,
      43451.3,
      43170.9,
      42413.5,
      42538.2,
      43486.65,
      41093.2,
      36797.7,
      36480.6,
      36255.1
    ],
    "close": [
      43069.2,
      43084.9,
      43074.6,
      42208.6,
      41637.7,
      41673.7,
      40705.05,
      36476.35,
      35068,
      36257.45,
      35216.55
    ]
  }
}

按照产品名称获取K线数据。 K线接口返回6个序列数据:开盘价序列、最高价序列、最低价序列、收盘价序列、时间戳序列和交易量序列
支持K线周期:

K线周期 说明
1 1 分钟
3 3 分钟
5 5 分钟
15 15 分钟
30 30 分钟
60 60 分钟
240 240 分钟
1d 1天
1w 1周(自然周)
1m 1月(自然月)

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
start_time integer true 起始时间戳
end_time integer true 结束时间戳
timeframe_min string true "" K线周期(参考上面说明)
count int false 100 每页数据条数 (默认值 100, 最大值 1000)

返回数据

字段名称 数据类型 说明
open float array 开盘价
high float array 最高价
low float array 最低价
close float array 收盘价
timestamps float array 开盘时间戳
volume float array 成交量

查询市场仓位交割信息

GET /linear/v1/market/deliveries

curl "https://betaapi.bitexch.dev/linear/v1/market/deliveries?currency=USDT"

Response

{
    "code": 0,
    "message": "",
    "data": [
        {
            "type": "delivery",
            "timestamp": 1658822400000,
            "instrument_id": "BCH-USDT-26JUL22-110-C",
            "position": "1.00000000",
            "exercise": true,
            "delivery_price": "115.63000000",
            "delivery_pnl": "5.63000000"
        },
        {
            "type": "delivery",
            "timestamp": 1658822400000,
            "instrument_id": "BCH-USDT-26JUL22-110-P",
            "position": "1.00000000",
            "exercise": false,
            "delivery_price": "115.63000000",
            "delivery_pnl": "0.00000000"
        },
        {
            "type": "delivery",
            "timestamp": 1658822400000,
            "instrument_id": "BCH-USDT-26JUL22-115-C",
            "position": "1.00000000",
            "exercise": true,
            "delivery_price": "115.63000000",
            "delivery_pnl": "0.63000000"
        },
        {
            "type": "delivery",
            "timestamp": 1658822400000,
            "instrument_id": "BCH-USDT-26JUL22-115-P",
            "position": "1.00000000",
            "exercise": false,
            "delivery_price": "115.63000000",
            "delivery_pnl": "0.00000000"
        }
    ]
}

查询市场仓位交割信息(交割的仓位/盈亏汇总,是否行权等.)

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
category string false "" 产品种类
instrument_id string false "" 产品名称
limit int false 100 返回记录条数

返回数据

字段名称 数据类型 说明
type string 类型("delivery")
timestamp integer 交割时间
instrument_id string 产品名称
position string 全部正仓位用户交割总仓位
exercise bool 是否行权
delivery_price string 交割价格
delivery_pnl string 全部正仓位用户交割盈亏汇总

获取市场结算价格信息

GET /linear/v1/settlement_prices

curl "https://betaapi.bitexch.dev/linear/v1/settlement_prices?currency=USDT&start_time=1600421456435&end_time=1603013456435"

返回数据

{
  "code": 0,
  "message": "",
  "data": {
    "data": {
      "1642204800000": [
        {
          "date": 1642204800000,
          "currency": "USDT",
          "instrument_id": "BCH-USDT-PERPETUAL",
          "settlement_type": "settlement",
          "price": "389.66802679"
        },
        {
          "date": 1642204800000,
          "currency": "USDT",
          "instrument_id": "BTC-USDT-PERPETUAL",
          "settlement_type": "settlement",
          "price": "43076.50631543"
        },
        {
          "date": 1642204800000,
          "currency": "USDT",
          "instrument_id": "ETH-USDT-PERPETUAL",
          "settlement_type": "settlement",
          "price": "3313.20469611"
        }
      ]
    }
  }
}

获取市场历史结算价格信息.
开始和结束的时间跨度小于或者等于30天.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
instrument_id string false "" 产品名称
start_time integer true 起始时间戳
end_time integer true 结束时间戳

返回数据

字段名称 数据类型 说明
date integer 结算/交割时间戳
currency string 币种
instrument_id string 产品名称 (BTC-OPTIONS表示所有期权)
settlement_type string delivery/settlement
price string 结算/交割价格

获取市场价格汇总信息

GET /linear/v1/market/summary

curl "https://betaapi.bitexch.dev/linear/v1/market/summary?currency=USDT&category=future"

返回数据

{
  "code": 0,
  "message": "",
  "data": [
    {
      "instrument_id": "BTC-USDT-PERPETUAL",
      "timestamp": 1642995368000,
      "best_bid": "35273.15000000",
      "best_ask": "35274.20000000",
      "best_bid_qty": "6.36000000",
      "best_ask_qty": "3.54000000",
      "last_price": "35274.20000000",
      "last_qty": "2.01000000",
      "open24h": "35064.40000000",
      "high24h": "36480.60000000",
      "low24h": "34688.50000000",
      "volume24h": "35162.74000000",
      "open_interest": "94.21840000",
      "mark_price": "35276.43209068",
      "max_buy": "35805.58000000",
      "min_sell": "34747.28000000",
      "delta": "",
      "gamma": "",
      "vega": "",
      "theta": ""
    }
  ]
}

根据产品名称获取市场价格汇总信息。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
category string true "" 产品种类
instrument_id string false "" 产品名称

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
timestamp integer 时间戳
best_bid string 最佳买入价
best_ask string 最佳卖出价
best_bid_qty string 最佳买入数量
best_ask_qty string 最佳卖出数量
last_price string 最新成交价
last_qty string 最新成交数量
open24h string 24小时开盘价
high24h string 24小时最高价
low24h string 24小时最低价
volume24h string 24小时成交量
open_interest string 未平仓量
mark_price string 报价
max_buy string 最大买入价
min_sell string 最小卖出价
delta string 期权delta值
gamma string 期权gamma值
vega string 期权vega值
theta string 期权theta值

查询资金费率

GET /linear/v1/funding_rate

curl "https://betaapi.bitexch.dev/linear/v1/funding_rate?instrument_id=BTC-USDT-PERPETUAL"

Response

返回数据


{
  "code": 0,
  "message": "",
  "data": {
    "instrument_id": "BTC-USDT-PERPETUAL",
    "time": 1635913370000,
    "funding_rate": "0.00000000",
    "funding_rate_8h": "-0.00102858",
    "index_price": "62989.63000000",
    "mark_price": "62969.83608581"
  }
}

查询最新的永续资金费率。 资金费率每10秒更新一次。

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称 (永续)

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
time integer 时间戳
funding_rate string 永续资金费率
funding_rate_8h string 永续过去8小时的平均资金费率
index_price string 指数价格
mark_price string 永续标记价格

查询资金费率历史

GET /linear/v1/funding_rate_history

curl "https://betaapi.bitexch.dev/linear/v1/funding_rate_history?instrument_id=BTC-USDT-PERPETUAL&start_time=1603260000000&end_time=1603346400000&history_type=1H"

返回数据


{
    "code": 0,
    "message": "",
    "data": [
        {
            "instrument_id": "BTC-USDT-PERPETUAL",
            "time": 1603263600000,
            "average_funding_rate": "0.00100000",
            "index_price": "8880.17000000",
            "mark_price": "8900.18000000"
        }
    ]
}

注意: 开始时间须在2020.10.31之后 (timestamp: 1604102400000).

获取时间范围内的资金费率历史,历史种类有1H/8H/24H。

返回时间范围内每3分钟的过去1小时资金费率平均值,对于8小时/24小时历史,返回时间范围内每个整小时时间的过去24小时资金费率平均值。

对于查询1小时历史数据,查询时间范围不能超过1天。 对于查询8小时/24小时历史数据,查询时间范围不能超过30天。

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品ID (只能是永续合约)
start_time integer true 开始时间
end_time integer true 结束时间
history_type string true 1H/8H/24H

返回数据

字段名称 数据类型 说明
instrument_id string 产品ID
time integer 时间戳
average_funding_rate string 过去1小时/8小时/24小时平均历史费率
index_price string 指数价格
mark_price string 永续合约标记价格

获取市场全币种24小时成交量

GET /linear/v1/total_volumes

curl "https://betaapi.bitexch.dev/linear/v1/total_volumes"

Response

{
  "code": 0,
  "message": "",
  "data": {
    "total_usdx_volume_24_hours": "11771592083.60040000",
    "details": [
      {
        "margin_currency": "USD",
        "usdx_option_volume_in_usd": "10000055.21000000",
        "usdx_future_volume_in_usd": "10604770109.18810000"
      },
      {
        "margin_currency": "USDT",
        "usdx_option_volume_in_usd": "0.00000000",
        "usdx_future_volume_in_usd": "1156821919.20230000"
      }
    ]
  }
}

获取市场全币种24小时成交量
缓存5秒钟。

请求参数

返回数据

字段名称 数据类型 说明
total_usdx_volume_24_hours string 总成交量
details array 明细

details

字段名称 数据类型 说明
margin_currency string 计价币种
usdx_option_volume_in_usd string 期权成交量(USD)
usdx_future_volume_in_usd string 期货/永续成交量(USD)

账户信息

统一UM账户信息

GET /um/v1/accounts


curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/um/v1/accounts?timestamp=1589521383462&signature=30f7cf5c8018f5dfee515533e25a1813e9120be7898b62fb85a2f4129f3e9528"

返回数据


{
    "code": 0,
    "message": "",
    "data": {
        "user_id": 481554,
        "created_at": 1649923879505,
        "total_collateral": "3170125.05978108",
        "total_margin_balance": "3170125.05978108",
        "total_available": "3169721.64891398",
        "total_initial_margin": "403.41086710",
        "total_maintenance_margin": "303.16627631",
        "total_initial_margin_ratio": "0.00012725",
        "total_maintenance_margin_ratio": "0.00009563",
        "total_liability": "0.00000000",
        "total_unsettled_amount": "-0.84400340",
        "total_future_value": "1.26000000",
        "total_option_value": "0.00000000",
        "spot_orders_hc_loss": "0.00000000",
        "total_position_pnl": "1225.53245820",
        "details": [
            {
                "currency": "BTC",
                "equity": "78.13359310",
                "liability": "0.00000000",
                "index_price": "41311.20615385",
                "cash_balance": "78.13360190",
                "margin_balance": "78.13359310",
                "available_balance": "78.12382795",
                "initial_margin": "0.00976516",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00733859",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.02966586",
                "total_delta": "0.48532539",
                "session_rpl": "0.00001552",
                "session_upl": "-0.00003595",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_value": "1.23000000",
                "future_pnl": "0.02966586",
                "future_session_rpl": "0.00001552",
                "future_session_upl": "-0.00003595",
                "future_session_funding": "0.00001552",
                "future_delta": "0.48532539",
                "future_available_balance": "76.72788921",
                "option_available_balance": "76.72788921",
                "unsettled_amount": "-0.00002043",
                "usdt_index_price": "41311.20615385"
            },
            {
                "currency": "ETH",
                "equity": "1.99960000",
                "liability": "0.00000000",
                "index_price": "3119.01923077",
                "cash_balance": "1.99960000",
                "margin_balance": "1.99960000",
                "available_balance": "1.99960000",
                "initial_margin": "0.00000000",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00000000",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.00000000",
                "total_delta": "0.00000000",
                "session_rpl": "0.00000000",
                "session_upl": "0.00000000",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_value": "0.03000000",
                "future_pnl": "0.00000000",
                "future_session_rpl": "0.00000000",
                "future_session_upl": "0.00000000",
                "future_session_funding": "0.00000000",
                "future_delta": "0.00000000",
                "future_available_balance": "1.99960000",
                "option_available_balance": "1.99960000",
                "unsettled_amount": "0.00000000",
                "usdt_index_price": "3119.01923077"
            }
        ],
        "usdt_total_collateral": "3170125.05978108",
        "usdt_total_margin_balance": "3170125.05978108",
        "usdt_total_available": "3169721.64891398",
        "usdt_total_initial_margin": "403.41086710",
        "usdt_total_maintenance_margin": "303.16627631",
        "usdt_total_initial_margin_ratio": "0.00012725",
        "usdt_total_maintenance_margin_ratio": "0.00009563",
        "usdt_total_liability": "0.00000000",
        "usdt_total_unsettled_amount": "-0.84400340"
    }
}



UM用户,用此接口获取统一交易账户信息。

PM total_initial_margin_ratio 公式
true (total_im + spot_haircut_loss) / collateral
false (total_im + spot_haircut_loss) / margin_balance

1)如果分子和分母都为0,返回0。
2)否则如果分母 <=0, 返回 "infinity".
3)返回分子/分母

PM total_maintenance_margin_ratio 公式
true total_maintenance_margin / collateral
false total_maintenance_margin / margin_balance

1)如果分子和分母都为0,返回0。
2)否则如果分母 <=0, 返回 "infinity".
3)返回分子/分母

请求参数

参数名称 数据类型 是否必填 默认值 说明
with_linear_pair_margins string false "" linear_pair_margins字段中返回按正向币对分类的保证金数值. 仅支持Portfolio Margin下返回.

返回数据

字段名称 数据类型 说明
user_id int 用户ID
created_at int 时间戳(查询时刻)
total_collateral string 账户维度USD总担保品金额
total_margin_balance string 账户维度USD总保证金余额
total_available string 账户维度USD总可用余额
total_initial_margin string 账户维度USD总初始保证金
total_maintenance_margin string 账户维度USD总维持保证金
total_initial_margin_ratio string 账户维度USD总初始保证金率,可能会返回"infinity"
total_maintenance_margin_ratio string 账户维度USD总维持保证金率,可能会返回"infinity"
total_liability string 账户维度USD总负债
total_unsettled_amount string 账户维度USD总待结金额
total_future_value string 期货总市值
total_option_value string 期权总市值
spot_orders_hc_loss string 现货挂单损失
total_position_pnl string 账户维度USD损益 [SUM(ccy.pnl * ccy.index-price)]
details array 分币种账户信息
usdt_total_collateral string (兼容旧字段) 等于 total_collateral
usdt_total_margin_balance string (兼容旧字段) 等于 total_margin_balance
usdt_total_available string (兼容旧字段) 等于 total_available
usdt_total_initial_margin string (兼容旧字段) 等于 total_initial_margin
usdt_total_maintenance_margin string (兼容旧字段) 等于 total_maintenance_margin
usdt_total_initial_margin_ratio string (兼容旧字段) 等于 total_initial_margin_ratio
usdt_total_maintenance_margin_ratio string (兼容旧字段) 等于 total_maintenance_margin_ratio
usdt_total_liability string (兼容旧字段) 等于 total_liability
usdt_total_unsettled_amount string (兼容旧字段) 等于 total_unsettled_amount
字段名称 数据类型 说明
currency string 币种
equity string 权益
liability string 负债
index_price string USD指数价格
usdt_index_price string (兼容旧字段) 等于 index_price
cash_balance string 现金余额
margin_balance string 保证金余额
available_balance string 可用余额
initial_margin string 初始保证金
spot_margin string 现货冻结金额
maintenance_margin string 维持保证金
potential_liability string 潜在负债
interest string 借币利息
interest_rate string 借币利率
pnl string 币种维度损益
total_delta string 账户delta总值
session_rpl string 已实现损益
session_upl string 未实现损益
option_value string 期权市值
option_pnl string 期权损益
option_session_rpl string 期权已实现损益
option_session_upl string 期权未实现损益
option_delta string 期权delta
option_gamma string 期权gamma
option_vega string 期权vega
option_theta string 期权theta
future_value string 期货市值
future_pnl string 期货损益
future_session_rpl string 期货已实现损益
future_session_upl string 期货未实现损益
future_session_funding string 期货funding
future_delta string 期货delta
future_available_balance string 期货最大可用余额
option_available_balance string 期权最大可用余额
unsettled_amount string 待结金额

当请求中有with_linear_pair_margins=true参数时, 在linear_pair_margins字段中返回一个数组. 仅支持Portfolio Margin下返回.

字段名称 数据类型 说明
pair string 正向币对名称
initial_margin string 币对初始保证金
maintenance_margin string 币对维持保证金

统一UM账户交易日志

GET /um/v1/transactions

curl -H "X-Bit-Access-Key: ak-8e97ac6c-8075-4a94-b2bb-38bd537619fa" "https://betaapi.bitexch.dev/um/v1/transactions?currency=BTC&type=trade-recv&limit=2&timestamp=1620369292928&signature=35d76033f6e251ce85524ec4310417fd555953fff00cd33f3a94e3d27d062965" 


返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "tx_time": 1631240595162,
            "tx_type": "deposit",
            "ccy": "BTC",
            "instrument_id": "",
            "direction": "",
            "qty": "3.20000000",
            "price": "",
            "position": "",
            "fee_paid": "0.00000000",
            "fee_rate": "",
            "funding": "",
            "change": "3.20000000",
            "balance": "107.00000000",
            "order_id": "",
            "trade_id": "",
            "remark": ""
        },
        {
            "tx_time": 1630722195162,
            "tx_type": "spot-trade-recv",
            "ccy": "BTC",
            "instrument_id": "BTC-USD",
            "direction": "buy",
            "qty": "2.00000000",
            "price": "60000.00000000",
            "position": "",
            "fee_paid": "0.00030000",
            "fee_rate": "0.00000000",
            "funding": "",
            "change": "2.00000000",
            "balance": "102.00000000",
            "order_id": "9001",
            "trade_id": "3001",
            "remark": ""
        }
    ],
    "page_info": {
        "has_more": false
    }
}

查询统一交易账户的交易日志。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string false "" 币种
instrument_id string false "" 产品名称
start_time integer false Three month ago 起始时间戳
end_time integer false Now 结束时间戳
type string false "" UM交易日志类型
merge_twap_market bool false 交易流水如果是twap market生成,展示twap market订单id
offset int false 1 分页偏移(第一页为1)
limit int false 100 分页大小

返回数据

参数名称 数据类型 说明
tx_time integer 时间戳
tx_type string UM交易日志类型
ccy string 币种
instrument_id string 产品名称
direction string 方向: buy/sell
qty string 数量
price string 交易价格 (针对trade交易类型有效)
position string 期权/期货仓位
fee_paid string 手续费
fee_rate string 手续费率
funding string 资金费用
change string 账户变动
cash_flow string 现金流(现货cash_flow=change, 期权/期货请参考期权/期货的transactions文档)
balance string 变动后的余额
order_id string 订单ID
trade_id string 交易ID
remark string 备注

查询用户配置

GET /linear/v1/account_configs

curl -H "X-Bit-Access-Key: ak-7656c65e-6643-4668-807f-32d84a60eda5" "https://betaapi.bitexch.dev/linear/v1/account_configs?timestamp=1677679210295&signature=1273631a3152f5ad6dca3258788b3f7dc39373fcd7c3ab2c22b1080acee56d60" 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "ccy_open_params": [
            {
                "ccy": "USD",
                "ccy_display_name": "USD",
                "is_pm": false,
                "is_cust": false,
                "max_open_count": 1000,
                "max_option_open_count_by_ccy": 1000,
                "max_option_open_count_by_instrument": 50,
                "max_future_open_count_by_ccy": 1000,
                "max_future_open_count_by_instrument": 100,
                "max_option_total_usd_pos_by_ccy": "10000000.00000000",
                "max_future_total_usd_pos_by_ccy": "10000000000.00000000",
                "max_total_usd_pos_by_ccy": "10000000.00000000",
                "max_stop_open_count": 50
            },
            {
                "ccy": "USDT",
                "ccy_display_name": "USDT",
                "is_pm": false,
                "is_cust": false,
                "max_open_count": 50,
                "max_option_open_count_by_ccy": 50,
                "max_option_open_count_by_instrument": 20,
                "max_future_open_count_by_ccy": 50,
                "max_future_open_count_by_instrument": 50,
                "max_option_total_usd_pos_by_ccy": "10000000.00000000",
                "max_future_total_usd_pos_by_ccy": "10000000.00000000",
                "max_total_usd_pos_by_ccy": "10000000.00000000",
                "max_stop_open_count": 50
            }
        ],
        "pairs": [
            {
                "base_ccy": "BTC",
                "quote_ccy": "USD",
                "base_display_name": "BTC",
                "quote_display_name": "USD",
                "customize_future_fee_rates": false,
                "perpetual_taker_fee_rate": "0.00080000",
                "perpetual_maker_fee_rate": "-0.00020000",
                "customize_option_fee_rates": true,
                "option_taker_fee_rate": "0.00020000",
                "option_maker_fee_rate": "0.00010000",
                "customize_blocktrades": true,
                "blocktrade_future_min_order_price": "0.00100000",
                "blocktrade_future_max_order_price": "1000000.00000000",
                "blocktrade_future_min_order_qty": "0.00100000",
                "blocktrade_future_max_order_qty": "40000.00000000",
                "blocktrade_future_price_step": "0.00100000",
                "blocktrade_future_size_step": "0.00100000",
                "blocktrade_option_min_order_price": "0.00100000",
                "blocktrade_option_max_put_price": "500.00000000",
                "blocktrade_option_min_order_qty": "0.00100000",
                "blocktrade_option_max_order_qty": "1000000.00000000",
                "blocktrade_option_price_step": "0.00100000",
                "blocktrade_option_size_step": "0.00100000",
                "customize_pos_limit": false,
                "future_pos_limit_by_pair": "500000.00000000",
                "option_pos_limit_by_pair": "1000000.00000000"
            }
        ],
        "feerate_class_list": [
            {
                "base_ccy": "BTC",
                "quote_ccy": "USD",
                "base_display_name": "BTC",
                "quote_display_name": "USD",
                "perpetual_fee_rate_info": {
                    "pair": "BTC-USD",
                    "taker_fee_rate": "0.00300000",
                    "maker_fee_rate": "0.00100000",
                    "source": "vip_manual",
                    "taker_basic": "0.00080000",
                    "maker_basic": "0.00020000",
                    "taker_user_defined": "",
                    "maker_user_defined": "",
                    "taker_vip_level": "0.00300000",
                    "maker_vip_level": "0.00100000",
                    "has_vip_level": true,
                    "vip_level": 2
                },
                "option_fee_rate_info": {
                    "pair": "BTC-USD",
                    "taker_fee_rate": "0.00700000",
                    "maker_fee_rate": "0.00200000",
                    "source": "vip_manual",
                    "taker_basic": "0.00100000",
                    "maker_basic": "0.00050000",
                    "taker_user_defined": "",
                    "maker_user_defined": "",
                    "taker_vip_level": "0.00700000",
                    "maker_vip_level": "0.00200000",
                    "has_vip_level": true,
                    "vip_level": 2
                }
            }
        ]                
    }
}

查询U本位用户配置.

请求参数

NONE

返回数据

字段名称 数据类型 说明
pairs array 币对配置
ccy_open_params array currency open order 配置
字段名称 数据类型 说明
base_ccy string 基础币种
quote_ccy string 报价币种
base_display_name string 基础币种显示名称
quote_display_name string 报价币种显示名称
customize_future_fee_rates bool 是否定制永续费率(已废弃,目前使用 vip 费率等级)
perpetual_taker_fee_rate string 永续 taker 费率(已废弃,目前使用 vip 费率等级)
perpetual_maker_fee_rate string 永续 maker 费率(已废弃,目前使用 vip 费率等级)
customize_option_fee_rates bool 是否定制期权费率(已废弃,目前使用 vip 费率等级)
option_taker_fee_rate string 期权 taker 费率(已废弃,目前使用 vip 费率等级)
option_maker_fee_rate string 期权 maker 费率(已废弃,目前使用 vip 费率等级)
customize_blocktrades bool 是否定制 Blocktrade 参数
blocktrade_future_min_order_price string Blocktrade 期货最小下单价格
blocktrade_future_max_order_price string Blocktrade 期货最大下单价格
blocktrade_future_min_order_qty string Blocktrade 期货最小下单数量
blocktrade_future_max_order_qty string Blocktrade 期货最大下单数量
blocktrade_future_price_step string Blocktrade 期货下单价格步长
blocktrade_future_size_step string Blocktrade 期货下单数量步长
blocktrade_option_min_order_price string Blocktrade 期权最小下单价格
blocktrade_option_max_put_price string Blocktrade 期权 PUT 最大下单价格(max call = underlying)
blocktrade_option_min_order_qty string Blocktrade 期权最小下单数量
blocktrade_option_max_order_qty string Blocktrade 期权最大下单数量
blocktrade_option_price_step string Blocktrade 期权下单价格步长(quote)
blocktrade_option_size_step string Blocktrade 期权下单数量步长
customize_pos_limit bool 是否定制持仓上限
future_pos_limit_by_pair string 期货币对级别仓位上限
option_pos_limit_by_pair string 期权币对级别仓位上限
字段名称 数据类型 说明
base_ccy string 基础币种
quote_ccy string 报价币种
base_display_name string 基础币种显示名称
quote_display_name string 报价币种显示名称
perpetual_fee_rate_info.pair string 币对
perpetual_fee_rate_info.has_vip_level bool 用户是否有 VIP 级别
perpetual_fee_rate_info.vip_level integer VIP 级别
perpetual_fee_rate_info.taker_basic string 产品的永续 taker 费率
perpetual_fee_rate_info.maker_basic string 产品的永续 maker 费率
perpetual_fee_rate_info.taker_user_defined string 定制的永续 taker 费率
perpetual_fee_rate_info.maker_user_defined string 定制的永续 maker 费率
perpetual_fee_rate_info.taker_vip_level string VIP 级别的永续 taker 费率
perpetual_fee_rate_info.maker_vip_level string VIP 级别的永续 maker 费率
perpetual_fee_rate_info.source string 费率来源
perpetual_fee_rate_info.taker_fee_rate string 最终生效的永续 taker 费率
perpetual_fee_rate_info.maker_fee_rate string 最终生效的永续 maker 费率
option_fee_rate_info.pair string 币对
option_fee_rate_info.has_vip_level bool 用户是否有 VIP 级别
option_fee_rate_info.vip_level integer VIP 级别
option_fee_rate_info.taker_basic string 产品的期权 taker 费率
option_fee_rate_info.maker_basic string 产品的期权 maker 费率
option_fee_rate_info.taker_user_defined string 定制的期权 taker 费率
option_fee_rate_info.maker_user_defined string 定制的期权 maker 费率
option_fee_rate_info.taker_vip_level string VIP 级别的期权 taker 费率
option_fee_rate_info.maker_vip_level string VIP 级别的期权 maker 费率
option_fee_rate_info.source string 费率来源
option_fee_rate_info.taker_fee_rate string 最终生效的期权 taker 费率
option_fee_rate_info.maker_fee_rate string 最终生效的期权 maker 费率
字段名称 数据类型 说明
ccy string 计价币种
ccy_display_name string 币种显示名字
is_pm bool 是否 pm 模式
is_cust bool 下面参数是否为定制参数
max_open_count integer 最大未结订单数量
max_option_open_count_by_ccy integer 最大期权未结订单数量(ccy)
max_option_open_count_by_instrument integer 最大期权未结订单数量(instrument)
max_future_open_count_by_ccy integer 最大期货未结订单数量(ccy)
max_future_open_count_by_instrument integer 最大期货未结订单数量(instrument)
max_option_total_usd_pos_by_ccy string 最大期权持仓价值(ccy)
max_future_total_usd_pos_by_ccy string 最大期货持仓价值(ccy)
max_total_usd_pos_by_ccy string 最大持仓价值(ccy, 期权+期货)
max_stop_open_count integer 最大条件单未结订单数量

查询计息记录

GET /um/v1/interest_records


curl -H "X-Bit-Access-Key: ak-8e97ac6c-8075-4a94-b2bb-38bd537619fa" "https://betaapi.bitexch.dev/um/v1/interest_records?currency=BTC&timestamp=1631669478618&signature=3d4685f07751cd51f42ee631938f189cbe6e9712cc6d559881e5b3b6d1ba1224" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "currency": "BTC",
            "time": 1631559600000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.05000000"
        },
        {
            "currency": "BTC",
            "time": 1631556000000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.06000000"
        },
        {
            "currency": "BTC",
            "time": 1631552400000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.07000000"
        }
    ],
    "page_info": {
        "has_more": true
    }
}

只有UM模式用户可启用借币功能。此接口用于获取统一保证金UM账户的计息记录。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
start_time integer false One month ago 起始时间戳
end_time integer false Now 结束时间戳
offset int false 1 分页偏移(第一页为1)
limit int false 100 分页大小

返回数据

参数名称 数据类型 说明
currency string 币种
time integer 计息时间戳
loan_rate string 计息利率
liability string 计息负债
interest string 利息

查询用户仓位

GET /linear/v1/positions

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/positions?currency=USDT&instrument_id=BTC-USDT-PERPETUAL&timestamp=1589521619990&signature=9a7f7704cb4d6ec3cd2dccbd55e09ce8abd1ffb48529a742337706dd1a43eea8" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "instrument_id": "BTC-USDT-PERPETUAL",
            "expiration_at": 4102444800000,
            "qty": "-0.20000000",
            "initial_margin": "67.04199679",
            "maintenance_margin": "50.30660069",
            "avg_price": "17047.79250000",
            "session_avg_price": "16785.93357500",
            "mark_price": "16735.39610357",
            "index_price": "16819.49357143",
            "last_price": "16648.00000000",
            "qty_base": "-0.20000000",
            "liq_price": "7651872.25400846",
            "session_funding": "-50.22633841",
            "position_pnl": "62.47927929",
            "position_session_upl": "10.10749429",
            "position_session_rpl": "-50.22633841",
            "category": "future",
            "roi": "0.93194240",
            "leverage": "50.00000000",
            "adl_level": "4",
        }
    ]
}

查询用户仓位.
qty and qty_base 带方向, 正数为多仓,负数为空仓。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
category string false "" 产品类别
instrument_id string false "" 产品名称

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
qty string 仓位,带方向(U本位单位为币)
qty_base string 仓位, 带方向(U本位单位为币),等于qty
avg_price string 开仓均价
index_price string 指数价格
mark_price string 标记价格
initial_margin string 初始保证金
maintenance_margin string 维持保证金
session_funding string 当前周期funding(8小时结算一次)
position_pnl string 仓位损益
category string 产品种类
roi string 回报率
option_delta string 期权 delta(期货隐藏此字段)
option_gamma string 期权 gamma(期货隐藏此字段)
option_vega string 期权 vega(期货隐藏此字段)
option_theta string 期权 theta(期货隐藏此字段)
liq_price string 预估强平价(期货)
leverage string 杠杆率(期货)
adl_level string ADL 等级(值为1,2,3,4), 等级越高,被强平减仓的机会越大
session_avg_price string 持仓均价
position_session_upl string 仓位未实现损益
position_session_rpl string 仓位已实现损益

查询聚合用户仓位

GET /linear/v1/aggregated/positions

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/aggregated/positions?currency=USDT&instrument_id=BTC-USDT-PERPETUAL&timestamp=1589521619990&signature=9a7f7704cb4d6ec3cd2dccbd55e09ce8abd1ffb48529a742337706dd1a43eea8" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "instrument_id": "BTC-USDT-PERPETUAL",
            "expiration_at": 4102444800000,
            "qty": "-0.20000000",
            "initial_margin": "67.04199679",
            "maintenance_margin": "50.30660069",
            "avg_price": "17047.79250000",
            "session_avg_price": "16785.93357500",
            "mark_price": "16735.39610357",
            "index_price": "16819.49357143",
            "last_price": "16648.00000000",
            "qty_base": "-0.20000000",
            "liq_price": "7651872.25400846",
            "session_funding": "-50.22633841",
            "position_pnl": "62.47927929",
            "position_session_upl": "10.10749429",
            "position_session_rpl": "-50.22633841",
            "category": "future",
            "roi": "0.93194240",
            "leverage": "50.00000000",
            "adl_level": "4",
        }
    ]
}

查询当前用户和所有子账户的仓位.

qty and qty_base 带方向, 正数为多仓,负数为空仓。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
category string false "" 产品类别
instrument_id string false "" 产品名称

返回数据

字段名称 数据类型 说明
instrument_id string 产品名称
qty string 仓位,带方向(U本位单位为币)
qty_base string 仓位, 带方向(U本位单位为币),等于qty
avg_price string 开仓均价
index_price string 指数价格
mark_price string 标记价格
initial_margin string 初始保证金
maintenance_margin string 维持保证金
session_funding string 当前周期funding(8小时结算一次)
position_pnl string 仓位损益
category string 产品种类
roi string 回报率
option_delta string 期权 delta(期货隐藏此字段)
option_gamma string 期权 gamma(期货隐藏此字段)
option_vega string 期权 vega(期货隐藏此字段)
option_theta string 期权 theta(期货隐藏此字段)
liq_price string 预估强平价(期货)
leverage string 杠杆率(期货)
adl_level string ADL 等级(值为1,2,3,4), 等级越高,被强平减仓的机会越大
session_avg_price string 持仓均价
position_session_upl string 仓位未实现损益
position_session_rpl string 仓位已实现损益

查询用户交割记录

GET /linear/v1/user/deliveries

curl -H "X-Bit-Access-Key: ak-8628663d-678c-49b0-8d4e-a8691152a2d0" "https://betaapi.bitexch.dev/linear/v1/user/deliveries?currency=USDT&pair=BTC-USDT&timestamp=1659186383799&signature=cc17d4d9f67aabb254ba58085ea6bf498122d88cdf0f991e983674c1bb3a1e2b" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [{
        "type": "delivery",
        "timestamp": 1588492890000,
        "instrument_id": "BTC-30JUL22-23000-C",
        "position": "1.00000000",
        "exercise": true,
        "delivery_price": "23950.37000000",
        "delivery_pnl": "170.60000680"
    }]
}

查询用户交割记录.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
instrument_id string false "" 产品名称
start_time integer false 0 起始时间戳
end_time integer false 0 结束时间戳
count int false 100 返回条数 (default 100, max 500)

返回数据

字段名称 数据类型 说明
type string Settlement type (delivery)
instrument_id string 产品名称
position string 交割仓位
timestamp integer 交割时间戳
exercise boolean 是否行权
delivery_price string 交割价格
delivery_pnl string 交割损益

查询用户结算记录

GET /linear/v1/user/settlements


curl -H "X-Bit-Access-Key: ak-c1d4bc58-37f3-49da-93b5-396ab44b1543" "https://betaapi.bitexch.dev/linear/v1/user/settlements?currency=BTC&offset=1&limit=10&timestamp=1590851451072&signature=538b4ed2b917db4c96e12ddb5daafe84b58f566173f4d003533c19ccc32ff177" 


返回数据

{
    "code": 0,
    "message": "",
    "data": [{
        "type": "settlement",
        "timestamp": 1590825600000,
        "instrument_id": "BTC-USDT-PERPETUAL",
        "position": "-28.00000000",
        "direction": "short",
        "session_upl": "-1000.02754390",
        "session_rpl": "1343.00125935",
        "session_funding": "-973.00028997",
        "price": "32000"
    }]
}

已经废弃.

请使用 GET /um/v1/transactions type = 'usdx-funding-settlement'

查询用户交割记录.

请求参数

字段名称 数据类型 是否必填 默认值 说明
settlement_currency string true "" 结算币种
instrument_id string false "" 产品名称
start_time integer false 0 起始时间戳
end_time integer false 0 结束时间戳
offset int false 1 分页偏移(第一页为1)
limit int false 100 分页大小

返回数据

字段名称 数据类型 说明
type string 结算类型 (settlement)
timestamp integer 时间戳
instrument_id string 产品名称
position string 结算仓位
direction string 方向
session_upl string 未实现损益
session_rpl string 已实现损益
session_funding string 永续funding
price string 结算价格

查询MMP状态

GET /linear/v1/mmp_state

curl -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f" "https://betaapi.bitexch.dev/linear/v1/mmp_state?timestamp=1600050649936&signature=3a3c511ab776674c4a8db31135f22c8bf2bc5aac4eb0070c8c4d577e89e01643" 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "mmp_enabled": true,
        "mmp_user_configurable": true,
        "mmp_data": [
            {
                "pair": "BTC-USD",
                "mmp_config": {
                    "window_ms": 2000,
                    "frozen_period_ms": 10000,
                    "qty_limit": "30.00000000",
                    "delta_limit": "10.00000000"
                },
                "mmp_state": {
                    "mmp_frozen_until_ms": -1,
                    "mmp_frozen": false
                }
            },
            {
                "pair": "ETH-USD",
                "mmp_config": {
                    "window_ms": 5000,
                    "frozen_period_ms": 100,
                    "qty_limit": "100.00000000",
                    "delta_limit": "100.00000000"
                },
                "mmp_state": {
                    "mmp_frozen_until_ms": -1,
                    "mmp_frozen": false
                }
            },
            {
                "pair": "BCH-USD",
                "mmp_config": {
                    "window_ms": 5000,
                    "frozen_period_ms": 100,
                    "qty_limit": "100.00000000",
                    "delta_limit": "100.00000000"
                },
                "mmp_state": {
                    "mmp_frozen_until_ms": -1,
                    "mmp_frozen": false
                }
            },
        ]
    }
}

查询MMP状态.

mmp_enabled
MMP是否开启.

mmp_user_configurable
用户是否可以更改MMP配置, 如果为true,用户可以调用 POST /linear/v1/update_mmp_config

mmp_data
MMP 配置参数和状态列表,针对每一个交易对:

mmp_frozen_until_ms
mmp_frozen_until_ms 显示冻结状态.
mmp_frozen_until_ms > 0: 冻结到指定时间戳,或者手动reset MMP解冻
mmp_frozen_until_ms = 0: 冻结直到reset MMP解冻
mmp_frozen_until_ms = -1: 解冻状态

mmp_frozen
显示MMP是否已经冻结.

请求参数

None

返回数据

字段名称 数据类型 说明
mmp_enabled bool MMP 是否开启
mmp_user_configurable bool 用户是否可以修改MMP配置
mmp_data array MMP配置和状态列表(如下)
字段名称 数据类型 说明
window_ms integer MMP滚动时间窗口
frozen_period_ms integer MMP冻结时间窗口
qty_limit string MMP数量上限 (in base currency, e.g. BTC)
delta_limit string MMP delta 上限 (in base currency, e.g. BTC)
字段名称 数据类型 说明
mmp_frozen_until_ms integer MMP冻结时间戳
mmp_frozen bool MMP是否冻结

更新MMP配置

POST /linear/v1/update_mmp_config

curl -X POST "https://betaapi.bitexch.dev/linear/v1/update_mmp_config" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f"  -d '{"pair": "BTC-USD", "window_ms": 20000, "frozen_period_ms": 30000, "qty_limit": "1000.00000000", "delta_limit": "1000.00000000", "timestamp": 1600050944127, "signature": "661b535fa878633718922fd90b419de4b5d9ae447833876b91bc8bcc7906e0f3"}' 

返回数据

{
    "code": 0,
    "message": "",
    "data": "ok"
}    

更新MMP配置参数 仅当mmp.user_configurable = true, 可以调用此函数,否则返回错误。

MMP冻结状态会触发当 qty >= qty_limit 或者 abs(delta) >= delta_limit.

window_ms: MMP 滚动时间窗口
frozen_period_ms: MMP 冻结时间窗口
qty_limit: MMP 数量上限 (in base currency, e.g. BTC)
delta_limit: MMP delta 上限 (in base currency, e.g. BTC)




请求参数

字段名称 数据类型 是否必填 默认值 说明
pair string true "" 交易对
window_ms integer true 0 MMP 滚动时间窗口
frozen_period_ms integer true 0 MMP 冻结时间窗口
qty_limit string true "" MMP 数量上限 (in base currency, e.g. BTC)
delta_limit string true "" MMP delta 上限 (in base currency, e.g. BTC)

返回数据

字段名称 数据类型 说明
data string ok

重置MMP状态

POST /linear/v1/reset_mmp

curl -X POST "https://betaapi.bitexch.dev/linear/v1/reset_mmp" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f"  -d '{"pair": "BTC-USD", "timestamp": 1600050689085, "signature": "992507afc30728c2bc55d7bf7f47e76126ce3f40ddebc205594877381c4374fa"}' 

返回数据

{
    "code": 0,
    "message": "",
    "data": "ok"
}    

重置MMP状态(解冻),用户可以继续下MMP订单。

请求参数

字段名称 数据类型 是否必填 默认值 说明
pair string true "" 交易对

返回数据

字段名称 数据类型 说明
data string ok

查询用户杠杆率

GET /linear/v1/leverage_ratio

curl -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f" "https://betaapi.bitexch.dev/linear/v1/leverage_ratio?pair=BTC-USDT&timestamp=1600050649936&signature=a6f2511ab776674c4a9db39835f22c8bf2bc5aac4eb0070c8c4d577e89e016ef" 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "pair": "BTC-USD",
        "leverage_ratio": "20.00000000"
    }
}    

查下用户杠杆率

请求参数

字段名称 数据类型 是否必填 默认值 说明
pair string true "" 币对

返回数据

字段名称 数据类型 说明
pair string 币对
leverage_ratio string 杠杆率

更新用户杠杆率

POST /linear/v1/leverage_ratio

curl -X POST "https://betaapi.bitexch.dev/linear/v1/leverage_ratio" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f"  -d '{"pair": "BTC-USD", "leverage_ratio": "10.00000000", "timestamp": 1600050944127, "signature": "251b535fa878633718922fd90b419de4b5d9ae447833876b91bc8bcc7906ee72"}' 

返回数据


{
    "code": 0,
    "message": "",
    "data": {
        "pair": "BTC-USD",
        "leverage_ratio": "10.00000000"
    }
} 

更新用户杠杆率

请求参数

字段名称 数据类型 是否必填 默认值 说明
pair string true "" 币对
leverage_ratio string true 0 新的杠杆率

返回数据

字段名称 数据类型 说明
pair string 币对
leverage_ratio string 新的杠杆率

开启或关闭COD(Cancel On Disconnect)

POST /v1/account_configs/cod

curl -X POST "https://betaapi.bitexch.dev/v1/account_configs/cod" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113"  -d '{"cod":true, "timestamp": 1590572422557, "signature": "3c8c2271a58e3d11dfbd262a6be40ebdd07e8f394a002db0065068b36bc66d5a"}'

返回数据

{
    "code": 0,
    "message": "",
    "data": {
    }
}

开启或关闭COD, 如果COD是开启状态, 同时全部私有频道的连接都断开的话, 这个账户的所有未结订单都会被撤销.

请求参数

字段名称 数据类型 是否必填 默认值 说明
cod bool true "" 开启或关闭COD

返回数据

None


查询COD配置

GET /v1/account_configs/cod

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/v1/account_configs/cod?timestamp=1588932548594&signature=d642b046b247bf00ba285bb260582aadf33e98d2b47d26479b99cc1a7941f807"

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "cod": true
    }
}

查询COD配置.

请求参数

返回数据

字段名称 数据类型 说明
cod bool COD是否开启

订单管理

下单

POST /linear/v1/orders

curl -X POST "https://betaapi.bitexch.dev/linear/v1/orders" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113"  -d '{"instrument_id": "BTC-USDT-PERPETUAL", "price": "5000", "qty": "3", "side": "buy", "time_in_force": "gtc", "auto_price": "", "label":"hedge", "hidden": false, "timestamp": 1589523989378, "signature": "68b658eb68f4ce529623bb4505f5c1c6408b37064a9a5f2102d08088e59d917c"}' 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "order_id": "17552314",
        "created_at": 1589523803017,
        "updated_at": 1589523803017,
        "user_id": "51140",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "order_type": "limit",
        "side": "buy",
        "price": "50000.00000000",
        "qty": "3.00000000",
        "time_in_force": "gtc",
        "avg_price": "0.00000000",
        "filled_qty": "0.00000000",
        "status": "open",
        "is_liquidation": false,
        "auto_price": "0.00000000",
        "auto_price_type": "",
        "taker_fee_rate": "0.00050000",
        "maker_fee_rate": "0.00020000",
        "label":"hedge",
        "stop_price": "0.00000000",
        "reduce_only": false,
        "post_only": false,
        "reject_post_only": false,
        "mmp":false,
        "source": "api",
        "hidden": false,
        "fee": "0.000000000000",
        "fee_ccy": "USDT",
        "fee_deduction_enabled": true,
        "fee_in_deduction_ccy": "0.088423738581",
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000"
    }
}

下一个新订单。
订单类型的默认值是"限价单limit”,订单为市价单market时,价格字段非必填。
生效时间的默认值是‘gtc’。
订单qty单位是币(e.g. BTC)


条件单:
* 订单类型有 trigger-limit/trigger-market。
* 条件单价格(stop_price)是指触发的条件价格,价格(price)是触发条件价格后的订单下单价格。
* 支持以last-price为触发价格。当last_price达到stop_price 时,则被触发下单。


自动价格类型:
*base:下单时,设置"auto price type"为'base',"auto price"为Base 币种计价的值。订单价格将按auto_price * underlying_price公式进行计算,订单每6秒钟进行一次重新报价。
*iv:下单时,设置"auto price"为'iv',"auto price"为隐含波动率计价的值。订单价格将按convert_iv_to_usd(auto_price) 公式进行计算,并且订单每6秒进行一次重新报价。示例:想设置隐含波动率85.56%,应输入 85.56。

bbo(best-bid-offer) 订单:如果 "bbo"是'true',下单价格取对手价,(买单为卖一价, 卖单为买一价), 如果没有对手价,价格取标记价格。 批量下单不支持对手价下单。


mmp(market-maker-protect) 订单: 如果用户为MMP用户,且允许用户自定义修改MMP参数时,order下单接口中 "mmp" 字段可生效(可以为'true'也可为'false');如果用户为MMP用户,且不允许用户自定义修改MMP参数时,order下单接口中limit gtc订单强制"mmp"字段为'true'值。


Example:
Twap order: p1
Child orders(like other exchange orders): o1, o2, o3
Trades of child order: t1-1, t1-2 (trades of o1), t2-6(trade of o2), t3-7(trade of o3)

Query orders: GET /linear/v1/orders

Query trade: GET /linear/v1/user/trades

Query transactions(GET /um/v1/transactions)


请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
qty string true "" 订单数量(正数)
side string true "" 方向
price string false "0.0" 订单价格(市价单不用填)
order_type string false "limit" 订单类型
time_in_force string false "gtc" 生效时间
auto_price_type string false "" U本位自动价格类型
auto_price string false "" 自动价格, 仅当 "自动价格类型"为 'base','iv'时需要。 *iv 是百分比, 85.56 代表 85.56%
label string false "" 用户方唯一订单Label,由用户方维护
stop_price string false "" 条件单触发价格
trigger_type string false "" 条件单触发类型 (mark-price/last-price)
post_only bool false false 是否post only单
如果 reject_post_only = true, post only单进不了orderbook就会被撤销.
如果 reject_post_only = false, post only单进不了orderbook就会被修改价格。
reject_post_only bool false false 作为maker挂单时不支持改价。当"post_only"为'是'时,该字段有效。
bbo bool false false 是否 bbo 单,是否为对手价下单
reduce_only bool 是否减仓单(只支持永续)
mmp bool false false 是否 mmp 单
hidden bool false false 是否 hidden单, hidden单不在公共orderbook显示

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方唯一订单ID,由用户方维护
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
source string 订单来源
hidden bool 是否隐藏订单
fee string 手续费
fee_ccy string 手续费单位
fee_deduction_enabled bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

批量下单

POST /linear/v1/batchorders


curl -X POST "https://betaapi.bitexch.dev/linear/v1/batchorders" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f"  -d '{"currency":"USDT", "orders_data": [{"instrument_id": "BTC-USDT-", "price": "50000", "qty": "1.5", "side": "buy", "hidden": true}, {"instrument_id": "BTC-USDT-PERPETUAL", "price": "50010", "qty": "2", "side": "sell"}], "timestamp": 1596782252388, "signature": "0b8b64d2f35f9742a17af4ee0b993d0248a27a98f320abbfe8e7316f184e30d5"}' 


返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "orders": [
            {
                "order_id": "",
                "created_at": 0,
                "updated_at": 0,
                "user_id": "",
                "instrument_id": "",
                "order_type": "",
                "side": "",
                "price": "",
                "qty": "",
                "time_in_force": "",
                "avg_price": "",
                "filled_qty": "",
                "status": "",
                "is_liquidation": false,
                "auto_price": "",
                "auto_price_type": "",
                "taker_fee_rate": "",
                "maker_fee_rate": "",
                "label": "",
                "reduce_only": false,
                "post_only": false,
                "reject_post_only": false,
                "mmp": false,
                "source": "api",
                "hidden": true,
                "fee": "0.000000000000",
                "fee_ccy": "USDT",
                "fee_deduction_enabled": true,
                "fee_in_deduction_ccy": "0.088423738581",
                "fee_deduction_ccy": "TONCOIN",
                "fee_deduction_rate": "0.202100000000",
                "error_code": 18100185,
                "error_msg": "Invalid instrument BTC-USDT-"
            },
            {
                "order_id": "501758",
                "created_at": 1596782252996,
                "updated_at": 1596782252996,
                "user_id": "51140",
                "instrument_id": "BTC-USDT-PERPETUAL",
                "order_type": "limit",
                "side": "sell",
                "price": "50010.00000000",
                "qty": "2.00000000",
                "time_in_force": "gtc",
                "avg_price": "0.00000000",
                "filled_qty": "0.00000000",
                "status": "open",
                "is_liquidation": false,
                "auto_price": "0.00000000",
                "auto_price_type": "",
                "taker_fee_rate": "0.00045000",
                "maker_fee_rate": "0.00025000",
                "label": "",
                "reduce_only": false,
                "post_only": false,
                "reject_post_only": false,
                "mmp": false,
                "source": "api",
                "hidden": false,
                "fee": "0.000000000000",
                "fee_ccy": "USDT",
                "fee_deduction_enabled": true,
                "fee_in_deduction_ccy": "0.088423738581",
                "fee_deduction_ccy": "TONCOIN",
                "fee_deduction_rate": "0.202100000000",
                "error_code": 0,
                "error_msg": ""
            }
        ]
    }
}

批量下单。
提供订单数组,订单信息同下单接口POST /linear/v1/orders。
批量下单不支持条件单。
批量下单最大下单数为10。


请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
orders_data array true 请求列表(如下)
字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
qty string true "" 订单数量(正数)
side string true "" 方向
price string false "0.0" 订单价格(市价单不用填)
order_type string false "limit" 订单类型
time_in_force string false "gtc" 生效时间
label string false "" 用户方唯一订单ID,由用户方维护
post_only bool false false 是post only单,则支持仅作为maker挂单,不立即成交。限价单且生效时间类型为'gtc'时该字段有效。条件单暂不支持该设置。
reject_post_only bool false false 是reject单,作为maker挂单时不支持改价。当"post_only"为'是'时,该字段有效。
reduce_only bool 是否减仓单(只支持永续)
mmp bool false false 是否 mmp 单

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方唯一订单ID,由用户方维护
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
source string 订单来源
hidden bool 是否隐藏订单
fee string 手续费
fee_ccy string 手续费单位
fee_deduction_enabled bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例
error_code int 订单请求错误码: 0为成功,否则为失败
error_msg string 订单请求错误信息

撤销订单

POST /linear/v1/cancel_orders


curl -X POST "https://betaapi.bitexch.dev/linear/v1/cancel_orders" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113"  -d '{"currency": "USDT", "order_id": "44092860", "instrument_id":"BTC-USDT-PERPETUAL", "timestamp": 1590572422557, "signature": "3c8c2271a58e3d11dfbd262a6be40ebdd07e8f394a002db0065068b36bc66d5a"}' 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "num_cancelled": 1
    }
}

撤销订单。
currency参数为必需参数。
撤销单笔订单,需提供订单ID和instrument ID。
批量撤单参数包括: all_global, all_cond_orders, order_id_list, label, instrument_id, pair, category, currency。
批量撤单参数优先级: all_global, all_cond_orders, order_id_list > label > instrument_id > pair > category > currency。

撤销条件单: 需要提供 条件单ID+InstrumentId, 条件单不能批量撤销.

批量撤销备注: (缩小范围可以获得更快响应时间)

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string false "" 计价币种
order_id string false "" 订单ID (需要提供instrument_id)
pair string false "" 币对
instrument_id string false "" 产品名称(如果用户指定order_id,那么也需要提供instrument_id)
order_id_list array false "" (order_id + instrument_id)列表, e.g [{"instrument_id":"BTC-USDT-PERPETUAL","order_id":"1001"}, {"instrument_id":"BTC-USDT-29JUL22-24250-C","order_id":"1002"}]
category string false "" 产品种类
label string false "" 用户方唯一订单ID,由用户方维护
all_cond_orders bool false false 撤销全部条件单(全部quote ccy)
all_global bool false false 撤销全部限价单和全部条件单(全部quote ccy)
字段名称 数据类型 是否必填 默认值 说明
order_id string true "" Order ID
instrument_id string true "" Instrument ID

返回数据

字段名称 数据类型 说明
num_cancelled integer 成功撤单数目

修改订单

POST /linear/v1/amend_orders


curl -X POST "https://betaapi.bitexch.dev/linear/v1/amend_orders" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113"  -d '{"currency": "USDT", "order_id": "1206764", "instrument_id":"BTC-USDT-PERPETUAL", "price": "49000", "timestamp": 1590760362688, "signature": "a74dda0f2bdaf1e1587a5e7577a281497cb66607166bd3b7e0cc4c805c750bf1"}' 



返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "order_id": "1206764",
        "created_at": 1590760363846,
        "updated_at": 1590760363846,
        "user_id": "51140",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "order_type": "limit",
        "side": "buy",
        "price": "49000.00000000",
        "qty": "1.00000000",
        "time_in_force": "gtc",
        "avg_price": "49000.00000000",
        "filled_qty": "1.00000000",
        "status": "filled",
        "is_liquidation": false,
        "auto_price": "0.00000000",
        "auto_price_type": "",
        "taker_fee_rate": "0.00050000",
        "maker_fee_rate": "-0.00020000",
        "label": "hedge",
        "stop_price": "0.00000000",
        "reduce_only": false,
        "post_only": false,
        "reject_post_only": false,
        "mmp": false,
        "source": "api",
        "hidden": false,
        "fee": "0.000000000000",
        "fee_ccy": "USDT",
        "fee_deduction_enabled": true,
        "fee_in_deduction_ccy": "0.088423738581",
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000",
    }
}


修改订单
订单ID+InstrumentId为必填参数。
以下参数必须至少提供一个: 价格,数量。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
order_id string true "" 订单ID
instrument_id string true "" 产品ID
price string false "" 新的订单价格
qty string false "" 新订单数量
auto_price string false "" 新自动价格

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方唯一订单ID
stop_price string 条件单触发价格。
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
source string 订单来源
hidden bool 是否隐藏订单
fee string 手续费
fee_ccy string 手续费单位
fee_deduction_enabled bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

批量修改订单

POST /linear/v1/amend_batchorders


curl -X POST "https://betaapi.bitexch.dev/linear/v1/amend_batchorders" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-96cc0cbd-c501-448f-a32d-21228bc9648f"  -d '{"currency": "USDT", "orders_data": [{"order_id": "572083", "instrument_id":"BTC-USDT-PERPETUAL", "price": "50000", "qty": "1.3"}, {"order_id": "invalid-order-id", "instrument_id":"BTC-USDT-PERPETUAL", "price": "50000", "qty": "0.2"}], "timestamp": 1597313835731, "signature": "c8b5fddd5f2cfa1517854dc54c51e7c3b79af91f0927ea1389ba43dbeee45652"}' 


返回数据


```json
{
    "code": 0,
    "message": "",
    "data": {
        "orders": [
            {
                "order_id": "572083",
                "created_at": 1597313836214,
                "updated_at": 1597313836214,
                "user_id": "51140",
                "instrument_id": "BTC-USDT-PERPETUAL",
                "order_type": "limit",
                "side": "sell",
                "price": "50000.00000000",
                "qty": "1.30000000",
                "time_in_force": "gtc",
                "avg_price": "0.00000000",
                "filled_qty": "0.00000000",
                "status": "open",
                "is_liquidation": false,
                "auto_price": "0.00000000",
                "auto_price_type": "",
                "taker_fee_rate": "0.00045000",
                "maker_fee_rate": "0.00025000",
                "label": "",
                "reduce_only": false,
                "post_only": true,
                "reject_post_only": false,
                "mmp": false,
                "source": "api",
                "hidden": true,
                "fee": "0.000000000000",
                "fee_ccy": "USDT",
                "fee_deduction_enabled": true,
                "fee_in_deduction_ccy": "0.088423738581",
                "fee_deduction_ccy": "TONCOIN",
                "fee_deduction_rate": "0.202100000000",
                "error_code": 0,
                "error_msg": ""
            },
            {
                "order_id": "",
                "created_at": 0,
                "updated_at": 0,
                "user_id": "",
                "instrument_id": "",
                "order_type": "",
                "side": "",
                "price": "",
                "qty": "",
                "time_in_force": "",
                "avg_price": "",
                "filled_qty": "",
                "status": "",
                "is_liquidation": false,
                "auto_price": "",
                "auto_price_type": "",
                "taker_fee_rate": "",
                "maker_fee_rate": "",
                "label": "",
                "reduce_only": false,
                "post_only": false,
                "reject_post_only": false,
                "mmp": false,
                "source": "api",
                "hidden": false,
                "fee": "0.000000000000",
                "fee_ccy": "USDT",
                "fee_deduction_enabled": true,
                "fee_in_deduction_ccy": "0.088423738581",
                "fee_deduction_ccy": "TONCOIN",
                "fee_deduction_rate": "0.202100000000",
                "error_code": 18100113,
                "error_msg": "order id is invalid : invalid-order-id"
            }
        ]
    }
}

批量修改订单。
对每一个请求:
订单ID+InstrumentId为必填参数。
以下参数必须至少提供一个:价格,数量。
批量改单最大订单数为10。


请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
orders_data array true 请求列表(如下)
字段名称 数据类型 是否必填 默认值 说明
order_id string true "" 订单ID
instrument_id string true "" 产品ID
price string false "" 新的订单价格
auto_price string false "" 新的自动价格 (自动价格单)
qty string false "" 新订单数量

返回数据

Name Type Desc
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方唯一订单ID,由用户方维护
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
source string 订单来源
hidden bool 是否隐藏订单
fee string 手续费
fee_ccy string 手续费单位
fee_deduction_enabled bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例
error_code int 订单请求错误码: 0为成功,否则为失败
error_msg string 订单请求错误信息

关闭仓位

POST /linear/v1/close_positions


curl -X POST "https://betaapi.bitexch.dev/linear/v1/close_positions" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113"  -d '{"instrument_id": "BTC-USDT-PERPETUAL", "price": "51000", "order_type": "limit", "timestamp": 1589524756236, "signature": "5bf4f9f00722d133336e736196c09a8e02c634dc0deacf2cf12413049d8d8b06"}' 




返回数据



{
    "code": 0,
    "message": "",
    "data": {
        "order_id": "17553311",
        "created_at": 1589524757818,
        "updated_at": 1589524757818,
        "user_id": "51140",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "order_type": "limit",
        "side": "sell",
        "price": "51000.00000000",
        "qty": "1.00000000",
        "time_in_force": "gtc",
        "avg_price": "51000.50000000",
        "filled_qty": "1.00000000",
        "status": "filled",
        "is_liquidation": false,
        "auto_price": "0.00000000",
        "auto_price_type": "",
        "taker_fee_rate": "0.00050000",
        "maker_fee_rate": "0.00020000",
        "label": "hedge",
        "stop_price": "0.00000000",
        "reduce_only": false,
        "post_only": false,
        "reject_post_only": false,
        "mmp": false,
        "source": "api",
        "hidden": false,
        "fee_deduction_enabled": true,
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000"
    }
}



关闭所有仓位。下一个平仓单,该订单数量等于 abs(open_position), 方向跟持仓方向相反。

Limit单是IOC单.

如果用户不想指定价格price, 输入order_type = 'market'

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 平仓单产品名称
order_type string false "limit" 平仓单订单类型 limit (IOC) 订单类型
price string false "" 平仓单价格

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方订单唯一ID
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
source string 订单来源
hidden bool 是否隐藏订单
fee_deduction_enabled bool 是否启用手续费抵扣
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

查询未结订单

GET /linear/v1/open_orders

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/open_orders?currency=USDT&category=future&timestamp=1589522687689&signature=89d5a1d929e7baa247021e090f9f634f02a7fc6c82a44c8de3bb04fa6b005a7b" 


返回数据


{
    "code": 0,
    "message": "",
    "data": [{
        "order_id": "7610691",
        "created_at": 1589183001000,
        "updated_at": 1589183001000,
        "user_id": "51140",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "order_type": "limit",
        "side": "buy",
        "price": "50010.00000000",
        "qty": "1.00000000",
        "time_in_force": "gtc",
        "avg_price": "0.00000000",
        "filled_qty": "0.00000000",
        "status": "open",
        "is_liquidation": false,
        "auto_price": "0.00000000",
        "auto_price_type": "",
        "pnl": "0.00000000",
        "cash_flow": "0.00000000",
        "initial_margin": "0.24000000",
        "taker_fee_rate": "0.00050000",
        "maker_fee_rate": "0.00020000",
        "label": "hedge",
        "stop_price": "0.00000000",
        "reduce_only": false,
        "post_only": false,
        "reject_post_only": false,
        "mmp": false,
        "reorder_index": 1,
        "source": "api",
        "hidden": false,
        "is_um": true,
        "fee": "0.00000000",
        "fee_ccy": "USDT",
        "is_fee_deducted": true,
        "fee_in_deduction_ccy": "3.000000000000",
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000"
    }]
}

查询未结订单.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
category string false "" 产品种类
instrument_id string false "" 产品名称
label string false "" 用户方订单ID

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
pnl string 订单损益
cash_flow string 订单现金流
initial_margin string 订单初始保证金(未结订单)
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方订单ID
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
reorder_index int64 内部排序使用
source string 订单来源
hidden bool 是否隐藏订单
is_um bool 是否为Um模式订单, USD-M/USDT-M订单必定为true
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

查询订单记录

GET /linear/v1/orders

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/orders?currency=USDT&instrument_id=BTC-USDT-PERPETUAL&order_id=7718222&start_time=1585270800000&end_time=1589522084000&include_open=true&offset=1&limit=10&timestamp=1589523178651&signature=2092cebba4f082f9c8718344cdad9bed83950b5fe90b3a875b708898bfd89b20" 


返回数据



{
    "code": 0,
    "message": "",
    "data": [{
        "order_id": "7718222",
        "created_at": 1589202185000,
        "updated_at": 1589460149000,
        "user_id": "51140",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "order_type": "limit",
        "side": "buy",
        "price": "50010.00000000",
        "qty": "1.00000000",
        "time_in_force": "gtc",
        "avg_price": "0.00000000",
        "filled_qty": "0.00000000",
        "status": "cancelled",
        "is_liquidation": false,
        "auto_price": "0.00000000",
        "auto_price_type": "",
        "pnl": "0.00000000",
        "cash_flow": "0.00000000",
        "initial_margin": "",
        "taker_fee_rate": "0.00050000",
        "maker_fee_rate": "0.00020000",
        "label": "hedge",
        "stop_price": "0.00000000",
        "reduce_only": false,
        "post_only": false,
        "reject_post_only": false,
        "mmp": false,
        "reorder_index": 1,
        "source": "api",
        "hidden": false,
        "is_um": true,
        "fee": "0.00000000",
        "fee_ccy": "USDT",
        "is_fee_deducted": true,
        "fee_in_deduction_ccy": "3.000000000000",
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000"
    }]
}


查询订单记录。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
instrument_id string true "" 产品名称
order_id string false "" 订单ID
label string false "" 用户方订单ID
start_time integer false 起始时间戳
end_time integer false 结束时间戳
include_open boolean false true 是否包含未结订单
limit int false 100 返回记录条数
merge_twap_market bool false 展示twap market订单

返回数据

字段名称 数据类型 说明
order_id string 订单ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id string 用户ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 订单价格
qty string 订单数量
time_in_force string 生效时间
avg_price string 平均成交价
filled_qty string 成交数量
status string 订单状态
is_liquidation boolean 是否强平单
auto_price string 自动价格
auto_price_type string U本位自动价格类型
pnl string 订单损益
cash_flow string 订单现金流
initial_margin string 订单初始保证金(未结订单)
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 用户方订单ID
stop_price string 条件单触发价格
reduce_only bool 是否reduce only单
post_only bool 是否post only单
reject_post_only bool 是否reject post only单
mmp bool 是否 mmp单
reorder_index int64 内部排序使用
source string 订单来源
hidden bool 是否隐藏订单
is_um bool 是否为Um模式订单, USD-M/USDT-M订单必定为true
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

查询用户交易记录

GET /linear/v1/user/trades

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/user/trades?currency=USDT&category=future&order_id=17551020&start_time=1585270800000&end_time=1589522084000&offset=1&limit=10&timestamp=1589523590679&signature=c4788e3a77b6000424b55067f9ba38009b34d12e482b1c80186756857c869bb5" 

返回数据



{
    "code": 0,
    "message": "",
    "data": [{
        "user_id": 51130,
        "trade_id": "23210268",
        "order_id": "17551020",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "qty": "2.00000000",
        "price": "50010.00000000",
        "sigma": "0.00000000",
        "underlying_price": "",
        "index_price": "50012.81000000",
        "usd_price": "",
        "fee_rate": "0.00050000",
        "side": "buy",
        "created_at": 1589521371000,
        "is_taker": true,
        "order_type": "limit",
        "label": "hedge",
        "fee": "0.00000000",
        "fee_ccy": "USDT",
        "is_fee_deducted": true,
        "fee_in_deduction_ccy": "3.000000000000",
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.202100000000",
        "fee_deduction_ccy_index": "1.372980000000",
        "closed_pnl": "0.03600000"
    }]
}

查询用户交易记录.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
category string false "" 产品种类
instrument_id string false "" 产品名称
order_id string false "" 订单ID
start_time integer false 起始时间戳
end_time integer false 结束时间戳
start_id integer false 起始Trade ID
end_id integer false 结束Trade ID
count int false 1 返回条数, max 500
merge_twap_market bool false false 如果记录为twap market成交,里面orderid为twap market订单id

返回数据

字段名称 数据类型 说明
user_id integer 用户 ID
order_id string 订单ID
trade_id string 交易ID
instrument_id string 产品名称
created_at integer 创建时间戳
order_type string 订单类型
side string 订单方向
price string 成交价格
qty string 成交数量
fee_rate string 手续费率
sigma string 隐含波动率(期权订单)
is_taker boolean 是否taker
index_price string 指数价格
underlying_price string 标的价格
usd_price string (不适用)
label string 订单label
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例
fee_deduction_ccy_index string 手续费抵扣币种的指数价格
closed_pnl string 平仓交易盈亏

查询聚合用户交易记录

GET /linear/v1/aggregated/trades

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/aggregated/trades?currency=USDT&category=future&order_id=17551020&start_time=1585270800000&end_time=1589522084000&offset=1&limit=10&timestamp=1589523590679&signature=c4788e3a77b6000424b55067f9ba38009b34d12e482b1c80186756857c869bb5" 

返回数据



{
    "code": 0,
    "message": "",
    "data": [{
        "user_id": 51130,
        "trade_id": "23210268",
        "order_id": "17551020",
        "instrument_id": "BTC-USDT-PERPETUAL",
        "qty": "2.00000000",
        "price": "50010.00000000",
        "sigma": "0.00000000",
        "underlying_price": "",
        "index_price": "50012.81000000",
        "usd_price": "",
        "fee_rate": "0.00050000",
        "side": "buy",
        "created_at": 1589521371000,
        "is_taker": true,
        "order_type": "limit",
        "label": "hedge",
        "fee": "0.00100000",
        "fee_ccy": "TONCOIN",
        "is_fee_deducted": true,
        "fee_deduction_ccy": "TONCOIN",
        "fee_deduction_rate": "0.101100000000",
        "fee_deduction_ccy_index": "1.372980000000",
        "closed_pnl": "0.03600000"
    }]
}

查询当前用户和所有子账户交易记录.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 计价币种
pair string false "" 币对
category string false "" 产品种类
instrument_id string false "" 产品名称
start_time integer false 起始时间戳
end_time integer false 结束时间戳
start_id integer false 起始Trade ID
end_id integer false 结束Trade ID
count int false 1 返回条数, max 500
merge_twap_market bool false false 如果记录为twap market成交,里面orderid为twap market订单id

返回数据

字段名称 数据类型 说明
user_id integer 用户 ID
order_id string 订单ID
trade_id string 交易ID
instrument_id string 产品名称
created_at integer 创建时间戳
order_type string 订单类型
side string 订单方向
price string 成交价格
qty string 成交数量
fee_rate string 手续费率
sigma string 隐含波动率(期权订单)
is_taker boolean 是否taker
index_price string 指数价格
underlying_price string 标的价格
usd_price string (不适用)
label string 订单label
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例
fee_deduction_ccy_index string 手续费抵扣币种的指数价格
closed_pnl string 平仓交易盈亏

查询预估保证金

GET /linear/v1/margins

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/linear/v1/margins?instrument_id=BTC-USDT-PERPETUAL&price=5000&qty=1&timestamp=1588932548594&signature=d642b046b247bf00ba285bb260582aadf33e98d2b47d26479b99cc1a7941f807" 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "buy_margin": "70.93672651",
        "sell_margin": "100.13000000",
        "min_sell": "34890.97000000",
        "max_buy": "35953.65000000",
        "index_price": "35423.91000000"
    }
}

查询预估保证金.

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
price string true "" 订单价格
qty string true "" 订单数量

返回数据

字段名称 数据类型 说明
buy_margin string 预估买单保证金(单位为计价币种)
sell_margin string 预估卖单保证金(单位为计价币种)
min_sell string 最小卖出价格
max_buy string 最大买入价格
index_price string USD 指数价格
usdt_index_price string (兼容旧字段) 等于 index_price

查询条件单记录

GET /linear/v1/conditional_orders

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/v1/conditional_orders?currency=USDT&instrument_id=BTC-USDT-PERPETUAL&status=open&timestamp=1590667739793&signature=14c522605de563064ae36933604225730a8b4e254be8ce58ecc2746f5199d77f" 


Response

{
    "code": 0,
    "message": "",
    "data": [
        {
            "cond_order_id": "trigger-c8vbgjdlat8f5clahjpg",
            "created_at": 1648277581254,
            "updated_at": 1648277581254,
            "status": "open",
            "stop_price": "40000.00000000",
            "trigger_type": "last-price",
            "reject_reason": "",
            "instrument_id": "BTC-USDT-PERPETUAL",
            "user_id": 8001,
            "qty": "1.00000000",
            "price": "39000.00000000",
            "side": "buy",
            "order_type": "trigger-limit",
            "time_in_force": "gtc",
            "source": "api",
            "hidden": false
        }
    ],
    "page_info": {
        "has_more": false
    }
}

查询条件单记录.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
pair string false "" 币对
instrument_id string false "" 产品名称
status string false "" 条件单状态
start_time integer false 起始时间戳
end_time integer false 结束时间戳
limit int false 100 返回记录条数

返回数据

字段名称 数据类型 说明
cond_order_id string 条件单ID (带前缀"trigger-")
created_at integer 创建时间戳
updated_at integer 更新时间戳
instrument_id string 产品名称
qty string 订单数量
price string 触发后的订单价格
side string 订单方向
order_type string 订单类型
stop_price string 条件单触发价格
time_in_force string 生效时间
status string 条件单状态
trigger_type string 以最新成交价触发
user_id int 用户ID
source string 订单来源
hidden bool 是否隐藏订单

止盈止损单-创建(仓位)

POST /linear/v1/tpsl/new

curl -X "POST" "https://betaapi.bitexch.dev/linear/v1/tpsl/new" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-8628663d-678c-49b0-8d4e-a8691152a2d0"  -d '{"trigger_type": "mark-price", "take_profit_price": "40000", "qty": "0.5", "tpsl_mode": 1, "instrument_id": "BTC-USDT-PERPETUAL", "stoploss_price": "44000", "timestamp": 1703139275532, "signature": "bd2bf2123d2bf53ab776b1c77cf56c5dc42efaade77aecf46c41ac8f796619e8"}' 

Response


{
    "code": 0,
    "message": "",
    "data": {
        "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0",
        "created_at": 1703139275902,
        "update_at": 1703139275902,
        "instrument_id": "BTC-USDT-PERPETUAL",
        "qty": "0.500000000000",
        "trigger_type": "mark-price",
        "tpsl_mode": 1,
        "tp_price": "40000.000000000000",
        "tp_status": "open",
        "sl_price": "44000.000000000000",
        "sl_status": "open",
        "display_name": "BTC-USDT-PERPETUAL",
        "is_user_twap": false,
        "user_stgy_id": 0
    }
}

创建针对仓位的止盈止损单. (区别于下单时的开仓绑定止盈止损)

请求参数

字段名称 数据类型 是否必填 默认值 说明
instrument_id string false "" 产品名称
trigger_type string true "" 触发类型(mark-price/index-price)
qty string false "" 数量(部分仓位模式)
tpsl_mode int true "" 平仓模式, 1:部分仓位, 2:全部仓位(触发后全部平仓)
take_profit_price string true "" 止盈价
stoploss_price string true "" 止损价

返回数据

字段名称 数据类型 说明
tpsl_id string tpsl ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
instrument_id string 产品名称
qty string 数量(只针对部分仓位模式)
trigger_type string 触发类型(mark-price/index-price)
tpsl_mode int 平仓模式, 1:部分仓位, 2:全部仓位(触发后全部平仓)
tp_price string 止盈价
tp_status string 止盈单状态
sl_price string 止损价
sl_status string 止损单状态
is_user_twap bool 触发后是否以twap执行
user_stgy_id int twap单id (is_user_twap=true有效)
display_name string 显示名称

止盈止损单-查询

GET /linear/v1/tpsl/list

curl -H "X-Bit-Access-Key: ak-8628663d-678c-49b0-8d4e-a8691152a2d0" "https://betaapi.bitexch.dev/linear/v1/tpsl/list?currency=USDT&active_only=false&timestamp=1703139930897&signature=1053585256ce9a3cdd92d3750fe8e363a09b69fc26d8301d4f0e7989bbf99508" 

Response


{
    "code": 0,
    "message": "",
    "data": [
        {
            "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0",
            "created_at": 1703139275902,
            "update_at": 1703139275902,
            "instrument_id": "BTC-USDT-PERPETUAL",
            "qty": "0.500000000000",
            "trigger_type": "mark-price",
            "tpsl_mode": 1,
            "tp_price": "40000.000000000000",
            "tp_status": "open",
            "sl_price": "44000.000000000000",
            "sl_status": "open",
            "display_name": "BTC-USDT-PERPETUAL",
            "is_user_twap": false,
            "user_stgy_id": 0
        }
    ]
}

查询止盈止损单.

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
instrument_id string false "" 产品名称
active_only bool false false 只返回活跃的
start_time integer false 起始时间戳
end_time integer false 结束时间戳
count int false 100 返回记录条数

返回数据

字段名称 数据类型 说明
tpsl_id string tpsl ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
instrument_id string 产品名称
qty string 数量(只针对部分仓位模式)
trigger_type string 触发类型(mark-price/index-price)
tpsl_mode int 平仓模式, 1:部分仓位, 2:全部仓位(触发后全部平仓)
tp_price string 止盈价
tp_status string 止盈单状态
sl_price string 止损价
sl_status string 止损单状态
is_user_twap bool 触发后是否以twap执行
user_stgy_id int twap单id (is_user_twap=true有效)
display_name string 显示名称

止盈止损单-撤销

POST /linear/v1/tpsl/cancel

curl -X "POST" "https://betaapi.bitexch.dev/linear/v1/tpsl/cancel" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-8628663d-678c-49b0-8d4e-a8691152a2d0"  -d '{"instrument_id": "BTC-USDT-PERPETUAL", "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0", "cancel_mode": 1, "timestamp": 1703140404331, "signature": "295892b8a1b2a6364d5c3ea4c4c4b377f846bab428d4eff23f085aab0de75f4d"}' 

Response


{
    "code": 0,
    "message": "",
    "data": {
        "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0",
        "created_at": 1703139275902,
        "update_at": 1703139275902,
        "instrument_id": "BTC-USDT-PERPETUAL",
        "qty": "0.500000000000",
        "trigger_type": "mark-price",
        "tpsl_mode": 1,
        "tp_price": "40000.000000000000",
        "tp_status": "cancelled",
        "sl_price": "44000.000000000000",
        "sl_status": "open",
        "display_name": "BTC-USDT-PERPETUAL",
        "is_user_twap": false,
        "user_stgy_id": 0
    }
}

撤销止盈止损单.

请求参数

字段名称 数据类型 是否必填 默认值 说明
tpsl_id string true "" tpsl ID
instrument_id string true "" 产品名称
cancel_mode int true 0 1=cancel all, 2=cancel take-profit, 3=cancel stoploss

返回数据

字段名称 数据类型 说明
tpsl_id string tpsl ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
instrument_id string 产品名称
qty string 数量(只针对部分仓位模式)
trigger_type string 触发类型(mark-price/index-price)
tpsl_mode int 平仓模式, 1:部分仓位, 2:全部仓位(触发后全部平仓)
tp_price string 止盈价
tp_status string 止盈单状态
sl_price string 止损价
sl_status string 止损单状态
is_user_twap bool 触发后是否以twap执行
user_stgy_id int twap单id (is_user_twap=true有效)
display_name string 显示名称

止盈止损单-修改

POST /linear/v1/tpsl/edit

curl -X "POST" "https://alphaapi.bitexch.dev/linear/v1/tpsl/edit" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-8628663d-678c-49b0-8d4e-a8691152a2d0"  -d '{"instrument_id": "BTC-USDT-PERPETUAL", "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0", "take_profit_price": "41000", "timestamp": 1703142258792, "signature": "351125be64a2d5f9fafb5c5c7c29764480f05e37aa6a891ed5687a978c4cc8e9"}' 

Response


{
    "code": 0,
    "message": "",
    "data": {
        "tpsl_id": "tpsl-cm1tfipm2rc7n9vrv4b0",
        "created_at": 1703139275902,
        "update_at": 1703139275902,
        "instrument_id": "BTC-USDT-PERPETUAL",
        "qty": "0.500000000000",
        "trigger_type": "mark-price",
        "tpsl_mode": 1,
        "tp_price": "40000.000000000000",
        "tp_status": "cancelled",
        "sl_price": "44000.000000000000",
        "sl_status": "open",
        "display_name": "BTC-USDT-PERPETUAL",
        "is_user_twap": false,
        "user_stgy_id": 0
    }
}

修改止盈止损单.

请求参数

字段名称 数据类型 是否必填 默认值 说明
tpsl_id string true "" tpsl ID
instrument_id string true "" 产品名称
take_profit_price string false "" 新的止盈价格
stoploss_price string false "" 新的止损价格
trigger_type string false "" 触发类型
cancel_tp bool false false 撤销止盈单腿
cancel_sl bool false false 撤销止损单腿
is_user_twap bool false false 触发后是否以twap执行

返回数据

字段名称 数据类型 说明
tpsl_id string tpsl ID
created_at integer 创建时间戳
updated_at integer 更新时间戳
instrument_id string 产品名称
qty string 数量(只针对部分仓位模式)
trigger_type string 触发类型(mark-price/index-price)
tpsl_mode int 平仓模式, 1:部分仓位, 2:全部仓位(触发后全部平仓)
tp_price string 止盈价
tp_status string 止盈单状态
sl_price string 止损价
sl_status string 止损单状态
is_user_twap bool 触发后是否以twap执行
user_stgy_id int twap单id (is_user_twap=true有效)
display_name string 显示名称

Block Trade



新增 block trade 下单

POST /linear/v1/blocktrades

# <bt_source> should be replaced with real bt_source

curl -X POST "https://betaapi.bitexch.dev/linear/v1/blocktrades" -H "Content-Type: application/json" -H "X-Bit-Access-Key: ak-df074cbc-dbf7-46f9-b07c-f4f51763ac7a"  -d '{"currency": "USDT", "label": "e8db3a92b94c482bb0e30f421415982d", "role": "maker", "counterparty": 1026, "bt_source": "<bt_source>", "trades": [{"instrument_id": "BTC-USDT-25SEP20-9000-C", "price": "0.18", "qty": "10", "side": "sell"}, {"instrument_id": "BTC-USDT-PERPETUAL", "price": "19300", "qty": "5", "side": "buy"}], "timestamp": 1594447520876, "signature": "7e8b0e7987fcb282b691d9e87c5afa9af578ed0c464190ca1fa466d18c17adde"}' 


返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "label": "e8db3a92b94c482bb0e30f421415982d",
        "status": "pending"
    }
}

新增 block trade 下单。
Label: block trade唯一标签, 买卖双方用同一个标签ID来标记同一笔交易。
买卖双方调用/linear/v1/blocktrades, 使用同一个标签,订单列表的产品,价格相同,方向相反。
Block trade 请求有效时间为1 分钟, 另一方超过时间没有回应,请求就会超时。
Block trade bt_source 是 Bit.com 指定的来源, 具体请联系Bit.com。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
bt_source string true "" Block trade 来源 (Bit.com 指定的来源)
label string true "" block trade唯一标签
role string true "" 角色: taker/maker
counterparty integer true "" 对方的用户ID
trades array true Block trade订单列表
字段名称 数据类型 是否必填 默认值 说明
instrument_id string true "" 产品名称
side string true "" 订单方向: buy/sell
price string true "" 订单价格
qty string true "" 订单数量

返回数据

字段名称 数据类型 说明
label string Block trade 标签
status string Block trade 状态: pending/filled/rejected/expired

查询block trades

GET /linear/v1/blocktrades

# <bt_source> should be replaced with real bt_source

curl -H "X-Bit-Access-Key: ak-df074cbc-dbf7-46f9-b07c-f4f51763ac7a" "https://betaapi.bitexch.dev/linear/v1/blocktrades?currency=USDT&bt_source=<bt_source>&timestamp=1594447524043&signature=12b1090ea6432e71f2f6d01c6f08f0ff30e3765791ebff87b4183964643d61d2" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "block_order_id": "56",
            "label": "8c5d90b6cbd744ceab49d0e66b8fda68",
            "created_at": 1613637677061,
            "updated_at": 1613637678593,
            "user_id": 51140,
            "counterparty": 481554,
            "instrument_id": "BTC-USDT-PERPETUAL",
            "side": "buy",
            "price": "19000.00000000",
            "qty": "10.00000000",
            "fee": "0.00000392",
            "status": "filled",
            "role": "maker",
            "bt_source": "<bt_source>",
            "order_id": "6325142",
            "trade_id": "1299120841",
            "index_price": "51723.49000000",
            "sigma": "0.00000000"
        }   
    ]
}

查询指定用户的block trades信息和状态。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
bt_source string true "" Block trade 来源
instrument_id string false "" 产品名称
label string false "" Block trade标签
start_time integer false 起始时间戳
end_time integer false 结束时间戳
limit int false 100 返回记录条数

返回数据

字段名称 数据类型 说明
block_order_id string Block 订单ID
label string Block trade标签
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id integer 用户ID
counterparty integer 对方的用户ID
instrument_id string 产品名称
side string 订单方向
price string 订单价格
qty string 订单数量
fee string 手续费
status string 状态
role string 订单角色 (taker/maker)
bt_source string Block trade 来源
order_id string 场内订单ID
trade_id string 场内成交ID
index_price string 指数价格
sigma string 隐含波动率(期权订单)

查询平台的block trades

GET /linear/v1/platform_blocktrades

# <bt_source> should be replaced with real bt_source

curl -H "X-Bit-Access-Key: ak-df074cbc-dbf7-46f9-b07c-f4f51763ac7a" "https://betaapi.bitexch.dev/linear/v1/platform_blocktrades?currency=USDT&bt_source=<bt_source>&timestamp=1594448745124&signature=39078700dbe556df7f34dd6e0fb444b4ead9ef6ddc8e5b24c76555b6758c68d2" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "block_order_id": "56",
            "label": "8c5d90b6cbd744ceab49d0e66b8fda68",
            "created_at": 1613637677061,
            "updated_at": 1613637678593,
            "user_id": 51140,
            "counterparty": 481554,
            "instrument_id": "BTC-USDT-PERPETUAL",
            "side": "buy",
            "price": "19000.00000000",
            "qty": "10.00000000",
            "fee": "0.00000392",
            "status": "filled",
            "role": "maker",
            "bt_source": "<bt_source>",
            "order_id": "6325142",
            "trade_id": "1299120841",
            "index_price": "51723.49000000",
            "sigma": "0.00000000"
        }   
    ]
}

查询该平台所有相关的block trades信息。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
bt_source string true "" Block trade 来源
instrument_id string false "" 产品名称
label string false "" Block trade标签
taker string false "" Taker
maker string false "" Maker
start_time integer false 起始时间戳
end_time integer false 结束时间戳
limit int false 100 返回记录条数

返回数据

字段名称 数据类型 说明
block_order_id string Block 订单ID
label string Block trade标签
created_at integer 创建时间戳
updated_at integer 更新时间戳
user_id integer 用户ID
counterparty integer 对方的用户ID
instrument_id string 产品名称
side string 订单方向
price string 订单价格
qty string 订单数量
fee string 手续费
status string 状态
role string 订单角色 (taker/maker)
bt_source string Block trade 来源
order_id string 场内订单ID
trade_id string 场内成交ID
index_price string 指数价格
sigma string 隐含波动率(期权订单)

查询blocktrade用户信息

GET /linear/v1/user/info

curl -H "X-Bit-Access-Key: ak-77fd5728-e7d4-4174-991a-6e9b8f5887e6" "https://betaapi.bitexch.dev/linear/v1/user/info?timestamp=1613713263340&signature=038be893be10e51b7545abacbf669e7569b7de2dcb2693c33f4aa29c956a611a" 

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "user_id": 10031
    }
}

查询用户信息(只需要blocktrade权限).
有"read"权限的API key应该使用GET /linear/v1/accounts.

请求参数

None

返回数据

字段名称 数据类型 说明
user_id integer 用户ID

Websocket 数据订阅

数据订阅基于websocket协议。用户可以在建立websocket连接后发送请求订阅数据。

连接建立后如果30秒内没有订阅任何数据,系统将关闭该连接。

所有订阅数据按以下结构返回。

字段名称 类型 说明
channel string 频道名称
timestamp integer 时间戳(服务器返回时间)
data object 数据内容
module string [linear, um] 订阅数据所属模块

订阅管理

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL",
        "ETH-USDT-PERPETUAL"
    ],
    "channels":[
        "depth",
        "ticker",
        "kline.5",
        "order"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "categories":[
        "future"
    ],
    "interval": "100ms",
    "token":"be4ffcc9-2b2b-4c3e-9d47-68bf062cf651"
}

Response (success)

{
    "channel":"subscription",
    "timestamp":1587921122970,
    "data":{
        "code":0,
        "subscription":[
            "depth",
            "ticker",
            "kline.5"
        ]
    }
}

Response (failure)

{
    "channel":"subscription",
    "timestamp":1587921122970,
    "data":{
        "code":13200302,
        "message":"auth failed: invalid token"
    }
}

websocket连接建立后,用户可以发送请求订阅频道以获取相应的数据推送。频道分为公共频道和私有频道,私有频道首次订阅前需要先获取认证token,填入订阅请求,鉴权通过后就能收到数据推送。

每个频道有不同的订阅参数,订阅时需根据频道订阅要求填写相应的参数,详情参考后面的频道说明。

用户可以通过设置参数interval控制推送频率。当设置为raw时,频道有数据更新立刻就会推送。当设置为100ms时,则会把该频道100ms内的更新聚合后推送。当设置为fixed100ms时,按100ms固定时间间隔进行推送(仅部分频道支持)。

订阅后会收到订阅结果。当订阅请求包含多个频道,而其中部分订阅失败时,将返回两条消息:一条是订阅失败的原因,一条是成功订阅的频道列表。

当不再需要订阅某个频道数据时,用户可以发送取消订阅请求来实现。

请求参数

字段名称 类型 说明
type string [subscribe, unsubscribe]
channels string[] 频道列表
pairs string[] 币对列表
categories string[] 产品种类列表
instruments string[] 产品名称列表
interval string [raw, 100ms, fixed100ms] 默认为raw
token string 订阅私有频道的认证token

关于interval参数设置

返回数据

字段名称 类型 说明
code integer 0表示成功, 非0表示失败
message string 错误消息,订阅失败时返回
subscription string[] 订阅成功的频道列表

获取认证Token

GET /v1/ws/auth

Request

curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/v1/ws/auth?timestamp=1588996062516&signature=9ed1dd821cc6464d2cfc5bf9614df1f22611c977b513e1ffde864a673b6915f0" 

Response

{
    "code":0,
    "message":"",
    "data":{
        "token":"be4ffcc9-2b2b-4c3e-9d47-68bf062cf651"
    }
}

订阅私有频道需要先通过本接口(REST)获取认证token,然后将其填入websocket的订阅请求。

token只能使用一次,服务器验证后即丢弃,所以没有被盗用风险,重连需要重新申请token。

每个连接只需要鉴权一次,鉴权通过后新的订阅请求无需再填写token(后续private请求中的token会被丢弃,因此不同用户不能共享同一个private websocket连接)。

查询参数

None

返回数据

字段名称 类型 说明
token string 私有频道认证token

心跳

协议标准

根据RFC 6455, websocket协议实现了PING/PONG消息,用以确认websocket连接保持活动状态。

服务器每分钟通过websocket连接向客户端发送PING消息,客户端收到后应答PONG。如果服务器在一分钟内没收到PONG,则认为连接不正常将连接关闭。

客户端也可向服务器发送PING消息,通过检测是否收到PONG,确认该连接数据收发正常。

PING或者PONG都是控制帧。PING消息的opcode为0x9,PONG消息的opcode为0xA。可参考Websocket协议说明

自定义PING/PONG

由于部分客户端封装所限不支持按需发送控制帧,因此在协议标准外提供了一套自定义基于payload的PING/PONG。详细参考“Websocket RPC - PING”

频道目录

频道名称 权限 订阅参数 说明
depth public instruments 市场深度数据的快照和增量变化
order_book.{group}.{depth} public instruments 指定层数的订单簿快照
depth1 public instruments 订单簿的第一层价格
ticker public instruments 市场最新成交价格和最近24小时交易统计信息
kline.{timeframe} public instruments K线数据
trade public instruments 指定产品的最新成交信息
market_trade public categories + pairs 市场上所有期权或期货产品的最新成交信息
index_price public pairs 指定币对的指数价格
mark_price public instruments 指定产品的标记价格
um_account private UM账户信息
position private categories + pairs 用户的仓位信息
order private categories + pairs 用户的订单信息
user_trade private categories + pairs 用户的交易信息
mmp_frozen private pairs MMP冻结事件

市场深度频道(depth)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "depth"
    ],
    "interval": "100ms"
}

Response (snapshot)

{
    "channel":"depth",
    "timestamp":1643094930373,
    "module":"linear",
    "data":{
        "type":"snapshot",
        "instrument_id":"BTC-USDT-PERPETUAL",
        "sequence":9,
        "bids":[
            [
                "35731.05000000",
                "6.82000000"
            ]
        ],
        "asks":[
            [
                "35875.00000000",
                "1.00000000""
            ]
        ]
    }
}

Response (update)

{
    "channel":"depth",
    "timestamp":1643094930373,
    "module":"linear",
    "data":{
        "type":"update",
        "instrument_id":"BTC-USDT-PERPETUAL",
        "sequence":10,
        "prev_sequence":9,
        "changes":[
            [
                "sell",
                "35733.00000000",
                "2.10000000"
            ]
        ]
    }
}

depth频道推送市场深度的快照和增量变化,包括snapshotupdate两种类型的消息。snapshot类型表示当前订单簿的快照,update类型表示深度变更信息。

订阅成功后将首先发送一个快照消息,再发送深度变更消息。当出现异常时会重新发送快照消息。

快照消息包括买价和卖价价格深度,每一层深度由价格和数量组成。

更新消息包含sequenceprev_sequencesequence表示本次更新序号,prev_sequence表示前一次更新序号。如果前一次更新序号等于上一条消息的本次更新序号,则意味着没有消息丢失。

更新消息的变更列表,每一个变更都由方向、价格和数量组成。当数量为0时表示从订单簿中删除该层。

频道信息

频道名称 权限 订阅参数 推送频率
depth public instruments [raw, 100ms]

返回数据

字段名称 类型 说明
type string [snapshot, update]两种类型:快照、深度变更
instrument_id string 产品名称
sequence integer 订单簿更新序号
asks array of [price, quantity] 卖价, price(价格)和quantity(数量)都是string类型。仅快照类型消息返回
bids array of [price, quantity] 买价, price(价格)和quantity(数量)都是string类型。仅快照类型消息返回
prev_sequence integer 前1次消息的更新序号。仅更新类型消息返回
changes array of [side, price, quantity] 深度更新列表。side(方向)、price(价格)、quantity(数量)都是string类型。数量为0表示删除该层。仅更新类型消息返回

订单簿频道(order_book)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "order_book.1.20"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"order_book.1.20",
    "timestamp":1643095202401,
    "module":"linear",
    "data":{
        "instrument_id":"BTC-USDT-PERPETUAL",
        "sequence":1643010119674372,
        "timestamp":1643095202400,
        "asks":[
            [
                "35725.80000000",
                "2.29000000"
            ],
            [
                "35747.00000000",
                "1.00000000"
            ]
        ],
        "bids":[
            [
                "35724.80000000",
                "5.25000000"
            ],
            [
                "35724.75000000",
                "1.38000000"
            ]
        ]
    }
}

order_book频道根据指定的聚合倍数和深度层数,按价格聚合后,推送指定层数的订单簿快照。

订单簿包括买价和卖价深度,每一层深度由价格和数量组成。

频道信息

频道名称 权限 订阅参数 推送频率
order_book.{group}.{depth} public instruments [raw, 100ms,fixed100ms]

订阅order_book频道需要在频道名称中指定聚合倍数group和深度层数depth

订单薄聚合实例

假设价格步长 price_step = 0.01
原始深度:
bids: [[0.13, 3], [0.19, 7], [0.26, 5], [0.77, 12.3]]

订单频道信息为 orderbook.10.5, 聚合后价格步长aggregation price level = 0.01 * 10 = 0.1
聚合后深度:
bids: [[0.1, 10], [0.2, 5], [0.7, 12.3]]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
sequence integer 订单簿更新序号
timestamp integer 订单簿更新时间戳
asks array of [price, quantity] 卖价, price(价格)和quantity(数量)都是string类型
bids array of [price, quantity] 买价, price(价格)和quantity(数量)都是string类型

一层价格频道(depth1)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "depth1"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"depth1",
    "timestamp":1643095202400,
    "module":"linear",
    "data":{
        "instrument_id":"BTC-USDT-PERPETUAL",
        "asks":[
            [
                "35725.80000000",
                "2.29000000"
            ]
        ],
        "bids":[
            [
                "35724.80000000",
                "5.25000000"
            ]
        ]
    }
}

depth1频道推送1层的买价/卖价信息。

频道信息

频道名称 权限 订阅参数 推送频率
depth1 public instruments [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
asks array of [price, quantity] 卖价, price(价格)和quantity(数量)都是string类型。返回0或1层
bids array of [price, quantity] 买价, price(价格)和quantity(数量)都是string类型。返回0或1层

市场交易信息统计频道(ticker)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "ticker"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"ticker",
    "timestamp":1643099422727,
    "module":"linear",
    "data":{
        "ask_sigma":"",
        "best_ask":"36295.00000000",
        "best_ask_qty":"1.00000000",
        "best_bid":"36242.30000000",
        "best_bid_qty":"7.01000000",
        "bid_sigma":"",
        "funding_rate":"0.00203429",
        "funding_rate8h":"0.00009707",
        "high24h":"37377.00000000",
        "instrument_id":"BTC-USDT-PERPETUAL",
        "last_price":"36242.30000000",
        "last_qty":"0.42000000",
        "low24h":"33117.95000000",
        "mark_price":"36261.48392714",
        "max_buy":"36805.41000000",
        "min_sell":"35717.56000000",
        "open24h":"34998.65000000",
        "open_interest":"87.69310000",
        "price_change24h":"0.03553423",
        "time":1643099422727,
        "volume24h":"4422.94140000"
    }
}

ticker频道推送市场最新成交价格和最近24小时交易统计信息。

频道信息

频道名称 权限 订阅参数 推送频率
ticker public instruments [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
last_price string 最新成交价
last_qty string 最新成交量
open24h string 24小时开盘价
high24h string 24小时最高价
low24h string 24小时最低价
volume24h string 24小时成交量
price_change24h string 24小时价格变动
open_interest string 未平仓量
best_bid string 最佳买入价
best_ask string 最佳卖出价
best_bid_qty string 最佳买入数量
best_ask_qty string 最佳卖出数量
bid_sigma string 买入sigma (期权)
ask_sigma string 卖出sigma (期权)
underlying_name string 标的指数(期权)
underlying_price string 标的指数价格(期权)
funding_rate string 资金费率 (永续)
funding_rate8h string 过去8小时的平均资金费率 (永续)
mark_price string 标记价格
sigma string 标记价格sigma值(期权)
delta string 标记价格delta值(期权)
vega string 标记价格vega值(期权)
theta string 标记价格theta值(期权)
gamma string 标记价格gamma值(期权)
max_buy string 最大买入价
min_sell string 最小卖出价

K线频道(kline)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "kline.5"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"kline.5",
    "timestamp":1643099753388,
    "module":"linear",
    "data":{
        "instrument_id":"BTC-USDT-PERPETUAL",
        "close":"36088.00000000",
        "high":"36088.00000000",
        "low":"36081.45000000",
        "open":"36176.90000000",
        "tick":1643099700000,
        "volume":"3.29000000"
    }
}

kline频道推送K线数据。如果在当前周期内没有发生过交易,则开盘价、收盘价、最高价、最低价会以前一个周期的收盘价填充。

频道信息

频道名称 权限 订阅参数 推送频率
kline.{timeframe} public instruments [raw, 100ms]

订阅kline频道需要在频道名称中指定K线周期timeframe

支持的K线周期:

时间周期 类型
1 1 分钟
3 3 分钟
5 5 分钟
15 15 分钟
30 30 分钟
60 60 分钟
240 240 分钟
360 360 分钟
720 720 分钟
1d 1天
1w 1周(自然周)
1m 1月(自然月)

返回数据

字段名称 类型 说明
instrument_id string 产品名称
tick integer 统计周期开始时间
open string 开盘价
close string 收盘价
high string 最高价
low string 最低价
volume string 成交量

交易频道(trade)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "trade"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"trade",
    "timestamp":1643099734031,
    "module":"linear",
    "data":[
        {
            "instrument_id":"BTC-USDT-PERPETUAL",
            "created_at":1643099733988,
            "is_block_trade":false,
            "price":"36081.45000000",
            "qty":"2.29000000",
            "side":"buy",
            "sigma":"0.00000000",
            "trade_id":"1005590555"
        }
    ]
}

trade频道推送指定产品的最新成交信息。

频道信息

频道名称 权限 订阅参数 推送频率
trade public instruments [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
trade_id string 交易ID
price string 成交价格
qty string 成交数量
side string Taker方向
sigma string 隐含波动率 (期权)
option_type string 期权类型 (期权)
is_block_trade boolean 是否block trade
created_at integer 成交时间戳

市场交易频道(market_trade)

Request

{
    "type":"subscribe",
    "channels":[
        "market_trade"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "categories":[
        "future"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"market_trade",
    "timestamp":1643099734031,
    "module":"linear",
    "data":[
        {
            "instrument_id":"BTC-USDT-PERPETUAL",
            "created_at":1643099733988,
            "is_block_trade":false,
            "price":"36081.45000000",
            "qty":"2.29000000",
            "side":"buy",
            "sigma":"0.00000000",
            "trade_id":"1005590555"
        }
    ]
}

market_trade频道推送市场上所有期权或期货产品的最新成交信息。

频道信息

频道名称 权限 订阅参数 推送频率
market_trade public categories + pairs [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
trade_id string 交易ID
price string 成交价格
qty string 成交数量
side string Taker方向
sigma string 隐含波动率 (期权)
option_type string 期权类型 (期权)
is_block_trade boolean 是否block trade
created_at integer 成交时间戳

指数价格频道(index_price)

Request

{
    "type":"subscribe",
    "channels":[
        "index_price"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"index_price",
    "timestamp":1643099733988,
    "module":"linear",
    "data":{
        "index_name":"BTC-USD",
        "index_price":"35866.66000000"
    }
}

index_price频道推送指定币对的指数价格。

频道信息

频道名称 权限 订阅参数 推送频率
index_price public pairs [raw, 100ms]

返回数据

字段名称 类型 说明
index_name string 币对名称
index_price string 指数价格

标记价格频道(mark_price)

Request

{
    "type":"subscribe",
    "instruments":[
        "BTC-USDT-PERPETUAL"
    ],
    "channels":[
        "mark_price"
    ],
    "interval": "100ms"
}

Response

{
    "channel":"mark_price",
    "timestamp":1643100336677,
    "module":"linear",
    "data":{
        "instrument_id":"BTC-USDT-PERPETUAL",
        "mark_price":"36079.52938997"
    }
}

mark_price频道推送指定产品的标记价格。

频道信息

频道名称 权限 订阅参数 推送频率
mark_price public instruments [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
mark_price string 标记价格
sigma string 标记价格sigma值(期权)
delta string 标记价格delta值(期权)
vega string 标记价格vega值(期权)
theta string 标记价格theta值(期权)
gamma string 标记价格gamma值(期权)

UM账户信息频道(um_account)

Request

{
    "type":"subscribe",
    "channels":[
        "um_account"
    ],
    "interval": "100ms",
    "token":"6d501ded-3c40-4697-b390-218a54b9de19"
}

Response

{
    "channel":"um_account",
    "timestamp":1632439007081,
    "module":"um",
"data": {
        "user_id": 481554,
        "created_at": 1649923879505,
        "total_collateral": "3170125.05978108",
        "total_margin_balance": "3170125.05978108",
        "total_available": "3169721.64891398",
        "total_initial_margin": "403.41086710",
        "total_maintenance_margin": "303.16627631",
        "total_initial_margin_ratio": "0.00012725",
        "total_maintenance_margin_ratio": "0.00009563",
        "total_liability": "0.00000000",
        "total_unsettled_amount": "-0.84400340",
        "spot_orders_hc_loss": "0.00000000",
        "total_position_pnl": "1225.53245820",
        "details": [
            {
                "currency": "BTC",
                "equity": "78.13359310",
                "liability": "0.00000000",
                "index_price": "41311.20615385",
                "cash_balance": "78.13360190",
                "margin_balance": "78.13359310",
                "available_balance": "78.12382795",
                "initial_margin": "0.00976516",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00733859",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.02966586",
                "total_delta": "0.48532539",
                "session_rpl": "0.00001552",
                "session_upl": "-0.00003595",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_pnl": "0.02966586",
                "future_session_rpl": "0.00001552",
                "future_session_upl": "-0.00003595",
                "future_session_funding": "0.00001552",
                "future_delta": "0.48532539",
                "future_available_balance": "76.72788921",
                "option_available_balance": "76.72788921",
                "unsettled_amount": "-0.00002043",
                "usdt_index_price": "41311.20615385"
            },
            {
                "currency": "ETH",
                "equity": "1.99960000",
                "liability": "0.00000000",
                "index_price": "3119.01923077",
                "cash_balance": "1.99960000",
                "margin_balance": "1.99960000",
                "available_balance": "1.99960000",
                "initial_margin": "0.00000000",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00000000",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.00000000",
                "total_delta": "0.00000000",
                "session_rpl": "0.00000000",
                "session_upl": "0.00000000",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_pnl": "0.00000000",
                "future_session_rpl": "0.00000000",
                "future_session_upl": "0.00000000",
                "future_session_funding": "0.00000000",
                "future_delta": "0.00000000",
                "future_available_balance": "1.99960000",
                "option_available_balance": "1.99960000",
                "unsettled_amount": "0.00000000",
                "usdt_index_price": "3119.01923077"
            }
        ],
        "usdt_total_collateral": "3170125.05978108",
        "usdt_total_margin_balance": "3170125.05978108",
        "usdt_total_available": "3169721.64891398",
        "usdt_total_initial_margin": "403.41086710",
        "usdt_total_maintenance_margin": "303.16627631",
        "usdt_total_initial_margin_ratio": "0.00012725",
        "usdt_total_maintenance_margin_ratio": "0.00009563",
        "usdt_total_liability": "0.00000000",
        "usdt_total_unsettled_amount": "-0.84400340"
    }
}

统一UM用户,订阅um_account频道推送统一保证金用户的账户信息。

频道信息

频道名称 权限 订阅参数 推送频率
um_account private [raw, 100ms]

返回数据

字段名称 数据类型 说明
user_id int 用户ID
created_at int 时间戳(查询时刻)
total_collateral string 账户维度USD总担保品金额
total_margin_balance string 账户维度USD总保证金余额
total_available string 账户维度USD总可用余额
total_initial_margin string 账户维度USD总初始保证金
total_maintenance_margin string 账户维度USD总维持保证金
total_initial_margin_ratio string 账户维度USD总初始保证金率,可能会返回"infinity"
total_maintenance_margin_ratio string 账户维度USD总维持保证金率,可能会返回"infinity"
total_liability string 账户维度USD总负债
total_unsettled_amount string 账户维度USD总待结金额
spot_orders_hc_loss string 现货挂单损失
total_position_pnl string 账户维度USD损益 [SUM(ccy.pnl * ccy.index-price)]
details array 分币种账户信息
usdt_total_collateral string (兼容旧字段) 等于 total_collateral
usdt_total_margin_balance string (兼容旧字段) 等于 total_margin_balance
usdt_total_available string (兼容旧字段) 等于 total_available
usdt_total_initial_margin string (兼容旧字段) 等于 total_initial_margin
usdt_total_maintenance_margin string (兼容旧字段) 等于 total_maintenance_margin
usdt_total_initial_margin_ratio string (兼容旧字段) 等于 total_initial_margin_ratio
usdt_total_maintenance_margin_ratio string (兼容旧字段) 等于 total_maintenance_margin_ratio
usdt_total_liability string (兼容旧字段) 等于 total_liability
usdt_total_unsettled_amount string (兼容旧字段) 等于 total_unsettled_amount
字段名称 数据类型 说明
currency string 币种
equity string 权益
liability string 负债
index_price string USD指数价格
usdt_index_price string (兼容旧字段) 等于 index_price
cash_balance string 现金余额
margin_balance string 保证金余额
available_balance string 可用余额
initial_margin string 初始保证金
spot_margin string 现货冻结金额
maintenance_margin string 维持保证金
potential_liability string 潜在负债
interest string 借币利息
interest_rate string 借币利率
pnl string 币种维度损益
total_delta string 账户delta总值
session_rpl string 已实现损益
session_upl string 未实现损益
option_value string 期权市值
option_pnl string 期权损益
option_session_rpl string 期权已实现损益
option_session_upl string 期权未实现损益
option_delta string 期权delta
option_gamma string 期权gamma
option_vega string 期权vega
option_theta string 期权theta
future_pnl string 期货损益
future_session_rpl string 期货已实现损益
future_session_upl string 期货未实现损益
future_session_funding string 期货funding
future_delta string 期货delta
future_available_balance string 期货最大可用余额
option_available_balance string 期权最大可用余额
unsettled_amount string 待结金额

用户仓位频道(position)

Request

{
    "type":"subscribe",
    "channels":[
        "position"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "categories":[
        "future"
    ],
    "interval": "100ms",
    "token":"6d501ded-3c40-4697-b390-218a54b9de19"
}

Response

{
    "channel":"position",
    "timestamp":1643101230232,
    "module":"linear",
    "data":[
        {
            "avg_price":"42474.49668874",
            "category":"future",
            "expiration_at":4102444800000,
            "index_price":"36076.66600000",
            "initial_margin":"21.81149685",
            "instrument_id":"BTC-USDT-PERPETUAL",
            "leverage":"50.00000000",
            "maintenance_margin":"16.36076260",
            "mark_price":"36097.57784846",
            "position_pnl":"192.58294898",
            "position_session_rpl":"-0.16699671",
            "position_session_upl":"-1.28505101",
            "qty":"-0.03020000",
            "qty_base":"-0.03020000",
            "roi":"8.82942378",
            "session_avg_price":"36055.02649047",
            "session_funding":"-0.16699671",
            "liq_price": "3587263.29572346",
        }
    ]
}

position频道推送用户的仓位信息。

频道信息

频道名称 权限 订阅参数 推送频率
position private categories + pairs [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
qty string 仓位
qty_base string 仓位(基础币种) (期货)
avg_price string 开仓均价
position_pnl string 仓位损益
position_session_upl string 仓位未实现损益
position_session_rpl string 仓位已实现损益
index_price string 指数价格
mark_price string 标记价格
initial_margin string 初始保证金
maintenance_margin string 维持保证金
session_avg_price string 持仓均价
session_funding string 当前周期funding(永续)
category string 产品种类
roi string 回报率
option_delta string 期权delta
option_gamma string 期权gamma
option_vega string 期权vega
option_theta string 期权theta
liq_price string 预估平仓价(期货)
leverage string 杠杆率(期货)

用户订单频道(order)

Request

{
    "type":"subscribe",
    "channels":[
        "order"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "categories":[
        "future"
    ],
    "interval": "100ms",
    "token":"6d501ded-3c40-4697-b390-218a54b9de19"
}

Response

{
    "channel":"order",
    "timestamp":1643101425658,
    "module":"linear",
    "data":[
        {
            "auto_price":"0.00000000",
            "auto_price_type":"",
            "avg_price":"0.00000000",
            "cash_flow":"0.00000000",
            "created_at":1643101425539,
            "filled_qty":"0.00000000",
            "hidden":false,
            "initial_margin":"",
            "instrument_id":"BTC-USDT-PERPETUAL",
            "is_liquidation":false,
            "is_um":true,
            "label":"",
            "maker_fee_rate":"0.00010000",
            "mmp":false,
            "order_id":"1034087",
            "order_type":"limit",
            "pnl":"0.00000000",
            "post_only":false,
            "price":"36088.95000000",
            "qty":"0.02000000",
            "reduce_only":false,
            "reject_post_only":false,
            "reorder_index":0,
            "side":"buy",
            "source":"web",
            "status":"pending",
            "stop_order_id":"",
            "stop_price":"0.00000000",
            "taker_fee_rate":"0.00010000",
            "time_in_force":"gtc",
            "updated_at":1643101425539,
            "user_id":"606122",
            "fee": "0.00000000",
            "fee_ccy": "USDT",
            "is_fee_deducted": true,
            "fee_in_deduction_ccy": "3.000000000000",
            "fee_deduction_ccy": "TONCOIN",
            "fee_deduction_rate": "0.202100000000"
        }
    ]
}

order频道推送用户的订单信息。

频道信息

频道名称 权限 订阅参数 推送频率
order private categories + pairs [raw, 100ms]

返回数据

字段名称 类型 说明
instrument_id string 产品名称
order_id string 订单ID
qty string 订单数量
filled_qty string 成交数量
remain_qty string 持有数量
price string 订单价格
avg_price string 平均成交价
side string 订单方向
order_type string 订单类型
time_in_force string 生效时间
status string 订单状态
cash_flow string 现金流
pnl string 损益
auto_price string 自动价格
auto_price_type string U本位自动价格类型
is_liquidation boolean 是否强平单
taker_fee_rate string Taker 手续费率
maker_fee_rate string Maker 手续费率
label string 自定义标签
stop_price string 触发价(止盈止损单)
reduce_only boolean 是否reduce only单
post_only boolean 是否post only单
reject_post_only boolean 是否reject post only单
mmp boolean 是否 mmp单
reorder_index integer 内部排序使用
created_at integer 创建时间戳
updated_at integer 更新时间戳
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例

用户交易频道(user_trade)

Request

{
    "type":"subscribe",
    "channels":[
        "user_trade"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "categories":[
        "future"
    ],
    "interval": "100ms",
    "token":"6d501ded-3c40-4697-b390-218a54b9de19"
}

Response

{
    "channel":"user_trade",
    "timestamp":1643101722258,
    "module":"linear",
    "data":[
        {
            "created_at":1643101722020,
            "fee_rate":"0.00010000",
            "index_price":"36214.05400000",
            "instrument_id":"BTC-USDT-PERPETUAL",
            "is_block_trade":false,
            "is_taker":true,
            "label":"",
            "order_id":"1034149",
            "order_type":"limit",
            "price":"36219.85000000",
            "qty":"0.00100000",
            "side":"buy",
            "sigma":"0.00000000",
            "trade_id":"1005590992",
            "underlying_price":"",
            "usd_price":"",
            "fee": "0.00000000",
            "fee_ccy": "USDT",
            "is_fee_deducted": true,
            "fee_in_deduction_ccy": "3.000000000000",
            "fee_deduction_ccy": "TONCOIN",
            "fee_deduction_rate": "0.202100000000",
            "fee_deduction_ccy_index": "1.372980000000",
            "closed_pnl": "0.03600000"
        }
    ]
}

user_trade频道推送用户的交易信息。

频道信息

频道名称 权限 订阅参数 推送频率
user_trade private categories + pairs [raw, 100ms]

返回数据

字段名称 类型 说明
order_id string 订单ID
trade_id string 交易ID
instrument_id string 产品名称
order_type string 订单类型
side string 订单方向
price string 成交价格
qty string 成交数量
fee_rate string 手续费率
sigma string 隐含波动性(期权)
is_taker boolean 是否taker
is_block_trade boolean 是否block trade
index_price string 指数价格
underlying_price string 标的价格(期权)
usd_price string USD 价格(自动价格订单)
label string 用户方订单唯一ID
created_at integer 创建时间戳
fee string 手续费
fee_ccy string 手续费单位
is_fee_deducted bool 是否启用手续费抵扣
fee_in_deduction_ccy string 手续费,以抵扣币种计
fee_deduction_ccy string 手续费抵扣币种
fee_deduction_rate string 手续费抵扣减免比例
fee_deduction_ccy_index string 手续费抵扣币种的指数价格
closed_pnl string 平仓交易盈亏

MMP冻结事件频道(mmp_frozen)

Request

{
    "type":"subscribe",
    "channels":[
        "mmp_frozen"
    ],
    "pairs":[
        "BTC-USD"
    ],
    "interval": "100ms",
    "token":"6d501ded-3c40-4697-b390-218a54b9de19"
}

Response

{
    "channel":"mmp_frozen",
    "timestamp":1643101722258,
    "module":"linear",
    "data":{
        "pair":"BTC-USD",
        "frozen_until_ms":1643101725000
    }
}

mmp_frozen频道推送MMP冻结事件。

frozen_until_ms 显示冻结状态。
frozen_until_ms > 0: 冻结到指定时间戳,或者手动reset MMP解冻
frozen_until_ms = 0: 冻结直到reset MMP解冻

频道信息

频道名称 权限 订阅参数 推送频率
mmp_frozen private pairs [raw, 100ms]

返回数据

字段名称 类型 说明
pair string 币对名称
frozen_until_ms integer MMP冻结时间戳

Websocket RPC

公共数据结构

Request

{
    "type":"RPC_name",
    "token":"If3Fy-o5TiOOTfvlmtryR0MTiziutYaYFkH3aRovJWWEXqCAD7CIdnbhGG5bwRqLRrGkOFEOjh0L",
    "params":{
        "param1":"hello"
    }
}

Response

{
    "type":"RPC_name",
    "result":{
        "code":0,
        "message":"",
        "data":{
            "field1":"world"
        }
    }
}

建立websocket连接后,除了数据订阅,还支持发送JSON格式的RPC请求。

首次发送私有请求需要先通过rest接口获取认证token,然后将token作为请求参数填入进行鉴权,详细参考“Websocket 数据订阅 - 获取认证Token”。

请求参数

字段名称 类型 说明
type string 请求类型
token string 私有请求认证token
params object 请求参数

返回数据

字段名称 类型 说明
type string 请求类型
result object 返回结果

result结构

字段名称 类型 说明
code integer 错误码
message string 错误信息
data object 返回数据

PING

Request

{
    "type":"ping",
    "params":{
        "id":123
    }
}

Response

{
    "type":"pong",
    "result":{
        "code":0,
        "message":"",
        "data":{
            "id":123,
            "timestamp":1632295288253
        }
    }
}

用于检测连接收发数据是否正常。客户端发送PING请求,服务器收到后回复PONG并返回收到PING时的时间戳。

请求信息

名称 访问范围
ping public

请求参数

字段名称 类型 是否必须 说明
id integer 可选 客户端自定义的请求ID,服务器回复时将ID回填到PONG消息中

返回数据

字段名称 类型 说明
id integer 客户端自定义请求ID
timestamp integer 服务器收到PING时的时间戳

设置COD (cancel_on_disconnect)

Request

{
    "type":"cancel_on_disconnect",
    "token":"If3Fy-o5TiOOTfvlmtryR0MTiziutYaYFkH3aRovJWWEXqCAD7CIdnbhGG5bwRqLRrGkOFEOjh0L",
    "params":{
        "scope":"connection",
        "enable":true
    }
}

Response

{
    "type":"cancel_on_disconnect",
    "result":{
        "code":0,
        "message":"",
        "data":""
    }
}

基于连接设置开启/关闭COD (Cancel On Disconnect)。开启COD后,当websocket连接断开时,取消用户所有订单。

与rest接口 POST /v1/account_configs/cod 的差异说明:

请求信息

名称 访问范围
cancel_on_disconnect private

请求参数

字段名称 类型 是否必须 说明
scope string 可选 COD生效范围,目前只支持connection
enable bool 必须 true表示开启,false表示关闭

返回数据

None

常量定义

Account Mode

账户模式 描述
classic 经典模式
um 统一保证金模式
migrating-to-um 模式迁移中: 经典到统保
migrating-to-classic 模式迁移中: 统保到经典

Risk mode

风控模式 描述
regular 普通模式
portfolio_margin PM模式(期权/期货组合保证金模式)

Instrument Category

产品种类 描述
option 期权
future 期货(包括永续)

Option type

期权类型 描述
call 看涨期权
put 看跌期权

Order side

订单方向 描述
buy
sell

Order type

订单类型 描述
limit 限价单
market 市价单
trigger-limit 条件单(限价)
trigger-market 条件单(市价)
twap_market Twap市价单

Order status

订单状态 描述
pending 订单初始状态
open 订单活跃状态
filled 订单全部成交状态
cancelled 订单撤销状态

ConditionalOrder status

条件单状态 描述
open 条件单活跃状态
triggered 条件单已触发状态
cancelled 条件单已撤销状态
failed 条件单触发失败

Order time in force

订单有效时间 描述
gtc 一直有效
fok 全部成交,否则将被取消
ioc 立即成交可成交的部分,然后取消剩余部分

Usdx Order auto price type

自动价格类型 描述
base 以Base currency价格下单
iv 以隐含波动率下单

Order source

订单来源 描述
api API
web 网页UI
app 手机APP

Account Mode

账户模式 描述
classic 经典模式
um 统一保证金模式
migrating-to-um 模式迁移中: 经典到统保
migrating-to-classic 模式迁移中: 统保到经典

UM transaction log type

UM交易日志类型 描述
spot-trade-pay 现货交易-支付
spot-trade-recv 现货交易-收入
deri-trade 币本位期权/期货交易
deri-delivery 币本位期权/期货交割
deri-settlement 币本位期权/期货结算
deri-socialized-fund 币本位期权/期货分摊
usdx-trade U本位期权/期货交易
usdx-delivery U本位期权/期货交割
usdx-settlement U本位期权/期货结算
usdx-socialized-fund U本位期权/期货分摊
pay-accrued-interest 支付利息
um-pex-trade-pay 自动卖币
um-pex-trade-recv 自动买币
deposit 充值
bad-deposit 充值失败
withdraw 提币
withdraw-revert 撤销提币
transfer-in 账户-转入
transfer-out 账户-转出
usdx-funding-settlement 实时funding结算

Feerate source

费率来源 描述
user_defined 定制(优先级最高)
vip VIP等级(成交量)
vip_manual VIP等级(手动)

错误码

错误处理

bit.com trading API 说明:


当调用bit.com的交易API时,例如 下单,编辑订单,取消订单,调用者将获得以下四种结果之一:

  1. 调用成功
  2. 调用失败
  3. 接收到响应,但是不能确定操作是成功还是失败
  4. 不能接收到响应

类型3的结果发生在bit.com的前端Web服务器未能及时从撮合引擎收到响应(由于网络问题或超时)时。 响应的形式可以为

  1. HTTP 响应"504 - Gateway Timeout": 表示故障发生在API网关层面
  2. HTTP 响应"200 - OK", 但是 JSON error code = 18500000: 表示 RPC timeout
  3. 其他形式的网络错误(如果故障发生在到达bit.com的网关之前).

当类型3的结果发生时,调用方将无法确定撮合引擎是否已接收/处理/拒绝了所发送的请求。 因此, 调用方必须发起另一个查询请求,以确认订单或帐户的状态。

Bit.com API 错误码列表:

错误码 描述
0 成功(无错误)
18100100 一般错误
18100101 不合法订单请求
18100102 不合法订单方向
18100103 不合法订单价格
18100104 不合法订单数量
18100105 不合法订单类型
18100106 不合法订单时效
18100107 获取仓位错误
18100109 获取Underlying价格失败
18100110 下单错误
18100111 序列化错误
18100112 提交创建订单请求出错
18100113 不合法订单id
18100114 获取订单错误
18100115 订单没有找到
18100116 提交撤销订单请求出错
18100117 不合法订单状态参数
18100119 获取交易记录错误
18100120 不合法创建期权请求
18100121 计算行权价错误
18100122 创建期权错误
18100123 不合法更新期权请求
18100124 不合法到期日
18100125 获取期权错误
18100126 不合法期权状态
18100127 更新期权错误
18100128 获取到期日错误
18100129 不合法交割价
18100130 期权包含有未结订单
18100131 不合法转账请求
18100132 不合法转账数量
18100133 创建转账请求错误
18100134 获取用户交易记录错误
18100135 获取转账错误
18100137 获取账户错误
18100138 获取交易记录错误
18100139 不合法的期权类型
18100141 不合法的货币
18100142 获取Underlying错误
18100143 获取Ticks错误
18100144 获取标记价格错误
18100145 获取Portfolio Margin错误
18100146 更新账户出错
18100147 获取交易日志错误
18100148 审核账户错误
18100149 交割信息错误
18100150 超过账户最大未结订单数目
18100151 超过品种最大未结订单数目
18100152 获取未结订单数目错误
18100153 创建到期日错误
18100154 更新存取Token出错
18100155 不合法的删除期权请求
18100156 删除期权出错
18100157 不合法的配置
18100158 更新配置错误
18100159 获取手续费率出错
18100160 不合法的参数
18100161 获取Orderbook出错
18100162 获取Index错误
18100163 账户信息错误
18100164 获取用户中心转账出错
18100165 不合法的用户
18100166 风险基金账户出错
18100167 风险日志错误
18100168 费用账户错误
18100169 费用日志错误
18100170 获取交割记录出错
18100171 获取风险数据出错
18100172 不合法的市场深度
18100173 到期错误
18100174 获取Orderbook统计出错
18100175 获取结算记录错误
18100176 获取Trading View数据出错
18100177 获取用户出错
18100178 保存数据出错
18100179 获取Funding图表出错
18100180 不合法的撤销订单请求
18100181 获取产品出错
18100183 获取期货产品出错
18100185 不合法的产品
18100186 平仓请求出错
18100187 获取订单保证金出错
18100188 获取限价价格出错
18100189 不合法的stop价格
18100190 获取未结stop order数目出错
18100191 超过最大stop order数目
18100192 不合法的stop价格
18100193 不合法的stop order触发类型
18100194 保存stop order失败
18100195 删除到期日出错
18100196 获取Funding Rate出错
18100197 不合法的更新到期日请求
18100198 更新到期日出错
18100199 余额不足
18100200 不合法的交易类型
18100201 获取指数数据出错
18100202 不合法的参数
18100204 不合法的分页参数
18100205 获取市场统计量出错
18100206 系统账户错误
18100210 不合法的操作员
18100211 获取接管记录出错
18100212 不合法的操作员用户id
18100213 开始接管
18100214 不合法的账户id
18100215 推出接管
18100216 绑定管理员到账户
18100217 解除绑定管理员到账户
18100218 计算组合保证金
18100223 获取接管订单出错
18100224 不合法的修改订单请求
18100225 自动价格错误
18100226 接管切换用户出错
18100227 账户被锁定
18100228 获取爆仓信息出错
18100229 记录爆仓请求出错
18100230 超过最大stop order数目
18100231 不合法的stop order状态
18100232 邮件验证码错误
18100233 电话验证码错误
18100234 Rpc错误: 修改订单失败
18100235 记录爆仓信息出错
18100236 不合法的订单角色
18100237 没有 Block Order 权限
18100238 自成交错误
18100239 不合法的时间
18100240 不合法的 Block Order 请求
18100241 接受 Block Order 出错
18100242 拒绝 Block Order 出错
18100243 计算期权维持保证金出错
18100244 减仓单错误
18100245 Block Trade 服务停止运行
18100246 获取触发价出错
18100247 获取未结订单挂单量出错
18100248 获取仓位出错
18100249 超过期权最大未结订单数目
18100250 超过期货最大未结订单数目
18100251 体验金请求出错
18100252 体验金错误
18100253 获取体验金出错
18100254 抵扣金请求出错
18100255 抵扣金错误
18100256 获取体验金活跃状态出错
18100257 获取账户配置出错
18100258 不合法的用户KYC水平
18100259 体验金重复
18100260 计算仓位出错
18100261 超过账户delta
18100262 不合法的提币请求
18100263 提币出错
18100264 不合法的用户自定义字符串
18100265 不合法的block trade来源
18100266 发送校验码出错
18100267 不合法的校验码
18100268 不合法的数字字符串
18100269 超过最大仓位
18100270 超过最大未结订单总数量
18100271 获取 Block Order出错
18100272 重复的 Blocktrade Key
18100273 创建体验金活跃记录出错
18100274 体验金超额
18100275 不合法的批量下单请求
18100276 批量订单数目错误
18100277 Rpc 批量下单出错
18100278 数据库超时
18100279 不允许接管
18100280 不合法的批量改单请求
18100281 不在未结订单列表
18100282 Rpc 批量改单出错
18100285 Mmp 错误
18100304 不合法的频道
18100305 不合法的类别
18100306 不合法的推送频率
18100311 CashBalance 小于 AccruedInterest
18100312 币对不支持PM模式
18100313 保证金不足
18100314 账户模式正在迁移到Um模式
18100315 账户模式正在迁移到经典模式
18100637 查下止盈止损单配置失败
18100638 错误的止盈止损单模式
18100639 止盈止损单模式不匹配
18100640 错误的止盈止损单触发模式
18100641 止盈止损单数量错误
18100642 止盈止损单数量不能为负
18100401 不合法的地址
18100402 不是白名单地址
18100403 资金秘密错误
18100404 提币订单不存在
18100405 KYT 拒绝
18100406 提币太频繁
18100407 超过提币额度
18100408 提币金额小于最小金额
18100500 交易权限错误
18100501 内部database错误
18100502 内部缓存错误
18100503 内部网络错误
18200300 超过API调用限额
18200301 登陆错误
18200302 鉴权错误, 鉴权码:
17002012: 无访问此api权限
17002011: IP地址错误
17002010: 签名错误
17002014: 时间戳过期
17002006: 内部错误
17002013: 无效 access key
18200303 超过最大连接数
18300300 无参赛
18300301 报名参赛失败
18300302 已报名参赛
18400300 只撤单阶段
18400301 正在结算中
18500000 Rpc timeout (需要调用方发查询请求确认结果,见上文)