Downloads
SBE XMLs
Schema definitions for SBE market data and order entry
Starbase SDK
Client SDK for integrating with Starbase
Market Data PCAP
Sample packet capture for market data
What is SBE?
SBE is a compact binary encoding format with fixed-width fields at fixed offsets, in contrast to standard FIX with ASCII-encoded human-readable tag=value pairs. SBE provides:- Minimizes latency: Binary encoding eliminates text parsing overhead
- Reduces bandwidth: Compact binary representation uses less network bandwidth than text-based protocols
- Provides type safety: Strong typing ensures data integrity
- Fixed offsets: Fields are at fixed positions within each message
Message Structure
TCP messages
All SBE messages sent over TCP follow a consistent structure:- Message Header (32 bytes): Contains protocol identification, message type, sequence numbers, and timing information
- Message Body: Contains the specific message data fields
UDP messages
Incremental, snapshot and retransmit channels share the same basic packet and message structure. Each UDP packet will start with a packet header followed by zero or more messages. Each message within the packet will start with a message header. All messages have a sequence number, although only the sequence number of the first message in the packet is specified (in the packet header). Thus the next expected sequence number in the next packet is packet sequenceNum plus messageCount.Heartbeat packets will have a messageCount of 0 with the next expected sequence number. This same sequence number will be repeated with the first real message. Each UDP packet starts with the following 24-byte packet header:
Each message within a packet starts with the following 16-byte header:
Key Concepts
Message Type ID: Each message type has a uniquemessageTypeId (uint16) that identifies its purpose. The messageTypeId is located in field 4 of the message header and is used to determine how to parse and process the message body.
For example, a NewOrderRequest message has messageTypeId = 100. When the gateway receives a message with messageTypeId = 100 in the header, it knows to parse the message body as a NewOrderRequest containing fields such as clientOrderId, correlationId, limitPrice, amount, etc.
Message Types: Each message type has a unique messageTypeId that identifies its purpose (e.g., NewOrderRequest (100), NewOrderResponse (200), OrderFilled (300)).
Sequence Numbers: Sequence numbers are assigned and validated like FIX sequence numbers. Every message includes sequence numbers for:
- sequenceNum: Sequence number of the current message
- lastProcessedSeqNum: Sequence number of the last message received from the client (in responses)
- Message ordering verification
- Gap detection for missing messages
- Resend requests when gaps are detected (using the resend flag in the message header)
OrderFilled) contain an 8-byte integer correlationId. Clients can assign any value to correlationId, which is not validated by the server. However, Deribit recommends monotonically increasing the value. correlationId is used for matching responses to requests and for indirectly correlated messages, such as order fill and system cancel notifications. Messages from server to client use the correlationId of either the corresponding request message from the client or of the last related request. Market data messages (order book updates, trades, reference data) do not contain correlation IDs.
Protocol ID: All messages start with protocolId = 0xDB to identify the Deribit Starbase protocol.
Data Types
All multi-byte fields are encoded in little-endian byte order. SBE uses standard binary data types:- int8/int16/int32/int64: Signed integers of various sizes
- uint8/uint16: Unsigned integers
- double: 64-bit floating point (used for prices)
- char: Fixed-length character arrays
- Decimal72 (also referred to as DFP, or Decimal Floating Point): A 9-byte variable-precision quantity encoding defined as an SBE composite of a 64-bit signed integer mantissa and an 8-bit signed integer exponent, where
value = mantissa × 10^exponent. The variable exponent provides a wide range of precision across different underlying assets. It is used for quantities throughout the protocol. - QuantityMantissa: A 64-bit signed integer (int64) representing the mantissa component of a Decimal72 quantity. Used in market data messages where only the mantissa is transmitted (8 bytes).
Byte Alignment and Message Padding
The frame length of all outbound messages to the client is rounded up to the nearest multiple of 8. Clients are encouraged to do the same with inbound messages, although this is not required.Usage Workflow
- Connect: Establish a TCP connection to the gateway
- Authenticate: Authenticate using your API credentials
- Send Requests: Send binary-encoded request messages
- Receive Responses: Process binary-encoded response and update messages
- Handle Sequence: Monitor sequence numbers and request resends if gaps are detected
Order Expiration
When an order expires (e.g., a day order at the close of a trading day or when an instrument expires), anOrderCanceled message is sent via the unsolicited events channel.
Fill Limits: The maximum number of fills on a single order or mass quote is 2000 fills for single-leg instruments and 400 fills for combo instruments.
Rejection Reason Codes
Reject messages in the Starbase Binary API include areason field that indicates why the request was rejected. The following table lists all possible rejection reason codes:
These rejection reason codes are used in the following reject messages:
NewOrderReject- Field 7 (reason)AmendOrderReject- Field 7 (reason)MassQuoteResponse- Fields 20 (bidRejectReason) and 21 (askRejectReason)
CancelOrderReject and MassCancelReject use separate enumeration types with their own reason codes, documented inline in their respective message tables.Cancel Reason Codes
ThecancelReason field uses a single enumeration across all contexts, indicating why an order was (partially) canceled.
Used in:
NewOrderResponse, Field 14 (cancelReason)AmendOrderResponse, Field 13 (cancelReason)OrderPlaced,cancelReasonfieldOrdersCanceled, Field 3 (cancelReason)MassQuoteOrdersPlaced,cancelReasonfield (per quote entry)