Deribit 托管网络上引入公共事件多播,为分发信息提供了低延迟接口,这也显著降低了客户端和服务器端的资源需求。在Websocket API上迁移客户端使用多播事件而不是事件订阅,不仅由于延迟更低和编码效率更高而使他们能够更快地做出反应,而且还可以提高API节点上交易操作的处理速度
这些事件使用 SBE(简单二进制编码)格式以 UDP 多播数据包的形式发送。
多播系统按货币和产品(永久、期权、期货)组合对事件进行分组。这些组可以与信道关联(实际的信道关联在单独的文档中维护和共享),其中可以为每个信道分配单独的多播组地址和 UDP 目标端口号。每个通道保留 100.000 个数据包的有限历史记录以供恢复。
UDP 协议标头之后,多播数据包以帧头开始,该帧标头包含信道中的数据包长度、信道 ID 和序列号(有关序列号的更多信息,请参见 4.D)。数据包长度是所有 SBE 消息(序列号之后)的总长度,以字节为单位。此标头的主要目的是允许客户端使用常规的 WebSocket/REST API 检测数据包何时丢失并检索它们
|
数据包长度 (uint16) |
|---|
|
频道 ID (uint16) |
|
序列号 (uint32) |
|
SBE 消息 |
|
SBE 消息 |
|
SBE 消息 |
|
… |
请注意,下面提供的所有示例消息以及示例数据包捕获均来自本地开发系统,定义的仪器仅用于生成用于测试/开发多播解码器的数据。使用的产品/仪器参数不匹配(也不打算)与生产产品/仪器相匹配
SBE 是一种高效的二进制编码,其特性允许以向后兼容的方式使用新元素扩展协议。此外,它还有一个相当广泛使用/众所周知的标准,其背后的社区提供了诸如代码生成工具之类的工具。
每条 SBE 消息都包含一个标题、一些固定长度的字段、群组(可变长度的项目列表)以及这个严格序列中的可选可变长度字段。
|
标题(固定大小) |
|---|
|
固定长度字段(固定大小) |
|
群组 |
|
可变长度字段 |
注意
从 v1.6.1 开始,XML 规范以 2 种格式提供。这是由于生成的代码在不同语言中的行为存在差异。根据客户的反馈,为某些语言生成的代码似乎已经假定了 messageHeader 作为每条消息的一部分,不要求它成为每个消息部分的一部分(甚至需要手动修复)。对于这些,提供了一个 XML 文件,没有 messageHeader 成为消息规范的一部分 (deribit_multicast_noheader.xml)。另一个(默认)版本适用于代码生成器需要在每条消息(deribit_multicast.xml)中指定标头的语言(例如 CPP)。对于使用 CPP 的客户端,代码生成器工具
Real-Logic 或内部开发的工具取决于 messageHeader 在消息中指定,建议使用默认 XML。
本文档中的 XML 消息片段不包含标题。包含标题的同一封邮件还包含 messageHeader 作为第一个字段(后续字段 ID 将增加一个)。
<composite name="messageHeader"> <type name="blockLength" primitiveType="uint16" /> <type name="templateId" primitiveType="uint16" /> <type name="schemaId" primitiveType="uint16" /> <type name="version" primitiveType="uint16" /> <type name="numGroups" primitiveType="uint16" /> <type name="numVarDataFields" primitiveType="uint16" /> </composite>
-
blockLength是消息中固定字段的总字节数。该字段的用途是,如果引入新的固定字段(总是在现有字段之后),客户端可以解码它知道的字段,并且可以基于该字段跳过
用于查找最终组/变量字段的开头或消息结尾的其他项目
-
templateId指相应消息的 ID(例如,订单簿变更时为 1001) -
这个
schemaId和version字段用于指示 XML 规范的 ID 及其版本号 -
numGroups是消息中的群组/列表的数量。该字段的用途类似于blockLength并允许以向后兼容的方式引入新群组 -
numVarDataFields用途类似blockLength和numGroups
群组是项目列表。每条消息可以包含 0 个或更多组。每个组可以有 0 个或更多项目。这些项目的结构与 SBE 消息类似。它们可以由固定长度的区块、(嵌套)组和可变长度字段组成。有关物品结构以及物品数量的信息(numInGroup) 在每个组的标题中都有描述。
群组标题定义:
<composite name="groupSizeEncoding"> <type name="blockLength" primitiveType="uint16"/> <type name="numInGroup" primitiveType="uint16"/> <type name="numGroups" primitiveType="uint16"/> <type name="numVarDataFields" primitiveType="uint16"/> </composite>
请注意,如果组标题表明条目没有嵌套组 (numGroups = 0) 或可变长度的数据字段 (numVarDataFields = 0) 则条目的长度是固定的,等于 blockLength。在这种情况下,组中的总字节数可以通过以下公式计算: blockLength * numInGroup。
可变长度字段以长度和长度的字节数开头。在当前的实现中,变量字段用于仪器事件/消息中的仪器名称
<composite name="varString" description="Variable-length string"> <type name="length" primitiveType="uint8" /> <type name="varData" length="0" primitiveType="uint8" /> </composite>
自版本 1.6 起,该平台多播多个事件:
活动的结构和内容旨在与当前活动相同或非常相似 Websocket API 订阅事件。
[en] The purpose of the Instrument event is to notify clients when an instrument (order book) is created or changes lifecycle state, and to provide static instrument information via snapshots.
[en] Based on this event, clients can:
-
[en] Start tracking a newly created or reactivated instrument.
-
[en] Stop tracking an instrument that has transitioned into an inactive or terminal lifecycle state.
-
[en] Maintain a reliable Instrument ID ↔ Instrument Name mapping, as both are included in the message payload.
[en] The instrument message is also sent on the snapshot channels, where it provides static instrument metadata as part of the snapshot flow.
[en] Instrument Lifecycle and Order Book States[en] With 2026 年 1 月 13 日 release, the state field represents the current lifecycle stage of the instrument’s order book. Each state explicitly defines what actions are permitted and how the order book behaves.
[en] Supported order book states:
-
[en] open
[en] Default active trading state. The order book accepts new orders, edits, and cancellations. Prices are updated and trading is live.
-
[en] locked
[en] New orders and edits are not accepted; cancellations are accepted. Books may start in this state or be locked by administrative action. Settlement remains possible.
-
[en] settlement
[en] Entered during settlement or delivery processing. New orders, edits, and cancellations are not accepted. Good-Till-Day orders are canceled upon entry.
-
[en] delivered
[en] Final state after delivery completion. No new orders, edits, or cancellations are accepted. All open orders are canceled upon entry.
-
[en] inactive
[en] No new orders, edits, or cancellations are accepted. All open orders are canceled upon entry. This state may be final and is used for instruments that are no longer active, including combo instruments.
-
[en] halted
[en] Entered due to an error condition. Settlement is not possible while any book is in this state.
[en] Lifecycle transitions are communicated through instrument messages, enabling clients to respond accurately to trading availability, settlement processing, and terminal conditions.
[en] Batched Instrument Changes[en] When instrument changes occur in bulk (for example, closing multiple option books), multiple instrument messages may be combined into a single packet, even across different instruments, provided they belong to the same currency/product combination.
[en] When books transition into inactive or terminal states, book change events (such as deletion of remaining price levels) and instrument lifecycle state change events may be combined.
[en] Combo instruments follow the same order book lifecycle states as all other instruments.
[en] Key characteristics:
-
[en] Combo instruments are distributed on dedicated multicast channels, as defined in the Deribit Multicast Channels document (v1.1 or later).
-
[en] Changes to instrument messages related to instrument kinds or lifecycle states apply only to combo channels.
[en] Lifecycle behavior for combos:
-
[en] When a combo instrument is removed from active trading, its order book transitions to the inactive state. An instrument message is sent reflecting this state change, and the static instrument state (e.g. in ticker or instrument snapshots) updates to inactive.
-
[en] When a previously inactive combo instrument is made available for trading again, an instrument message is sent indicating a transition back to the open state, and the static instrument state updates accordingly.
<message name="instrument" id="1000"> <field name="instrumentId" id ="1" type="uint32" /> <field name="instrumentState" id="2" type="instrumentState" /> <field name="kind" id="3" type="instrumentKind" /> <field name="instrumentType" id="4" type="instrumentType" /> <field name="optionType" id="5" type="optionType" /> <field name="rfq" id="6" type="yesNo" /> <field name="settlementPeriod" id="7" type="period" presence="optional" /> <field name="settlementPeriodCount" id="8" type="uint16" /> <field name="baseCurrency" id="9" type="string8" /> <field name="quoteCurrency" id="10" type="string8" /> <field name="counterCurrency" id="11" type="string8" /> <field name="settlementCurrency" id="12" type="string8" /> <field name="sizeCurrency" id="13" type="string8" /> <field name="creationTimestampMs" id="14" type="uint64" /> <field name="expirationTimestampMs" id="15" type="uint64" /> <field name="strikePrice" id="16" type="double" presence="optional" /> <field name="contractSize" id="17" type="double" /> <field name="minTradeAmount" id="18" type="double" /> <field name="tickSize" id="19" type="double" /> <field name="makerCommission" id="20" type="double" /> <field name="takerCommission" id="21" type="double" /> <field name="blockTradeCommission" id="22" type="double" presence="optional" /> <field name="maxLiquidationCommission" id="23" type="double" presence="optional" /> <field name="maxLeverage" id="24" type="double" presence="optional" /> <data name="instrumentName" id="25" type="varString" /> </message>
消息中使用的枚举类型
<enum name="instrumentState" encodingType="uint8"> <validValue name="created">0</validValue> <validValue name="open">1</validValue> <validValue name="closed">2</validValue> <validValue name="settled">3</validValue> <validValue name="deactivated">4</validValue> <validValue name="inactive">5</validValue> <validValue name="started">6</validValue> <validValue name="settlement" sinceVersion="4">7</validValue> <validValue name="delivered" sinceVersion="4">8</validValue> <validValue name="locked" sinceVersion="4">9</validValue> <validValue name="halted" sinceVersion="4">10</validValue> </enum> <enum name="instrumentKind" encodingType="uint8"> <validValue name="future">0</validValue> <validValue name="option">1</validValue> <validValue name="future_combo">2</validValue> <validValue name="option_combo">3</validValue> <validValue name="spot">4</validValue> </enum> <enum name="optionType" encodingType="uint8"> <validValue name="not_applicable">0</validValue> <validValue name="call">1</validValue> <validValue name="put">2</validValue> </enum> <enum name="instrumentType" encodingType="uint8"> <validValue name="not_applicable">0</validValue> <validValue name="reversed">1</validValue> <validValue name="linear">2</validValue> </enum> <enum name="period" encodingType="uint8"> <validValue name="perpetual">0</validValue> <validValue name="minute">1</validValue> <validValue name="hour">2</validValue> <validValue name="day">3</validValue> <validValue name="week">4</validValue> <validValue name="month">5</validValue> <validValue name="year">6</validValue> </enum>
Frame 4096: 227 bytes on wire (1816 bits), 227 bytes captured (1816 bits) on interface lo, id 0
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.2
User Datagram Protocol,
Src Port: 48210,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 177
Channel Id: 2
Channel Sequence: 1
Instrument State
Header
Root Block Length: 140
Type: instrument (1000)
Schema Id: 1
Version: 1
Num Groups: 0
Num Vars: 1
Instrument Id: 618
Instrument State: created (0)
Instrument Kind: option (1)
Instrument Type: not applicable (0)
Option Type: call (1)
RFQ: 0
Settlement Period: minute (1)
Settlement Period Count: 15
Base Currency: BTC
Quote Currency: BTC
Counter Currency: USD
Settlement Currency: BTC
Size Currency: BTC
Creation Timestamp: May 14, 2022 06:35:05.000000000 UTC
Expiration Timestamp: May 14, 2022 06:45:00.000000000 UTC
Strike Price: 29200
Contract Size: 1
Minimum Trade Amount: 0,01
Tick Size: 0,0001
Maker Commission: 0,0001
Taker Commission: 0,0005
Block Trade Commission: 0,00015
Max Liquidation Commission: 0
Max Leverage: 0
Instrument Name: BTC-14MAY22_0645-29200-C
Hex Dump
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 d5 bc fc 40 00 20 11 bf a8 7f 00 00 01 ef 6f ....@. ........o
0020 6f 02 bc 52 17 d4 00 c1 de 45 b1 00 02 00 01 00 o..R.....E......
0030 00 00 8c 00 e8 03 01 00 01 00 00 00 01 00 6a 02 ..............j.
0040 00 00 00 01 00 01 00 01 0f 00 42 54 43 00 00 00 ..........BTC...
0050 00 00 42 54 43 00 00 00 00 00 55 53 44 00 00 00 ..BTC.....USD...
0060 00 00 42 54 43 00 00 00 00 00 42 54 43 00 00 00 ..BTC.....BTC...
0070 00 00 a8 1d 47 c1 80 01 00 00 e0 31 50 c1 80 01 ....G......1P...
0080 00 00 00 00 00 00 00 84 dc 40 00 00 00 00 00 00 .........@......
0090 f0 3f 7b 14 ae 47 e1 7a 84 3f 2d 43 1c eb e2 36 .?{..G.z.?-C...6
00a0 1a 3f 2d 43 1c eb e2 36 1a 3f fc a9 f1 d2 4d 62 .?-C...6.?....Mb
00b0 40 3f 61 32 55 30 2a a9 23 3f 00 00 00 00 00 00 @?a2U0*.#?......
00c0 00 00 00 00 00 00 00 00 00 00 18 42 54 43 2d 31 ...........BTC-1
00d0 34 4d 41 59 32 32 5f 30 36 34 35 2d 32 39 32 30 4MAY22_0645-2920
00e0 30 2d 43 0-C
随着多种分时报价大小的引入,我们需要添加有关分笔成交量步长的信息,以便客户可以在不同的价格范围内以正确的分时大小下订单。
尽管 SBE 为添加新字段提供了向后兼容机制,但之所以选择引入新消息,是因为假设客户端实现比实现 SBE 的向后兼容机制更有可能忽略未知消息类型。第二个原因是,新消息允许我们删除已弃用的 “rfq” 字段。最近引入的 RFQ 消息为 RFQ 状态跟踪提供了一种更加可靠和全面的机制。SBE 不支持以向后兼容的方式从消息中删除字段,因此新消息是唯一的方法
其目的是在仪器状态更改和快照中发送这两条消息一段时间。在有足够的时间并及时发布公告以允许客户迁移到使用此新消息之后,原始仪器消息将从多播中删除
我们打算在将来使用这种机制对消息进行更改。
<message name="instrumentV2" id="1010" sinceVersion="3"> <field name="instrumentId" id ="1" type="uint32" /> <field name="instrumentState" id="2" type="instrumentState" /> <field name="kind" id="3" type="instrumentKind" /> <field name="instrumentType" id="4" type="instrumentType" /> <field name="optionType" id="5" type="optionType" /> <field name="settlementPeriod" id="6" type="period" presence="optional" /> <field name="settlementPeriodCount" id="7" type="uint16" /> <field name="baseCurrency" id="8" type="string8" /> <field name="quoteCurrency" id="9" type="string8" /> <field name="counterCurrency" id="10" type="string8" /> <field name="settlementCurrency" id="11" type="string8" /> <field name="sizeCurrency" id="12" type="string8" /> <field name="creationTimestampMs" id="13" type="uint64" /> <field name="expirationTimestampMs" id="14" type="uint64" /> <field name="strikePrice" id="15" type="double" presence="optional" /> <field name="contractSize" id="16" type="double" /> <field name="minTradeAmount" id="17" type="double" /> <field name="tickSize" id="18" type="double" /> <field name="makerCommission" id="19" type="double" /> <field name="takerCommission" id="20" type="double" /> <field name="blockTradeCommission" id="21" type="double" presence="optional" /> <field name="maxLiquidationCommission" id="22" type="double" presence="optional" /> <field name="maxLeverage" id="23" type="double" presence="optional" /> <group name="tickStepsList" id="24" dimensionType="groupSizeEncoding"> <field name="abovePrice" id="1" type="double" /> <field name="tickSize" id="2" type="double" /> </group> <data name="instrumentName" id="25" type="varString" /> </message>
此消息中使用的枚举类型与原始仪器消息中使用的枚举类型相同。
Frame 12890: 417 bytes on wire (3336 bits), 417 bytes captured (3336 bits) on interface lo, id 0
Interface id: 0 (lo)
Interface name: lo
Encapsulation type: Ethernet (1)
Arrival Time: Jun 15, 2023 20:51:00.018508968 CEST
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1686855060.018508968 seconds
[Time delta from previous captured frame: 0.001292339 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 283.628602527 seconds]
Frame Number: 12890
Frame Length: 417 bytes (3336 bits)
Capture Length: 417 bytes (3336 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:udp:deribit_sbe]
[Coloring Rule Name: UDP]
[Coloring Rule String: udp]
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)
Address: 00:00:00_00:00:00 (00:00:00:00:00:00)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: 00:00:00_00:00:00 (00:00:00:00:00:00)
Address: 00:00:00_00:00:00 (00:00:00:00:00:00)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 239.111.111.2
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint: Default (0)
.... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
Total Length: 403
Identification: 0x5ba3 (23459)
Flags: 0x40, Don't fragment
0... .... = Reserved bit: Not set
.1.. .... = Don't fragment: Set
..0. .... = More fragments: Not set
...0 0000 0000 0000 = Fragment Offset: 0
Time to Live: 32
Protocol: UDP (17)
Header Checksum: 0x2044 [validation disabled]
[Header checksum status: Unverified]
Source Address: 127.0.0.1
Destination Address: 239.111.111.2
User Datagram Protocol, Src Port: 32859, Dst Port: 6100
Source Port: 32859
Destination Port: 6100
Length: 383
Checksum: 0xdf03 [unverified]
[Checksum Status: Unverified]
[Stream index: 2]
[Timestamps]
[Time since first frame: 283.625157436 seconds]
[Time since previous frame: 0.001292339 seconds]
UDP payload (375 bytes)
Deribit SBE
Framing Header
Packet Length: 367
Channel Id: 2
Channel Sequence: 3145
Instrument State
Header
Root Block Length: 140
Type: instrument (1000)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 1
Instrument Id: 77
Instrument State: created (0)
Instrument Kind: option (1)
Instrument Type: reversed (1)
Option Type: call (1)
RFQ: 0
Settlement Period: week (4)
Settlement Period Count: 1
Base Currency: BTC
Quote Currency: BTC
Counter Currency: USD
Settlement Currency: BTC
Size Currency: BTC
Creation Timestamp: Jun 15, 2023 18:51:00.000000000 UTC
Expiration Timestamp: Jun 23, 2023 08:00:00.000000000 UTC
Strike Price: 25500
Contract Size: 1
Minimum Trade Amount: 0,01
Tick Size: 0,0001
Maker Commission: 0
Taker Commission: 0,0001
Block Trade Commission: 0,00015
Max Liquidation Commission: -nan
Max Leverage: -nan
Instrument Name: BTC-23JUN23-25500-C
Instrument State v2
Header
Root Block Length: 139
Type: instrument_v2 (1010)
Schema Id: 1
Version: 3
Num Groups: 1
Num Vars: 1
Instrument Id: 77
Instrument State: created (0)
Instrument Kind: option (1)
Instrument Type: reversed (1)
Option Type: call (1)
Settlement Period: week (4)
Settlement Period Count: 1
Base Currency: BTC
Quote Currency: BTC
Counter Currency: USD
Settlement Currency: BTC
Size Currency: BTC
Creation Timestamp: Jun 15, 2023 18:51:00.000000000 UTC
Expiration Timestamp: Jun 23, 2023 08:00:00.000000000 UTC
Strike Price: 25500
Contract Size: 1
Minimum Trade Amount: 0,01
Tick Size: 0,0001
Maker Commission: 0
Taker Commission: 0,0001
Block Trade Commission: 0,00015
Max Liquidation Commission: -nan
Max Leverage: -nan
Tick Size Steps Group
Header
Group Block Length: 16
Num In Group: 1
Group Num Groups: 0
Group Num Vars: 0
Tick Step List
above price : 0,001
tick_size : 0,0002
Instrument Name: BTC-23JUN23-25500-C
Hex Dump
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 01 93 5b a3 40 00 20 11 20 44 7f 00 00 01 ef 6f ..[.@. . D....o
0020 6f 02 80 5b 17 d4 01 7f df 03 6f 01 02 00 49 0c o..[......o...I.
0030 00 00 8c 00 e8 03 01 00 02 00 00 00 01 00 4d 00 ..............M.
0040 00 00 00 01 01 01 00 04 01 00 42 54 43 00 00 00 ..........BTC...
0050 00 00 42 54 43 00 00 00 00 00 55 53 44 00 00 00 ..BTC.....USD...
0060 00 00 42 54 43 00 00 00 00 00 42 54 43 00 00 00 ..BTC.....BTC...
0070 00 00 20 8a 65 c0 88 01 00 00 00 68 44 e7 88 01 .. .e......hD...
0080 00 00 00 00 00 00 00 e7 d8 40 00 00 00 00 00 00 .........@......
0090 f0 3f 7b 14 ae 47 e1 7a 84 3f 2d 43 1c eb e2 36 .?{..G.z.?-C...6
00a0 1a 3f 00 00 00 00 00 00 00 00 2d 43 1c eb e2 36 .?........-C...6
00b0 1a 3f 61 32 55 30 2a a9 23 3f ff ff ff ff ff ff .?a2U0*.#?......
00c0 ff ff ff ff ff ff ff ff ff ff 13 42 54 43 2d 32 ...........BTC-2
00d0 33 4a 55 4e 32 33 2d 32 35 35 30 30 2d 43 8b 00 3JUN23-25500-C..
00e0 f2 03 01 00 03 00 01 00 01 00 4d 00 00 00 00 01 ..........M.....
00f0 01 01 04 01 00 42 54 43 00 00 00 00 00 42 54 43 .....BTC....BTC
0100 00 00 00 00 00 55 53 44 00 00 00 00 00 42 54 43 .....USD....BTC
0110 00 00 00 00 00 42 54 43 00 00 00 00 00 20 8a 65 .....BTC..... .e
0120 c0 88 01 00 00 00 68 44 e7 88 01 00 00 00 00 00 ......hD........
0130 00 00 e7 d8 40 00 00 00 00 00 00 f0 3f 7b 14 ae ....@.......?{..
0140 47 e1 7a 84 3f 2d 43 1c eb e2 36 1a 3f 00 00 00 G.z.?-C...6.?...
0150 00 00 00 00 00 2d 43 1c eb e2 36 1a 3f 61 32 55 .....-C...6.?a2U
0160 30 2a a9 23 3f ff ff ff ff ff ff ff ff ff ff ff 0*.#?...........
0170 ff ff ff ff ff 10 00 01 00 00 00 00 00 fc a9 f1 ................
0180 d2 4d 62 50 3f 2d 43 1c eb e2 36 2a 3f 13 42 54 .MbP?-C...6*?.BT
0190 43 2d 32 33 4a 55 4e 32 33 2d 32 35 35 30 30 2d C-23JUN23-25500-
01a0 43 C
此事件包含订单簿等级的变化。更改可以是新关卡、更改关卡金额或删除(没有剩余金额),就像在websocket订阅事件中一样
组合的订单簿变更与普通乐器的订单簿更改相同。但是,由于组合交易会改变组合中各个工具(又名组合)的头寸(但不改变订单簿等级),因此组合交易将生成账面更改事件,其余的等级变化为空
同样,管理员发起的职位变动也可能触发图书变更事件,包括空白等级变化。
<message name="book" id="1001"> <field name="instrumentId" id="1" type="uint32" /> <field name="timestampMs" id="2" type="uint64" /> <field name="prevChangeId" id="3" type="uint64" /> <field name="changeId" id="4" type="uint64" /> <field name="isLast" id="5" type="yesNo" /> <group name="changesList" id="6" dimensionType="groupSizeEncoding"> <field name="side" id="1" type="bookSide" /> <field name="change" id="2" type="bookChange" /> <!-- Use double (64 bit float) encoding, SBE FIX price/amount decimal encoding makes sense when the decimal point is on a somewhat fixed position, for crypto, it can vary more by instrument --> <field name="price" id="3" type="double" /> <field name="amount" id="4" type="double" /> </group> </message>
此消息中使用的枚举类型
<enum name="bookChange" encodingType="uint8"> <validValue name="created">0</validValue> <validValue name="changed">1</validValue> <validValue name="deleted">2</validValue> </enum> <enum name="bookSide" encodingType="uint8"> <validValue name="ask">0</validValue> <validValue name="bid">1</validValue> </enum> <enum name="yesNo" encodingType="uint8"> <validValue name="no">0</validValue> <validValue name="yes">1</validValue> </enum>
这些事件使用与 websocket 事件相同的机制来确保订单簿的一致性。
每条消息都包含当前消息 changeId 和 prevChangeId。当收到一个事件时,它是 prevChangeId 应该与 changeId 书中最后一次看到的事件。应该假设变更ID只是一个不严格连续的单调递增数字。
图书变更清单偶尔会导致消息超过最大数据包大小。在这种情况下,平台将变更清单拆分为多个列表,并生成一系列完整的订单簿变更消息。消息具有相同的固定字段 (header, timestampMs, prevChangeId, changeId)但是 isLast 对于序列中除最后一条消息以外的所有消息,字段均设置为值 0,以指示是否发送了完整的更改列表。
示例消息
Frame 220: 135 bytes on wire (1080 bits), 135 bytes captured (1080 bits) on interface lo, id 0
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.3
User Datagram Protocol,
Src Port: 51012,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 85
Channel Id: 3
Channel Sequence: 21093
Book Change
Header
Root Block Length: 29
Type: book (1001)
Schema Id: 1
Version: 1
Num Groups: 1
Num Vars: 0
Instrument Id: 136
Timestamp: May 2, 2022 11:53:01.475000000 UTC
Previous Change ID: 3086730
Change ID: 3086733
Is Last Part: last (1)
Changes
Group Header
Group Block Length: 18
Num In Group: 2
Group Num Groups: 0
Group Num Vars: 0
Change List
delete bid - price : 35171,99
amount: 0
new bid - price : 36930,58
amount: 40
Hex Dump
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 79 7b 98 40 00 20 11 01 68 7f 00 00 01 ef 6f .y{.@. ..h....o
0020 6f 03 c7 44 17 d4 00 65 dd ea 55 00 03 00 65 52 o..D...e..U...eR
0030 00 00 1d 00 e9 03 01 00 01 00 01 00 00 00 88 00 ................
0040 00 00 23 e3 9d 84 80 01 00 00 8a 19 2f 00 00 00 ..#........./...
0050 00 00 8d 19 2f 00 00 00 00 00 01 12 00 02 00 00 ..../...........
0060 00 00 00 01 02 e1 7a 14 ae 7f 2c e1 40 00 00 00 ......z...,.@...
0070 00 00 00 00 00 01 00 f6 28 5c 8f 52 08 e2 40 00 ........(\.R..@.
0080 00 00 00 00 00 44 40 .....D@
如果订单产生了一笔或多笔交易,则这些订单将在交易事件中发送,其中包含与同一工具和订单有关的一笔或多笔交易。
这些字段的含义/用途与相应的 websocket API 事件相同。
<message name="trades" id="1002"> <field name="instrumentId" id="1" type="uint32" /> <group name="tradesList" id="2" dimensionType="groupSizeEncoding"> <field name="direction" id="1" type="direction" /> <field name="price" id="2" type="double" /> <field name="amount" id="3" type="double" /> <field name="timestampMs" id="4" type="uint64" /> <field name="markPrice" id="5" type="double" /> <field name="indexPrice" id="6" type="double" /> <field name="tradeSeq" id="7" type="uint64" /> <field name="tradeId" id="8" type="uint64" /> <field name="tickDirection" id="9" type="tickDirection" /> <field name="liquidation" id="10" type="liquidation" /> <field name="iv" id="11" type="double" presence="optional" /> <field name="blockTradeId" id="12" type="uint64" presence="optional" nullValue="0" /> <field name="comboTradeId" id="13" type="uint64" presence="optional" nullValue="0" /> </group> </message>
消息中使用的枚举类型
<enum name="tickDirection" encodingType="uint8"> <validValue name="plus">0</validValue> <validValue name="zeroplus">1</validValue> <validValue name="minus">2</validValue> <validValue name="zerominus">3</validValue> </enum> <enum name="direction" encodingType="uint8"> <validValue name="buy">0</validValue> <validValue name="sell">1</validValue> </enum> <enum name="liquidation" encodingType="uint8"> <validValue name="none">0</validValue> <validValue name="maker">1</validValue> <validValue name="taker">2</validValue> <validValue name="both">3</validValue> </enum>
事件系统将与同一笔交易相关的事件合并到一个工具上。如果这些事件放在一个数据包中,则相关的账簿、交易和股票信息将合并到一个数据包中
Frame 181: 470 bytes on wire (3760 bits), 470 bytes captured (3760 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.1
User Datagram Protocol,
Src Port: 55022,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 420
Channel Id: 1
Channel Sequence: 10477
Trades
Header
Root Block Length: 4
Type: trades (1002)
Schema Id: 1
Version: 1
Num Groups: 1
Num Vars: 0
Instrument Id: 1
Trades
Group Header
Group Block Length: 83
Num In Group: 2
Group Num Groups: 0
Group Num Vars: 0
Trade 1
Trade Direction: sell (1)
Price: 39344,25
Amount: 10
Timestamp: May 2, 2022 11:53:01.000000000 UTC
Mark Price: 38815,96
Index Price: 38603,64
Trade Sequence: 392167
Trade Id: 1297362
Tick Direction: zerominus (3)
Liquidation: no liquidation (0)
Implied Volatility: 0
Block Trade Id: 0
Combo Trade Id: 0
Trade 2
Trade Direction: sell (1)
Price: 39316,72
Amount: 10
Timestamp: May 2, 2022 11:53:01.000000000 UTC
Mark Price: 38815,96
Index Price: 38603,64
Trade Sequence: 392168
Trade Id: 1297363
Tick Direction: minus (2)
Liquidation: no liquidation (0)
Implied Volatility: 0
Block Trade Id: 0
Combo Trade Id: 0
Ticker
Header
Root Block Length: 133
Type: ticker (1003)
Schema Id: 1
Version: 1
Num Groups: 0
Num Vars: 0
Instrument Id: 1
Instrument State: open (1)
Timestamp: May 2, 2022 11:53:01.000000000 UTC
Open Interest: 60
Min Price: 38980,56
Max Price: 39375,71
Last Price: 39316,72
Index Price: 38603,64
Mark Price: 38815,96
Best Bid Price: 39316,31
Best Bid Amount: 30
Best Ask Price: 39375,72
Best Ask Amount: 10
Current Funding: 0,005
Funding 8h: 0,00751341
Estimated Delivery Price: 38603,64
Delivery Price: 0
Settlement Price: 39229,82
Book Change
Header
Root Block Length: 29
Type: book (1001)
Schema Id: 1
Version: 1
Num Groups: 1
Num Vars: 0
Instrument Id: 1
Timestamp: May 2, 2022 11:53:01.000000000 UTC
Previous Change ID: 3086708
Change ID: 3086709
Is Last Part: last (1)
Changes
Group Header
Group Block Length: 18
Num In Group: 2
Group Num Groups: 0
Group Num Vars: 0
Change List
delete bid - price : 39316,72
amount: 0
delete bid - price : 39344,25
amount: 0
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 01 c8 bd 2f 40 00 20 11 be 83 7f 00 00 01 ef 6f .../@. ......o
0020 6f 01 d6 ee 17 d4 01 b4 df 37 a4 01 01 00 ed 28 o........7.....(
0030 00 00 04 00 ea 03 01 00 01 00 01 00 00 00 01 00 ................
0040 00 00 53 00 02 00 00 00 00 00 01 00 00 00 00 08 ..S.............
0050 36 e3 40 00 00 00 00 00 00 24 40 48 e1 9d 84 80 6.@......$@H....
0060 01 00 00 85 eb 51 b8 fe f3 e2 40 ae 47 e1 7a 74 .....Q....@.G.zt
0070 d9 e2 40 e7 fb 05 00 00 00 00 00 d2 cb 13 00 00 ..@.............
0080 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 ................
0090 00 00 00 00 00 00 00 00 00 00 00 00 00 01 a4 70 ...............p
00a0 3d 0a 97 32 e3 40 00 00 00 00 00 00 24 40 48 e1 =..2.@......$@H.
00b0 9d 84 80 01 00 00 85 eb 51 b8 fe f3 e2 40 ae 47 ........Q....@.G
00c0 e1 7a 74 d9 e2 40 e8 fb 05 00 00 00 00 00 d3 cb .zt..@..........
00d0 13 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 ................
00e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00f0 85 00 eb 03 01 00 01 00 00 00 00 00 01 00 00 00 ................
0100 01 48 e1 9d 84 80 01 00 00 00 00 00 00 00 00 4e .H.............N
0110 40 b8 1e 85 eb 91 08 e3 40 85 eb 51 b8 f6 39 e3 @........@..Q..9.
0120 40 a4 70 3d 0a 97 32 e3 40 ae 47 e1 7a 74 d9 e2 @.p=..2.@.G.zt..
0130 40 85 eb 51 b8 fe f3 e2 40 b8 1e 85 eb 89 32 e3 @..Q....@.....2.
0140 40 00 00 00 00 00 00 3e 40 a4 70 3d 0a f7 39 e3 @......>@.p=..9.
0150 40 00 00 00 00 00 00 24 40 7b 14 ae 47 e1 7a 74 @......$@{..G.zt
0160 3f c2 f9 b3 a3 61 c6 7e 3f ae 47 e1 7a 74 d9 e2 ?....a.~?.G.zt..
0170 40 00 00 00 00 00 00 00 00 d7 a3 70 3d ba 27 e3 @.........p=.'.
0180 40 1d 00 e9 03 01 00 01 00 01 00 00 00 01 00 00 @...............
0190 00 48 e1 9d 84 80 01 00 00 74 19 2f 00 00 00 00 .H.......t./....
01a0 00 75 19 2f 00 00 00 00 00 01 12 00 02 00 00 00 .u./............
01b0 00 00 01 02 a4 70 3d 0a 97 32 e3 40 00 00 00 00 .....p=..2.@....
01c0 00 00 00 00 01 02 00 00 00 00 08 36 e3 40 00 00 ...........6.@..
01d0 00 00 00 00 00 00 ......
定期发送股票行情事件,以表明账面数据中未达到严格水平的变化(例如指数价格)。该事件可能与账面等级变化(例如最佳出价/卖出价变动)有关,在这种情况下,该事件将与相应的账面变更一起发送。它也可以作为独立事件发送。
股票报价消息结构也用于快照频道
注意
[en] Funding rates and related funding fields published on this multicast event are derived from the Deribit ticker.{instrument_name}.{interval} notification channel. Refer to the official Deribit documentation for more details.
<message name="ticker" id="1003"> <!-- according the the SBE spec, optional floats use the quietNaN null value 0xffffffffffffffff --> <field name="instrumentId" id="1" type="uint32" /> <field name="instrumentState" id="2" type="instrumentState" /> <field name="timestampMs" id="3" type="uint64" /> <field name="openInterest" id="4" type="double" presence="optional" /> <field name="minSellPrice" id="5" type="double" /> <field name="maxBuyPrice" id="6" type="double" /> <field name="lastPrice" id="7" type="double" presence="optional"/> <field name="indexPrice" id="8" type="double" /> <field name="markPrice" id="9" type="double" /> <field name="bestBidPrice" id="10" type="double" /> <field name="bestBidAmount" id="11" type="double" /> <field name="bestAskPrice" id="12" type="double" /> <field name="bestAskAmount" id="13" type="double" /> <field name="currentFunding" id="14" type="double" presence="optional" /> <field name="funding8h" id="15" type="double" presence="optional" /> <field name="estimatedDeliveryPrice" id="16" type="double" presence="optional"/> <field name="deliveryPrice" id="17" type="double" presence="optional" /> <field name="settlementPrice" id="18" type="double" presence="optional" /> </message>
Frame 106: 195 bytes on wire (1560 bits), 195 bytes captured (1560 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.4
User Datagram Protocol,
Src Port: 37630,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 145
Channel Id: 4
Channel Sequence: 4218
Ticker
Header
Root Block Length: 133
Type: ticker (1003)
Schema Id: 1
Version: 1
Num Groups: 0
Num Vars: 0
Instrument Id: 2
Instrument State: open (1)
Timestamp: May 3, 2022 13:17:24.827000000 UTC
Open Interest: 10
Min Price: 2837,56
Max Price: 2866,08
Last Price: 2865,61
Index Price: 2834,85
Mark Price: 2850,44
Best Bid Price: 2866,09
Best Bid Amount: 20
Best Ask Price: 2866,10
Best Ask Amount: 10
Current Funding: 0,004999
Funding 8h: -0,003006
Estimated Delivery Price: 2834,85
Delivery Price: 0
Settlement Price: 2837,27
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 b5 9e 37 40 00 20 11 de 8b 7f 00 00 01 ef 6f ...7@. ......o
0020 6f 04 92 fe 17 d4 00 a1 de 27 91 00 04 00 7a 10 o........'....z.
0030 00 00 85 00 eb 03 01 00 01 00 00 00 00 00 02 00 ................
0040 00 00 01 db 81 11 8a 80 01 00 00 00 00 00 00 00 ................
0050 00 24 40 85 eb 51 b8 1e 2b a6 40 5c 8f c2 f5 28 .$@..Q..+.@\...(
0060 64 a6 40 1f 85 eb 51 38 63 a6 40 33 33 33 33 b3 d.@...Q8c.@3333.
0070 25 a6 40 7b 14 ae 47 e1 44 a6 40 48 e1 7a 14 2e %.@{..G.D.@H.z..
0080 64 a6 40 00 00 00 00 00 00 34 40 33 33 33 33 33 d.@......4@33333
0090 64 a6 40 00 00 00 00 00 00 24 40 1c 09 34 d8 d4 d.@......$@..4..
00a0 79 74 3f 6c 07 23 f6 09 a0 68 bf 33 33 33 33 b3 yt?l.#...h.3333.
00b0 25 a6 40 00 00 00 00 00 00 00 00 d7 a3 70 3d 8a %.@..........p=.
00c0 2a a6 40 *.@
除上述事件外,订单簿的定期(默认为每隔 1 分钟)快照也是多播的。快照还按货币/产品(如事件)分组,可以分配给不同的 Deribit(多播频道)。
快照是一系列的 instrument/instrument_v2/ticker/snapshot 包含静态工具数据、账面当前状态下的股票信息、订单簿等级,以及带有上次更改时间戳的最后一次更改 ID 的消息。
使用之字形方法(bid1、ask1、bid2、ask2...)将两边的账面等级(竞价/出价)合并到一个列表中。
快照通常是完整的(即包含所有书籍关卡),但是如果它们的关卡超过 10000 个,则将限制在 10000 个以内。
为了表明快照是否完成,该消息包含一个 isComplete
标志。
如果数据包中无法容纳完整的快照,则将对级别列表进行拆分(与订单簿更改类似)。这个 isLast 标志表示消息是否包含关卡列表的一部分而下一条消息是否包含后续消息(值 = 0),或者该消息是序列中的最后一条且关卡的发送已完成,或者消息是否包含快照中发送的所有级别(值 = 1)。
如果是多个 instrument/instrument_v2/ticker/snapshot 消息序列(适用于货币/产品对上的不同工具)放入单个数据包中,它们将被合并。图书级别的快照消息可以拆分为多个数据包。
<message name="snapshot" id="1004"> <field name="instrumentId" id="1" type="uint32" /> <field name="timestampMs" id="2" type="uint64" /> <field name="changeId" id="3" type="uint64" /> <field name="isBookComplete" id="4" type="yesNo" /> <field name="isLastInBook" id="5" type="yesNo" /> <group name="levelsList" id="6" dimensionType="groupSizeEncoding"> <field name="side" id="1" type="bookSide" /> <field name="price" id="2" type="double" /> <field name="amount" id="3" type="double" /> </group> </message>
消息中使用的枚举类型
<enum name="yesNo" encodingType="uint8"> <validValue name="no">0</validValue> <validValue name="yes">1</validValue> </enum> <enum name="bookSide" encodingType="uint8"> <validValue name="ask">0</validValue> <validValue name="bid">1</validValue> </enum>
Frame 13142: 347 bytes on wire (2776 bits), 347 bytes captured (2776 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.5
User Datagram Protocol,
Src Port: 33646,
Dst Port: 6101
Deribit SBE
Framing Header
Packet Length: 297
Channel Id: 105
Channel Sequence: 95
Book Snapshot
Header
Root Block Length: 22
Type: snapshot (1004)
Schema Id: 1
Version: 1
Num Groups: 1
Num Vars: 0
Instrument Id: 486
Timestamp: May 9, 2022 14:04:23.702000000 UTC
Change ID: 4434022
Is Book Complete: complete (1)
Is Last Part: last (1)
Levels
Group Header
Group Block Length: 17
Num In Group: 15
Group Num Groups: 0
Group Num Vars: 0
Level List:
bid - price: 32030,22 amount: 10
bid - price: 32018,26 amount: 10
bid - price: 32017,43 amount: 10
bid - price: 32016,94 amount: 20
bid - price: 32013,36 amount: 10
bid - price: 32011,99 amount: 10
bid - price: 31728,66 amount: 10
bid - price: 31724,04 amount: 30
bid - price: 31712,10 amount: 10
bid - price: 31711,62 amount: 20
bid - price: 31709,33 amount: 20
bid - price: 31694,14 amount: 20
bid - price: 31684,67 amount: 10
bid - price: 31683,33 amount: 20
bid - price: 31079,33 amount: 30
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 01 4d c1 01 40 00 20 11 bb 28 7f 00 00 01 ef 6f .M..@. ..(....o
0020 6f 05 83 6e 17 d5 01 39 de c0 29 01 69 00 5f 00 o..n...9..).i._.
0030 00 00 16 00 ec 03 01 00 01 00 01 00 00 00 e6 01 ................
0040 00 00 16 ad 22 a9 80 01 00 00 66 a8 43 00 00 00 ....".....f.C...
0050 00 00 01 01 11 00 0f 00 00 00 00 00 01 48 e1 7a .............H.z
0060 14 8e 47 df 40 00 00 00 00 00 00 00 24 40 01 3d ..G.@.......$@.=
0070 0a d7 a3 90 44 df 40 00 00 00 00 00 00 00 24 40 ....D.@.......$@
0080 01 52 b8 1e 85 5b 44 df 40 00 00 00 00 00 00 24 .R...[D.@......$
0090 40 01 8f c2 f5 28 3c 44 df 40 00 00 00 00 00 00 @....(@.ffff...@.
00f0 00 00 00 00 00 00 24 40 01 e1 7a 14 ae e7 f7 de ......$@..z.....
0100 40 00 00 00 00 00 00 00 34 40 01 ec 51 b8 1e 55 @.......4@..Q..U
0110 f7 de 40 00 00 00 00 00 00 34 40 01 5c 8f c2 f5 ..@......4@.\\...
0120 88 f3 de 40 00 00 00 00 00 00 34 40 01 14 ae 47 ...@......4@...G
0130 e1 2a f1 de 40 00 00 00 00 00 00 24 40 01 ec 51 .*..@......$@..Q
0140 b8 1e d5 f0 de 40 00 00 00 00 00 00 34 40 01 ec .....@......4@..
0150 51 b8 1e d5 59 de 40 00 00 00 00 00 00 00 3e 40 Q...Y.@.......>@
快照序列示例
的目的 snapshotStart 事件是通过在接收/处理快照之前缓冲事件,向客户端表明它可以开始为即将到来的快照做准备。在发送每个快照之前不久(目前为 200 毫秒),一条类型为的消息 snapshotStart 已发送,表示可能的快照序列即将发布。
这个领域 snapshotDelay 表示延迟(以毫秒为单位)。
另一条带有类型的消息 snapshotEnd 频道的快照序列完成后立即发送
如果没有可用的快照(频道中没有活跃的图书),则只有一对 snapshotStart 和 snapshotEnd 将发送。
<message name="snapshotStart" id="1005"> <field name="snapshotDelay" id="1" type="uint32" /> </message>
Frame 1: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.10
User Datagram Protocol,
Src Port: 48141,
Dst Port: 6101
Deribit SBE
Framing Header
Packet Length: 16
Channel Id: 110
Channel Sequence: 2
Book Snapshot Start
Header
Root Block Length: 4
Type: snapshot_start (1005)
Schema Id: 1
Version: 1
Num Groups: 0
Num Vars: 0
Snapshot Delay: 200
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 b5 54 33 40 00 20 11 28 8a 7f 00 00 01 ef 6f ..T3@. .(.....o
0020 6f 0a bc 0d 17 d5 00 20 91 9c 10 00 6e 00 02 00 o...... ...n...
0030 00 00 04 00 ed 03 01 00 01 00 00 00 00 00 c8 00 ................
0040 00 00
Frame 1: 62 bytes on wire (496 bits), 62 bytes captured (496 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.10
User Datagram Protocol,
Src Port: 48141,
Dst Port: 6101
Deribit SBE
Framing Header
Packet Length: 12
Channel Id: 110
Channel Sequence: 3
Book Snapshot End
Header
Root Block Length: 0
Type: snapshot_end (1006)
Schema Id: 1
Version: 1
Num Groups: 0
Num Vars: 0
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 b5 54 33 40 00 20 11 28 8a 7f 00 00 01 ef 6f ..T3@. .(.....o
0020 6f 0a bc 0d 17 d5 00 1c 5f a5 0c 00 6e 00 03 00 o......._...n...
0030 00 00 00 00 ee 03 01 00 01 00 00 00 00 00 ..............
快照序列示例
组合段消息在组合事件和多播通道中的乐器消息之后发送,有两种情况:1) 创建组合时在事件通道中 2) 在每个快照的快照通道中。
该事件包含乐器 ID 和组合腿列表。列表中的每个组合腿都包含组合腿的乐器 ID 以及组合腿的大小 (int32)
<message name="comboLegs" id="1007"> <field name="instrumentId" id="1" type="uint32" /> <group name="legsList" id="2" dimensionType="groupSizeEncoding"> <field name="legInstrumentId" id="1" type="uint32" /> <field name="legSize" id="2" type="int32" /> </group> </message>
Frame 1865: 264 bytes on wire (2112 bits), 264 bytes captured (2112 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.14
User Datagram Protocol,
Src Port: 54658,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 214
Channel Id: 14
Channel Sequence: 0
Instrument State - Combo Legs
Header
Root Block Length: 4
Type: combo_legs (1007)
Schema Id: 1
Version: 2
Num Groups: 1
Num Vars: 0
Instrument Id: 32
Legs
Group Header
Group Block Length: 8
Num In Group: 2
Group Num Groups: 0
Group Num Vars: 0
Leg List:
leg instrument id: 1 leg size: -1
leg instrument id: 2 leg size: 1
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 fa ed e2 40 00 20 11 8e 91 7f 00 00 01 ef 6f ....@. ......o
0020 6f 0e d5 82 17 d4 00 e6 de 76 d6 00 0e 00 00 00 o........v......
0030 00 00 8c 00 e8 03 01 00 02 00 00 00 01 00 20 00 .............. .
0040 00 00 00 02 00 00 01 04 01 00 42 54 43 00 00 00 ..........BTC...
0050 00 00 55 53 44 00 00 00 00 00 55 53 44 00 00 00 ..USD.....USD...
0060 00 00 42 54 43 00 00 00 00 00 55 53 44 00 00 00 ..BTC.....USD...
0070 00 00 10 bd 10 3d 84 01 00 00 00 64 a7 41 84 01 .....=.....d.A..
0080 00 00 ff ff ff ff ff ff ff ff 00 00 00 00 00 00 ................
0090 24 40 00 00 00 00 00 00 24 40 7b 14 ae 47 e1 7a $@......$@{..G.z
00a0 84 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .?..............
00b0 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
00c0 ff ff ff ff ff ff ff ff ff ff 15 42 54 43 2d 46 ...........BTC-F
00d0 53 2d 31 31 4e 4f 56 32 32 5f 34 4e 4f 56 32 32 S-11NOV22_4NOV22
00e0 04 00 ef 03 01 00 02 00 01 00 00 00 20 00 00 00 ............ ...
00f0 08 00 02 00 00 00 00 00 01 00 00 00 ff ff ff ff ................
0100 02 00 00 00 01 00 00 00 ........
价格指数事件以货币对(例如 eth_usdc)的形式包含 16 字节的索引名称,后面是价格和时间戳。价格指数消息与任何货币/产品组无关,因此在通用多播频道 (0) 上发送
<message name="priceIndex" id="1008"> <field name="indexName" id="1" type="string16" /> <field name="price" id="2" type="double" /> <field name="timestampMs" id="3" type="uint64" /> </message>
消息中使用的其他类型:
<type name="string16" primitiveType="char" length="16" />
Frame 1228: 94 bytes on wire (752 bits), 94 bytes captured (752 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.0
User Datagram Protocol,
Src Port: 40820,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 44
Channel Id: 0
Channel Sequence: 306
Price Index
Header
Root Block Length: 32
Type: price_index (1008)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 0
Currency Pair: eth_usdc
Price: 1271,1231
Timestamp: Nov 11, 2022 10:10:45.315000000 UTC
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 50 1e 49 40 00 20 11 5e e3 7f 00 00 01 ef 6f .P.I@. .^......o
0020 6f 00 9f 74 17 d4 00 3c dd be 2c 00 00 00 32 01 o..t...<..,...2.
0030 00 00 20 00 f0 03 01 00 02 00 00 00 00 00 65 74 .. ............et
0040 68 5f 75 73 64 63 00 00 00 00 00 00 00 00 8d 28 h_usdc.........(
0050 ed 0d 7e dc 93 40 c3 9d 2b 66 84 01 00 00 ..~..@..+f....
RFQ(询价)事件包含状态(活跃或不活跃)、方面(买入、卖出或 no_direction),然后是金额和时间戳。此消息将在通用频道 ID: 0 上发送。有关其多播地址,请参阅频道文档
<message name="rfq" id="1009"> <field name="instrumentId" id="1" type="uint32" /> <field name="state" id="2" type="yesNo" /> <field name="side" id="3" type="rfqDirection" /> <field name="amount" id="4" type="double" /> <field name="timestampMs" id="5" type="uint64" /> </message>
消息中使用的枚举类型:
<enum name="yesNo" encodingType="uint8"> <validValue name="no">0</validValue> <validValue name="yes">1</validValue> </enum> <enum name="rfqDirection" encodingType="uint8"> <validValue name="buy">0</validValue> <validValue name="sell">1</validValue> <validValue name="no_direction">2</validValue> </enum>
Frame 1229: 84 bytes on wire (672 bits), 84 bytes captured (672 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.1
User Datagram Protocol,
Src Port: 37608,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 34
Channel Id: 1
Channel Sequence: 59
RFQ (Request for Quote)
Header
Root Block Length: 22
Type: rfq (1009)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 0
Instrument Id: 12
RFQ State: active (1)
RFQ Side: buy (0)
Amount: 1
Timestamp: Nov 11, 2022 10:10:46.250000000 UTC
Hex Dump:
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 46 29 55 40 00 20 11 53 e0 7f 00 00 01 ef 6f .F)U@. .S......o
0020 6f 01 92 e8 17 d4 00 32 dd b5 22 00 01 00 3b 00 o......2.."...;.
0030 00 00 16 00 f1 03 01 00 02 00 00 00 00 00 0c 00 ................
0040 00 00 01 00 00 00 00 00 00 00 f0 3f 6a a1 2b 66 ...........?j.+f
0050 84 01 00 00 ....
现货工具生成与其他工具相同的消息。账面事件和股票行情事件是针对订单簿数据的变化而生成的。现货快照包括所有现货工具的股票和账面数据
Frame 19: 117 bytes on wire (936 bits), 117 bytes captured (936 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.21
User Datagram Protocol,
Src Port: 52994,
Dst Port: 6100
Deribit SBE
Framing Header
Packet Length: 67
Channel Id: 21
Channel Sequence: 184
Book Change
Header
Root Block Length: 29
Type: book (1001)
Schema Id: 1
Version: 2
Num Groups: 1
Num Vars: 0
Instrument Id: 29
Timestamp: Mar 2, 2023 13:43:14.929000000 UTC
Previous Change ID: 80
Change ID: 86
Is Last Part: last (1)
Changes
Group Header
Group Block Length: 18
Num In Group: 1
Group Num Groups: 0
Group Num Vars: 0
Change List
new ask - price : 23308,9845
amount : 0,0002
Hex Dump:
0000 43 00 15 00 b8 00 00 00 1d 00 e9 03 01 00 02 00 C...............
0010 01 00 00 00 1d 00 00 00 f1 0c 90 a2 86 01 00 00 ................
0020 50 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 P.......V.......
0030 01 12 00 01 00 00 00 00 00 00 00 ba 49 0c 02 3f ............I..?
0040 c3 d6 40 2d 43 1c eb e2 36 2a 3f ..@-C...6*?
Frame 723: 1494 bytes on wire (11952 bits), 1494 bytes captured (11952 bits) on interface lo, id 0
Ethernet II,
Src: 00:00:00_00:00:00 (00:00:00:00:00:00),
Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4,
Src: 127.0.0.1,
Dst: 239.111.111.21
User Datagram Protocol,
Src Port: 48500,
Dst Port: 6101
Deribit SBE
Framing Header
Packet Length: 1444
Channel Id: 121
Channel Sequence: 4
Instrument State
Header
Root Block Length: 140
Type: instrument (1000)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 1
Instrument Id: 29
Instrument State: open (1)
Instrument Kind: spot (4)
Instrument Type: not applicable (0)
Option Type: not applicable (0)
RFQ: 0
Settlement Period: Unknown (255)
Settlement Period Count: 0
Base Currency: BTC
Quote Currency: USDC
Counter Currency: USDC
Settlement Currency: [empty]
Size Currency: BTC
Creation Timestamp: Mar 2, 2023 13:42:24.000000000 UTC
Expiration Timestamp: Jan 1, 3000 08:00:00.000000000 UTC
Strike Price: -nan
Contract Size: 0,0001
Minimum Trade Amount: 0,0001
Tick Size: 0,0001
Maker Commission: 0
Taker Commission: 0,0001
Block Trade Commission: -nan
Max Liquidation Commission: -nan
Max Leverage: -nan
Instrument Name: BTC_USDC
Ticker
Header
Root Block Length: 133
Type: ticker (1003)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 0
Instrument Id: 29
Instrument State: open (1)
Timestamp: Mar 2, 2023 13:43:26.970000000 UTC
Open Interest: -nan
Min Sell Price: 23226,7493
Max Buy Price: 23460,1839
Last Price: 23274,6191
Index Price: 23372,9729
Mark Price: 23296,2361
Best Bid Price: 23274,6191
Best Bid Amount: 0,0005
Best Ask Price: 23317,8531
Best Ask Amount: 0,0001
Current Funding: -nan
Funding 8h: -nan
Estimated Delivery Price: -nan
Delivery Price: -nan
Settlement Price: -nan
Book Snapshot
Header
Root Block Length: 22
Type: snapshot (1004)
Schema Id: 1
Version: 2
Num Groups: 1
Num Vars: 0
Instrument Id: 29
Timestamp: Mar 2, 2023 13:43:26.970000000 UTC
Change ID: 163
Is Book Complete: complete
Is Last Part: last (1)
Levels
Group Header
Group Block Length: 17
Num In Group: 27
Group Num Groups: 0
Group Num Vars: 0
Orderbook Levels:
ask - price: 23317,8531 amount: 0,0001
bid - price: 23274,6191 amount: 0,0005
ask - price: 23325,4224 amount: 0,0001
bid - price: 23267,3293 amount: 0,0003
ask - price: 23327,1627 amount: 0,0004
ask - price: 23332,8221 amount: 0,0002
ask - price: 23343,9179 amount: 0,0006
ask - price: 23355,7196 amount: 0,0007
ask - price: 23355,7235 amount: 0,0004
ask - price: 23360,0454 amount: 0,0004
ask - price: 23363,7177 amount: 0,0006
ask - price: 23370,4559 amount: 0,0007
ask - price: 23371,5373 amount: 0,0001
ask - price: 23374,1273 amount: 0,0002
ask - price: 23383,1583 amount: 0,0002
ask - price: 23386,2295 amount: 0,0001
ask - price: 23392,8084 amount: 0,0004
ask - price: 23392,8220 amount: 0,0002
ask - price: 23409,2294 amount: 0,0004
ask - price: 23410,6344 amount: 0,0001
ask - price: 23417,4490 amount: 0,0003
ask - price: 23419,4629 amount: 0,0008
ask - price: 23436,5183 amount: 0,0001
ask - price: 23436,5464 amount: 0,0008
ask - price: 23437,9561 amount: 0,0001
ask - price: 23438,0801 amount: 0,0002
ask - price: 23438,2290 amount: 0,0003
Instrument
State Header
Root Block Length: 140
Type: instrument (1000)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 1
Instrument Id: 30
Instrument State: open (1)
Instrument Kind: spot (4)
Instrument Type: not applicable (0)
Option Type: not applicable (0)
RFQ: 0
Settlement Period: Unknown (255)
Settlement Period Count: 0
Base Currency: ETH
Quote Currency: USDC
Counter Currency: USDC
Settlement Currency: –
Size Currency: ETH
Creation Timestamp: Mar 2, 2023 13:42:24.000000000 UTC
Expiration Timestamp: Jan 1, 3000 08:00:00.000000000 UTC
Strike Price: -nan
Contract Size: 0,0001
Minimum Trade Amount: 0,0001
Tick Size: 0,0001
Maker Commission: 0
Taker Commission: 0,0001
Block Trade Commission: -nan
Max Liquidation Commission: -nan
Max Leverage: -nan
Instrument Name: ETH_USDC
Ticker
Header
Root Block Length: 133
Type: ticker (1003)
Schema Id: 1
Version: 2
Num Groups: 0
Num Vars: 0
Instrument Id: 30
Instrument State: open (1)
Timestamp: Mar 2, 2023 13:43:26.973000000 UTC
Open Interest: -nan
Min Sell Price: 1624,8012
Max Buy Price: 1641,1309
Last Price: 1628,9218
Index Price: 1634,1202
Mark Price: 1629,0167
Best Bid Price: 0
Best Bid Amount: 0
Best Ask Price: 1624,9995
Best Ask Amount: 0,0025
Current Funding: -nan
Funding 8h: -nan
Estimated Delivery Price: -nan
Delivery Price: -nan
Settlement Price: -nan
Book Snapshot
Header
Root Block Length: 22
Type: snapshot (1004)
Schema Id: 1
Version: 2
Num Groups: 1
Num Vars: 0
Instrument Id: 30
Timestamp: Mar 2, 2023 13:43:26.973000000 UTC
Change ID: 162
Is Book Complete: complete (1)
Is Last Part: more to come (0)
Levels
Group Header
Group Block Length: 17
Num In Group: 17
Group Num Groups: 0
Group Num Vars: 0
Orderbook Levels (asks):
ask - price: 1624,9995 amount: 0,0025
ask - price: 1630,9028 amount: 0,0104
ask - price: 1630,9219 amount: 0,0098
ask - price: 1631,4677 amount: 0,0012
ask - price: 1632,6882 amount: 0,0043
ask - price: 1634,0983 amount: 0,0052
ask - price: 1634,7069 amount: 0,0061
ask - price: 1635,2764 amount: 0,0098
ask - price: 1635,3288 amount: 0,0098
ask - price: 1635,5830 amount: 0,0006
ask - price: 1635,9182 amount: 0,0012
ask - price: 1637,3179 amount: 0,0055
ask - price: 1637,4283 amount: 0,0043
ask - price: 1637,6410 amount: 0,0061
ask - price: 1637,8371 amount: 0,0061
ask - price: 1638,5149 amount: 0,0117
ask - price: 1639,1852 amount: 0,0043
Hex Dump:
0000 a4 05 79 00 04 00 00 00 8c 00 e8 03 01 00 02 00
0010 00 00 01 00 1d 00 00 00 01 04 00 00 00 ff 00 00
0020 42 54 43 00 00 00 00 00 55 53 44 43 00 00 00 00
0030 55 53 44 43 00 00 00 00 00 00 00 00 00 00 00 00
0040 42 54 43 00 00 00 00 00 00 46 8f a2 86 01 00 00
0050 00 54 04 dc 8f 1d 00 00 ff ff ff ff ff ff ff ff
0060 2d 43 1c eb e2 36 1a 3f 2d 43 1c eb e2 36 1a 3f
0070 2d 43 1c eb e2 36 1a 3f 00 00 00 00 00 00 00 00
0080 2d 43 1c eb e2 36 1a 3f ff ff ff ff ff ff ff ff
0090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
00a0 08 42 54 43 5f 55 53 44 43 85 00 eb 03 01 00 02
00b0 00 00 00 00 00 1d 00 00 00 01 fa 3b 90 a2 86 01
00c0 00 00 ff ff ff ff ff ff ff ff b9 fc 87 f4 af ae
00d0 d6 40 6f 81 04 c5 0b e9 d6 40 3d 9b 55 9f a7 ba
00e0 d6 40 92 5c fe 43 3e d3 d6 40 a5 2c 43 1c 0f c0
00f0 d6 40 3d 9b 55 9f a7 ba d6 40 fc a9 f1 d2 4d 62
0100 40 3f 0e be 30 99 76 c5 d6 40 2d 43 1c eb e2 36
0110 1a 3f ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0120 ff ff 92 5c fe 43 3e d3 d6 40 ff ff ff ff ff ff
0130 ff ff ff ff ff ff ff ff ff ff 16 00 ec 03 01 00
0140 02 00 01 00 00 00 1d 00 00 00 fa 3b 90 a2 86 01
0150 00 00 a3 00 00 00 00 00 00 00 01 01 11 00 1b 00
0160 00 00 00 00 00 0e be 30 99 76 c5 d6 40 2d 43 1c
0170 eb e2 36 1a 3f 01 3d 9b 55 9f a7 ba d6 40 fc a9
0180 f1 d2 4d 62 40 3f 00 75 02 9a 08 5b c7 d6 40 2d
0190 43 1c eb e2 36 1a 3f 01 a5 4e 40 13 d5 b8 d6 40
01a0 61 32 55 30 2a a9 33 3f 00 c4 42 ad 69 ca c7 d6
01b0 40 2d 43 1c eb e2 36 3a 3f 00 83 51 49 9d 34 c9
01c0 d6 40 2d 43 1c eb e2 36 2a 3f 00 40 a4 df be fa
01d0 cb d6 40 61 32 55 30 2a a9 43 3f 00 8d 28 ed 0d
01e0 ee ce d6 40 c7 ba b8 8d 06 f0 46 3f 00 aa f1 d2
01f0 4d ee ce d6 40 2d 43 1c eb e2 36 3a 3f 00 cf 66
0200 d5 e7 02 d0 d6 40 2d 43 1c eb e2 36 3a 3f 00 16
0210 fb cb ee ed d0 d6 40 61 32 55 30 2a a9 43 3f 00
0220 90 31 77 2d 9d d2 d6 40 c7 ba b8 8d 06 f0 46 3f
0230 00 09 8a 1f 63 e2 d2 d6 40 2d 43 1c eb e2 36 1a
0240 3f 00 32 e6 ae 25 88 d3 d6 40 2d 43 1c eb e2 36
0250 2a 3f 00 bd 52 96 21 ca d5 d6 40 2d 43 1c eb e2
0260 36 2a 3f 00 9c c4 20 b0 8e d6 d6 40 2d 43 1c eb
0270 e2 36 1a 3f 00 86 5a d3 bc 33 d8 d6 40 2d 43 1c
0280 eb e2 36 3a 3f 00 54 e3 a5 9b 34 d8 d6 40 2d 43
0290 1c eb e2 36 2a 3f 00 6d 56 7d ae 4e dc d6 40 2d
02a0 43 1c eb e2 36 3a 3f 00 25 75 02 9a a8 dc d6 40
02b0 2d 43 1c eb e2 36 1a 3f 00 fa 7e 6a bc 5c de d6
02c0 40 61 32 55 30 2a a9 33 3f 00 54 52 27 a0 dd de
02d0 d6 40 2d 43 1c eb e2 36 4a 3f 00 61 c3 d3 2b 21
02e0 e3 d6 40 2d 43 1c eb e2 36 1a 3f 00 a2 b4 37 f8
02f0 22 e3 d6 40 2d 43 1c eb e2 36 4a 3f 00 ed 0d be
0300 30 7d e3 d6 40 2d 43 1c eb e2 36 1a 3f 00 1a c0
0310 5b 20 85 e3 d6 40 2d 43 1c eb e2 36 2a 3f 00 b2
0320 9d ef a7 8e e3 d6 40 61 32 55 30 2a a9 33 3f 8c
0330 00 e8 03 01 00 02 00 00 00 01 00 1e 00 00 00 01
0340 04 00 00 00 ff 00 00 45 54 48 00 00 00 00 00 55
0350 53 44 43 00 00 00 00 00 55 53 44 43 00 00 00 00
0360 00 00 00 00 00 00 00 00 45 54 48 00 00 00 00 00
0370 46 8f a2 86 01 00 00 00 54 04 dc 8f 1d 00 00 ff
0380 ff ff ff ff ff ff ff 2d 43 1c eb e2 36 1a 3f 2d
0390 43 1c eb e2 36 1a 3f 2d 43 1c eb e2 36 1a 3f ff
03a0 ff ff ff ff ff ff ff ff 2d 43 1c eb e2 36 1a 3f
03b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
03c0 ff ff ff ff ff ff ff ff 08 45 54 48 5f 55 53 44
03d0 85 00 eb 03 01 00 02 00 00 00 00 00 1e 00 00 00
03e0 01 fd 3b 90 a2 86 01 00 00 ff ff ff ff ff ff ff
03f0 ff 39 d6 c5 6d 34 63 99 40 30 4c a6 0a 86 a4 99
0400 40 d0 d5 56 ec af 73 99 40 eb 73 b5 15 7b 88 99
0410 40 5f 07 ce 19 11 74 99 40 00 00 00 00 00 00 00
0420 00 00 00 00 00 00 00 00 00 68 91 ed 7c ff 63 99
0430 40 7b 14 ae 47 e1 7a 64 3f ff ff ff ff ff ff ff
0440 ff ff ff ff ff ff ff ff ff eb 73 b5 15 7b 88 99
0450 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0460 16 00 ec 03 01 00 02 00 01 00 00 00 1e 00 00 00
0470 fd 3b 90 a2 86 01 00 00 a2 00 00 00 00 00 00 00
0480 00 01 00 11 00 11 00 00 00 00 00 00 68 91 ed 7c
0490 ff 63 99 40 7b 14 ae 47 e1 7a 64 3f 00 51 6b 9a
04a0 77 9c 7b 99 40 94 f6 06 5f 98 4c 85 3f 00 bb b8
04b0 8d 06 b0 7b 99 40 6e a3 01 bc 05 12 84 3f 00 5b
04c0 b1 bf ec de 7d 99 40 61 32 55 30 2a a9 53 3f 00
04d0 6e 34 80 b7 c0 82 99 40 22 fd f6 75 e0 9c 71 3f
04e0 00 ca 54 c1 a8 64 88 99 40 94 f6 06 5f 98 4c 75
04f0 3f 00 2b f6 97 dd d3 8a 99 40 07 f0 16 48 50 fc
0500 78 3f 00 75 02 9a 08 1b 8d 99 40 6e a3 01 bc 05
0510 12 84 3f 00 b3 7b f2 b0 50 8d 99 40 6e a3 01 bc
0520 05 12 84 3f 00 46 b6 f3 fd 54 8e 99 40 61 32 55
0530 30 2a a9 43 3f 00 c0 ec 9e 3c ac 8f 99 40 61 32
0540 55 30 2a a9 53 3f 00 98 dd 93 87 45 95 99 40 ba
0550 49 0c 02 2b 87 76 3f 00 82 73 46 94 b6 95 99 40
0560 22 fd f6 75 e0 9c 71 3f 00 f2 d2 4d 62 90 96 99
0570 40 07 f0 16 48 50 fc 78 3f 00 ed 0d be 30 59 97
0580 99 40 07 f0 16 48 50 fc 78 3f 00 d7 12 f2 41 0f
0590 9a 99 40 67 d5 e7 6a 2b f6 87 3f 00 e0 9c 11 a5
05a0 bd 9c 99 40 22 fd f6 75 e0 9c 71 3f
当客户端启动时,它应该开始监听多播事件并将收到的消息排入队列,以确保在按照以下步骤构建初始数据时不会错过更改。
-
使用新的 API 调用检索所有打开乐器的当前完整乐器词典
multicast/get_instrument_dictionary调用的结果是仪器 ID 和仪器名称之间的映射
例如:
{"jsonrpc":"2.0","result":{"ETH-PERPETUAL":2,"BTC-PERPETUAL":3,"BTC-15APR22": 4}}也可以使用 public/get_instruments 调用从常规 API 中检索给定货币/产品的映射。
仪器数据现在包含数字仪器 ID。客户可以使用它来构建仪器 ID/名称
-
使用检索每种工具的订单簿的状态
public/get_order_book(或public/get_order_book_by_instrument_id) API 调用。
根据检索到的账簿和收到的多播事件中的更改 ID,应用最终错过的订单簿更改。
客户还可以根据常规快照创建书籍的初始状态。查看快照消息(仪器/仪器_v2/股票/快照)的详细信息
使用快照时,仍建议对更改进行排队,因为更改可能会在平台构建/发送快照时发生。从排队的图书级别更改来看,如果有任何变更ID高于快照中显示的更改,则应应用这些
显然,快照更改 ID 之前的更改无关紧要,应将其丢弃。为了处理仅收集到的更改 ID 高于快照(或者 API 调用结果)的事件(不太可能)的极端情况,还应根据图书快照的更改 ID 对事件的上一次更改 ID 进行验证。
由于快照包含仪器 ID 和仪器名称,以及其他静态仪器数据,因此可能无需从 API 检索字典。
注意
请注意,虽然 multicast/get_instrument_dictionary API调用仅包含活跃工具的列表,快照流包括已关闭/结算的工具,直到它们存档(通常在一天之后)。
当在快照批次中间(即加入时立即收到的数据包)加入快照通道时,建议忽略这些信道并等待下一批处理,以确保接收/处理包含该通道上所有乐器的完整快照批次。
当向系统中添加新仪器时, instrument 生成的事件(见上文),其中包含新仪器的 ID 和名称。这本新书也将成为快照的一部分。
当工具关闭/结算时,还有 instrument 生成的事件可供客户用来停止维护图书。
客户端可以根据序列号的跳跃来检测丢失的数据包。请注意,序列号是一个 32 位整数,在达到其最大值 (2^32-1) 后它将滚动到 0,客户端应该能够将其识别为正常序列,而不是将其视为
序列号也可以在系统维护后重置为 0,这可能需要客户端重建其初始数据(例如,如上所述)。
当客户端检测到丢失的数据包时,它可以使用检索它们 multicast/get_packets 打电话。通话的参数
|
频道_id |
丢失数据包的多播信道的整数 ID |
|---|---|
|
开始 |
起始序列号 |
|
结束 |
结束序列号 |
响应包含请求的数据包列表,不包括采用 base64 编码的二进制格式的帧标头(仅限 SBE 消息),其解码方式与多播数据包相同(在 base64 解码之后)。
此调用,可以在信道上请求最多 1000 个连续数据包。该呼叫的速率限制为 1 个请求/秒,突发请求量为 3 个请求/秒。如果信道上一次丢失的数据包超过 1000 个,则最好使用 4.A 和 4.B 中描述的任一客户端启动机制进行全信道恢复,而不是尝试使用此 API 进行恢复
请求
api/v2/multicast/get_packets?channel_id=15&end=2&start=1
回应
{
"jsonrpc": "2.0",
"result": [
{
"seq": 1,
"packet": "6QMBAAEAGQABAAAAAQAAABuxRACAAQAAAAAAAAAAAAAFAAAAAAAAAAESAAEAAAAAAAAAzczMzBxy5kAAAAAAAAAkQOsDAQABACgAAAAAAAEAAAAbsUQAgAEAAAAAAAAAAAAAAAAAAAAAAADNzMzMHHLmQAAAAAAAACRA"
},
{
"seq": 2,
"packet": "6QMBAAEAGQABAAAAAQAAAIWxRACAAQAABQAAAAAAAAAHAAAAAAAAAAESAAEAAAAAAAEA7FG4Hr185UAAAAAAAAA0QOsDAQABACgAAAAAAAEAAACFsUQAgAEAAOxRuB69fOVAAAAAAAAANEDNzMzMHHLmQAAAAAAAACRA"
}
],
"usIn": 1649273556304472,
"usOut": 1649273556304731,
"usDiff": 259,
"testnet": false
}
在本文档旁边,提供了以下文件以帮助客户开发。
这些数据取自开发测试设置,可用作使用 Wireshark(使用我们创建的插件)检查或使用 tcpreplay 等工具重播数据包的参考。
单独提供了包含新信息的其他跟踪,例如应用于以下用途的新消息
tcpreplay 可在大多数 linux 发行版上作为软件包使用。安装后,可以重放 pcap 文件,例如
sudo tcpreplay -p 1 -i lo sample_capture_v1_6.pcapng
使用此命令,捕获文件中的数据包将在本地(环路)接口上以每秒 1 个数据包的速度重放。
请注意,tcpreplay 只能将数据包重播到网络。虽然本地重播是可见的,例如在主机本身上使用 tcpdump,但实际上无法通过应用程序接收它们。为了将其与测试客户端一起使用,需要为 tcpreplay 提供一个真正的物理接口,并且该客户端需要在连接到同一网络的另一台主机上运行
|
sample_capture_v1_6.pcapng |
多播快照和消息示例 |
一个 LUA wireshark 解析器插件 deribit_sbe.lua 已创建允许Wireshark数据包捕获/分析工具显示多播数据包的内容。
该分析器已在 linux(ubuntu 20.04)上使用 Wireshark 版本 3.4.8 进行了测试。
要将解析器添加到 Wireshark,请将文件复制到的目录中 '个人 LUA 插件' 或者 '全球 LUA 插件' 可以在 Wireshark 下找到 '帮助'-> '关于Wireshark'-> “文件夹”。
可以通过单击 “” 来验证插件的加载 '插件' 选项卡在同一个窗口中。
该插件会自动分配给 UDP 端口 6100 和 6101,但是,如果需要在其他端口(例如测试流)上进行解码,则应在中明确分配它们
wireshark。
加载插件后,数据包未被解码 右键单击任何数据包 然后选择 '解码为... ' 从快捷菜单中。在对话框中,选择数据包的 UDP 目标端口号并分配 'DERIBIT SBE' 解码器。
LUA 文件也可以用作理解消息解码的示例。
可用于代码生成(需要安装 Java)的工具由 Real Logic 创建。它只是为了方便起见而捆绑销售,我们不支持
对于任何疑问或问题(与 XML 定义的最终问题无关),项目 github 存储库是最好的资源(https://github.com/real-logic/simple-binary-encoding)。也可以在那里找到该工具的更新版本。它可以根据不同编程语言(c、c++、java、go、rust)的 XML 规范生成库代码。该工具是根据Apache 2.0许可开源的。
请注意,提供 XML 定义仅用于帮助客户开发,不在平台中使用(也未经过广泛测试),因此欢迎对 XML 中发现的任何问题提供反馈。
示例命令以脚本形式提供(例如 generate_c.sh) 作为生成库的示例。
|
日期 |
版本 |
摘要 |
|---|---|---|
|
2022年4月6日 |
1.1 |
首次发布 |
|
2022年4月11日 |
1.2 |
更改邮件标题结构(blockLength 移至标题顶部)。 添加新的 API 调用以检索乐器词典。使用类型和示例消息改进消息描述。 更新了 XML 规范、样本跟踪和 LUA 解析器 |
|
2022年4月13日 |
1.3 |
修复 XML 规范中的 instrumentID 字段,更新生成的代码库 |
|
2022年5月2日 |
1.4 |
|
|
2022年5月13日 |
1.4.1 |
-修复仪器消息样本的根块长度并提供新的样本跟踪 |
|
2022年5月23日 |
1.4.2 |
|
|
2022年6月9日 |
1.4.3 |
|
|
2022年7月12日 |
1.5 |
|
|
2022 年 10 月 14 日 |
1.5.1 |
-添加了新的消息类型 SnapshotStart 和 SnapshotEnd |
|
2022 年 11 月 3 日 |
1.5.2 |
-添加了新的消息类型 comboLegs |
|
2022 年 11 月 11 日 |
1.5.3 |
-添加了新的消息类型 priceIndex 和 rfq |
|
2023 年 1 月 31 日 |
1.5.4 |
-更正了 rfq 中使用的枚举 |
|
2023 年 3 月 6 日 |
1.5.5 |
-增加了景点 |
|
2023 年 4 月 6 日 |
1.5.6 |
-将所有对 “未来类型” 的引用重命名为 “仪器类型” |
|
2023 年 4 月 27 日 |
1.5.7 |
-在订单簿更改中添加有关空白变更清单的说明 |
|
2023 年 5 月 22 日 |
1.5.8 |
|
|
2023 年 6 月 15 日 |
1.6 |
|
|
2023 年 7 月 20 日 |
1.6.1 |
|
|
2023 年 12 月 2 日 |
1.6.2 |
-仅在新 USDT 渠道的开发包中更新测试和产品渠道分配文档(本文档无变化,仅更新版本号) |