订阅订单数据

orders.$contract_code

是否验签: 是

接口权限: 读取

限频: WebSocket私有订单成交推送接口(需要API KEY验签) 一个UID最多同时建立30个私有订单成交推送WS链接。该用户在一个品种(包含该品种的所有周期的合约)上,仅需要维持一个订单推送WS链接即可。 单个链接为50次/秒的请求,单个IP链接为100次/秒的请求。 注意: 订单推送WS的限频,跟用户RESTFUL私有接口的限频是分开的,相互不影响。

接口描述: 当订单发生下单、订单撤单等事件时,推送消息。

订阅地址

环境
地址

线上环境

wss://api.sunx.io/ws/v1/notification

线上环境(aws客户首选)

wss://api.sunx.io/ws/v1/notification

请求参数

字段名称
类型
说明

op

string

必填;操作名称,sub 或 unsub;

cid

string

选填;Client 请求唯一 ID

topic

string

必填; orders

contract_code

string

必填; contract_code * 或者 BTC-USDT 或者 BTC-USDT-240909

规则说明

订阅(sub)
取消订阅(unsub)
规则

*

*

允许

*

contract_code

不允许

订阅参数

参数
数据类型
是否必填
描述
取值范围
默认值

contract_code

string

true

合约代码,支持大小写

全部:*(交割和永续), 永续:“BTC-USDT:... ,交割:"BTC-USDT-210625"...

数据更新

参数
数据类型
是否必填
描述
取值范围

op

String

true

操作名称,推送固定值为 notify;--可不可以去掉

topic

String

true

推送的主题

orders

ts

long

true

服务端应答时间戳

uid

String

true

用户uid

<data>

false

contract_code

String

true

合约代码

永续:"BTC-USDT"... ,交割:"BTC-USDT-210625"..

side

String

true

买卖方向

buy:买 "sell":卖

position_side

String

true

仓位方向

"long":多 "short":空 “both”:单向持仓

type

String

true

订单类型;枚举

"market": 市价,"limit":限价, "post_only":只挂单

price_match

String

true

价格匹配

order_id

String

true

订单id

client_order_id

String

true

用户自定义订单ID

margin_mode

String

true

保证金模式

枚举 cross

price

String

true

委托价格

volume

String

true

委托数量

lever_rate

Long

true

杠杆等级

state

string

true

订单状态

new, partially_filled, , partially_canceled, filled ,canceled,

order_source

String

true

订单来源

(system:系统、web:用户网页、api:用户API、m:用户M站、risk:风控系统、settlement:交割结算、ios:ios客户端、android:安卓客户端、windows:windows客户端、mac:mac客户端、trigger:计划委托触发、tpsl:止盈止损触发、ADL: adl订单)

reduce_only

Boolean

true

只减仓

time_in_force

String

true

枚举fok, ioc, gtc,非必填,默认是gtc

trade_avg_price

String

true

成交均价

trade_volume

String

true

成交数量

trade_turnover

String

true

成交金额

fee_currency

String

true

手续费币种,多个则使用","分隔

fee

String

true

总手续费(U)

tp_trigger_price

String

true

止盈触发价格

tp_order_price

String

true

止盈委托价格(最优N档委托类型时无需填写价格)

tp_type

String

true

止盈委托类型,不填默认为market: 市价,maket: 限价:limit ,最优5档: optimal_5,最优10档:optimal_10,最优20档:optimal_20

tp_trigger_price_type

String

false

止盈价格触发类型,默认是最新价

"last":最新价,"mark":标记价格

sl_trigger_price

String

true

止损触发价格

sl_order_price

String

true

止损委托价格(最优N档委托类型时无需填写价格)

sl_type

String

true

止损委托类型,不填默认为 市价,maket: 限价:limit ,最优5档: optimal_5,最优10档:optimal_10,最优20档:optimal_20

sl_trigger_price_type

String

false

止损价格触发类型,默认是最新价

"last":最新价,"mark":标记价格

price_protect

boolean

false

价差保护,默认为false。仅当设置止盈/止损需要该参数。

false 或者 true

profit

String

true

平仓盈亏

contract_type

String

true

业务类型

swap(永续)、this_week(当周)、next_week(次周)、quarter(当季)、next_quarter(次季)

created_time

String

true

订单创建时间, UTC时间戳(MS)

updated_time

String

true

订单更新时间, UTC时间戳(MS)

self_match_prevent

String

true

防自成交

cancel_taker: 撤销taker单 cancel_maker:撤销maker单 cancel_both:撤销全部订单

<data>

false

备注: 假设订单一次成交,且匹配了多个完全成交,则订单频道多次推送的状态都是“filled-完全成交“,但成交量可能小于下单量. 假设IOC订单部分成交剩余撤单,则订单频道多次推送的状态都是“partially_canceled-部分被撤销“,但成交量 + 撤单量可能小于下单量. 建议: 成交量 + 撤单量 是否等于 下单量 来辅助判断是否为最后一次更新

订阅示例

订阅成功示例

数据更新示例

最后更新于