Schemas
Every SBE message starts with the standard SBE
messageHeader (blockLength:uint16, templateId:uint16, schemaId:uint16, version:uint16). Use schemaId and templateId to select the decoder. On the wire, each SBE message is carried inside a TCP frame that adds a framing header in front of the SBE messageHeader — see Framing.
Compatibility rule: new optional or versioned fields require a schema version increase. Existing field and template IDs are never reused or reordered.
Breaking change from market data schema 34. Schema 36 removes static reference data from the instrument definition messages, changes the layout of both definition messages and replaces the template 11 and 12 layouts. Schema 34 codecs cannot decode schema 36. Regenerate your codecs from schema 36 together with session schema 33 version 5.
Connections
The session uses two connections. EachcompId allows one active live connection and one active snapshot connection.
- Snapshot connection — send a
SubscriptionRequestwithsubscriptionRequestType=Snapshotto receive one snapshot (instrument definitions, order book, instrument summaries or, on Spot and Futures only, trading session status). - Live connection — send
SubscribeorUnsubscribeto start or stop incremental delivery for a feed.
MarketDataFeed: InstrumentDefinition, OrderBookL3, Trade, InstrumentStatus, Summary and TradingSessionStatus.
TradingSessionStatus applies to Spot and Futures, not to US Perps. US Perps does not expose a global trading session status. It provides the status per instrument: use the InstrumentStatus feed, and the status carried by each InstrumentDefinition.Framing
Each TCP frame carries exactly one SBE message, in both directions. TLS protects the TCP stream but does not change the frame bytes.
The first six bytes are the Simple Open Framing Header (SOFH). The eight-byte Kraken TCP header is a Kraken extension to the usual SOFH and SBE layout: a generic SOFH reader must skip those eight bytes before decoding the SBE
messageHeader.
SendingTimeis diagnostic only. The gateway stamps a shared market data frame once, when it enters the shared fanout, so every client sees the same time for that frame. It is not a kernel transmit timestamp, and it must not be used for authentication or replay checks.- Reading frames. TCP may split one frame across several reads or return several frames in one read. Read the full SOFH, check its fields, then wait until
messageLengthbytes have arrived. - Protocol errors. An unsupported
encodingType, amessageLengthbelow 22 (the minimum frame size), or amessageLengthabove the service limit is a protocol error. Kraken closes the connection instead of skipping the frame. - Repeating groups. Before reading a group, verify that its block length and entry count fit inside the enclosing frame. Check the size arithmetic for overflow.
Frame counting
Frame counting is implicit: there is no sequence number on the wire for session control.- Each direction has its own counter. Both start at 1 on a new connection, never wrap, and have no daily reset.
- A sender advances its counter after it successfully sends a complete frame. A receiver advances its counter after it validates the complete SOFH and SBE frame.
- Every frame counts, including negotiation, subscription, heartbeat, termination and market data messages. Zero means no frame has been received.
AdminHeartbeat.lastReceivedClientSequencereports the latest client frame Kraken accepted, andSubscriberHeartbeat.lastReceivedServerSequencereports the latest server frame the client processed.- An acknowledgement greater than the number of frames its peer has sent is a protocol violation. A lower value is allowed while frames are in flight or waiting to be processed; persistent lag is handled by the service’s slow consumer limits.
- Heartbeat acknowledgements never request a replay. After a broken connection, start a new session and request a fresh snapshot.
Session schema (ID 33)
Enumerations and encodings: Session enums & encodings.
Market data schema (ID 36)
Enumerations and encodings: Market data enums & encodings.
Instrument definitions
The instrument definition messages carry an instrument’s trading parameters (scales, tick size, quantity increment, maximum trade volume, price controls and status) and itssymbol. They do not carry contractMultiplier, currency, underlyingSymbol, description, productType, marketSector or maturityType.
symbol is at most 128 UTF-8 bytes, not 128 characters, so you can resolve an instrumentId to a symbol from SBE alone. For an instrumentId you do not know, recover the definition from an InstrumentDefinitionSnapshot. Do not infer a mapping.
Order entry checks a price against tickSize: a price that is not a multiple of it is rejected with a session Reject (35=3). Order quantities are whole numbers of Min Tradable Contracts, each a fraction of a contract, and an order that is not is rejected the same way. See New Order Single and Reject (Session).
Price controls
minPrice, maxPrice and variation are optional absolute prices in the instrument currency, each with its own exponent (OptionalPrice). They are not percentages and are not scaled by priceScale. Exponent 127 means unavailable, and the mantissa must then be ignored. Zero is a valid value, including a variation of zero.
minPrice and maxPrice are inclusive static bounds. variation is a non-negative offset around the reference the matching engine selects for an aggressive limit order. Market-order protection is separate and is not represented by variation. A change to these values is published as a full-replacement InstrumentDefinitionIncremental.
Instrument summaries
TheSummary feed carries one summary per instrument. Each SummarySnapshot and SummaryIncremental is the complete current summary for that instrument. Currently it holds referencePrice, the external reference price accepted by the matching engine, and referencePriceTime, the producer timestamp of that value or of its clear. Mark price, volume and turnover are not defined.
Every update replaces the whole summary. A null referencePrice (exponent 127) clears the value, it does not mean unchanged, and zero is a real price. A referencePriceTime of zero means the source timestamp is unavailable.
summarySeq is contiguous per instrument, starts at one, is shared by all summary metrics and continues across reconnects and restarts. To join the feed:
- Subscribe to
Summaryon the live connection and buffer the updates. - Request the
Summarysnapshot on the snapshot connection. - Discard buffered updates with
summarySeqat or below the snapshot’slastSummarySeqProcessed, then apply later updates in contiguous order.
lastSummarySeqProcessed of zero means no summary update has been published: the reference price is null and its time is zero. A gap requires a new summary snapshot. A snapshot response has one message per instrument, numbered 1 through totalSummaries with summaryNumber, and is complete when every number has arrived. An instrument without a price is still a row, with a null referencePrice.
Sequencing
Incremental feeds carry contiguous per-instrument (or per-feed) sequence numbers starting at one —orderBookSeq, tradeSeq, instrumentStatusSeq, instrumentDefinitionSeq, summarySeq and tradingSessionSeq. Snapshots carry the last sequence number they include (for example lastOrderBookSeqProcessed), so you can apply buffered incrementals with a higher sequence number on top of the snapshot.
Gap recovery
There is no message replay. When you detect a gap, request a new snapshot on the snapshot connection and rebuild from it:There is no trade snapshot. A gap in
tradeSeq can be detected, but trades missed during the gap, or while you were disconnected, cannot be recovered from a book snapshot or any other feed.Related
US Perps API overview
How order entry, market data and drop copy fit together.
Unified FIX v2
FIX 4.4 order entry for US Perps.
Drop Copy
FIX 4.4 copy of every execution report on your account.
US Perps connectivity
Connectivity and colocation documents.