| Both sides previous revision Previous revision Next revision | Previous revision |
| developers:apiv2:markets [2026/09/07 17:57] – [Market Data] chad | developers:apiv2:markets [2026/09/07 18:16] (current) – [What you receive] chad |
|---|
| [[developers:apiv2|◀ WebSocket API (V2)]] | [[developers:apiv2|◀ WebSocket API (V2)]] |
| |
| Send a ''[[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L9|MarketSubscribe]]'' message in order to subscribe for market data. You may have multiple active market subscriptions (up to the subscription limit set for your user.) | Send a [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L9|MarketSubscribe]] message in order to subscribe for market data. You may have multiple active market subscriptions (up to the subscription limit set for your user.) |
| |
| | Feed | Description | | ^ Feed ^ Description ^ |
| | Depth of Market (Top of Book) | Provides the best bid and best offer. | | | **Depth of Market (Top of Book)** | Provides the best bid and best offer. | |
| | Depth of Market (Full Order Book) | Provides the 10 best bids and offers in the market. | | | **Depth of Market (Full Order Book)** | Provides the 10 best bids and offers in the market. | |
| | Market by Order (CME Only) | Provides the complete order book, including order id's and position in queue information. | | | **Market by Order (CME Only)** | Provides the complete order book, including order id's and position in queue information. | |
| | Ticker | Provides a ticker of every trade in the market. | | | **Ticker** | Provides a ticker of every trade in the market. | |
| |
| Note: Trade ticker includes order id's when subscribed for MBO. | Note: Trade ticker includes order id's when subscribed for MBO. |
| |
| |
| ===== Finding market ids ===== | ===== Identifying a Market ===== |
| |
| Subscriptions are keyed by ''exchange_id'', ''contract_id'' and ''market_id'' (all strings). Retrieve them from the REST [[developers:markets|Instruments API]] (Swagger: ''https://api-sim.t4login.com/markets/swagger/index.html''). A ''MarketDetails'' message with the full instrument definition is also delivered on subscribe. | Subscriptions are keyed by ''exchange_id'', ''contract_id'' and ''market_id''. Retrieve them from the REST-based [[developers:markets|Instruments API]] |
| |
| ===== Subscribe ===== | ===== Subscribe ===== |
| <code> | <code> |
| market_subscribe { | market_subscribe { |
| exchange_id: "CME" | exchange_id: "CME_Eq" |
| contract_id: "..." | contract_id: "ES" |
| market_id: "..." | market_id: "XME_Eq ES ()" |
| quotes: QUOTES_FULL_ORDER_BOOK // detail level (see below) | quotes: QUOTES_FULL_ORDER_BOOK // detail level (see below) |
| ticker: true // also stream trade prints | ticker: true // also stream trade prints |
| </code> | </code> |
| |
| **''quotes''** (''Quotes'' enum) selects the feed: | The [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/common/enums.proto#L95|Quotes]] enum selects the market data feed: |
| |
| ^ Value ^ You receive ^ | ^ Value ^ You receive ^ |
| | ''QUOTES_NONE'' | Nothing — **unsubscribes** the market. | | | ''QUOTES_NONE'' | **Unsubscribes** the market | |
| | ''QUOTES_TOP_OF_BOOK'' | Best bid / best offer only, as ''MarketDepth''. | | | ''QUOTES_TOP_OF_BOOK'' | Best bid / best offer (TOB) market depth feed | |
| | ''QUOTES_FULL_ORDER_BOOK'' | Full depth ladder (volume aggregated per price), as ''MarketDepth''. | | | ''QUOTES_FULL_ORDER_BOOK'' | Top-10 bids and offfers (FOB) market depth feed | |
| | ''QUOTES_MARKET_BY_ORDER'' | Every individual resting order, as ''MarketByOrder*''. | | | ''QUOTES_MARKET_BY_ORDER'' | Market by order (MBO) feed | |
| |
| **''ticker''** — when true, trade prints stream as ''MarketTrade'' messages. | **''ticker''** — when true, trade prints stream as [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L119|MarketTrade]] messages. |
| |
| **Unsubscribe** — resend ''MarketSubscribe'' for the same market with ''quotes: QUOTES_NONE''. | **Unsubscribe** — Send a [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L9|MarketSubscribe]] for the same market with ''quotes: QUOTES_NONE''. |
| |
| ===== What you receive ===== | ===== What You Receive ===== |
| |
| **Quote Feed** (''TOP_OF_BOOK'' / ''FULL_ORDER_BOOK''): | **Quote Feed** (''TOP_OF_BOOK'' / ''FULL_ORDER_BOOK''): |
| * ''MarketSnapshot'' — full current state on subscribe (bundles depth, trades, high/low, price limits, settlement). | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L190|MarketSnapshot]] — full current state on subscribe (bundles depth, trades, high/low, price limits, settlement). |
| * ''MarketDepth'' — incremental bid/offer/implied updates thereafter. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L79|MarketDepth]] — incremental bid/offer/implied updates thereafter. |
| |
| **Market by Order Feed** (''MARKET_BY_ORDER''): | **Market by Order Feed** (''MARKET_BY_ORDER''): |
| * ''MarketByOrderSnapshot'' — all resting orders plus ''last_sequence''. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L213|MarketByOrderSnapshot]] — all resting orders plus ''last_sequence''. |
| * ''MarketByOrderUpdate'' — per-order changes; each has a ''sequence'' and ''updates[]'' of type ''ADD_OR_UPDATE'', ''DELETE'' or ''CLEAR''. Apply in order; on a gap, resubscribe. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L231|MarketByOrderUpdate]] — per-order changes; each has a ''sequence'' and ''updates[]'' of type ''ADD_OR_UPDATE'', ''DELETE'' or ''CLEAR''. Apply in order; on a gap, resubscribe. |
| |
| **Ticker Feed** | **Ticker Feed** |
| * ''MarketTrade'' — when ''ticker'' is set. For an MBO subscription it also carries the trade ''sequence'' and the participating resting orders | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L119|MarketTrade]] — when ''ticker'' is set. For an MBO subscription it also carries the trade ''sequence'' and the participating resting orders |
| |
| **Always:** | **Always:** |
| * ''MarketDetails'' — the instrument definition. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L29|MarketDetails]] — the instrument definition. |
| * ''MarketHighLow'', ''MarketPriceLimits'', ''MarketSettlement'' — as they occur. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L144|MarketHighLow]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L155|MarketPriceLimits]], [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L165|MarketSettlement]] — as they occur. |
| * ''MarketSubscribeReject'' — subscription refused; check ''mode''. | * [[https://github.com/CTS-Futures/t4-api-tools/blob/main/proto/t4/v2/market/market.proto#L21|MarketSubscribeReject]] — subscription refused. |
| |
| Every message carries a ''mode'' (''MarketMode'': open, closed, halted, …) and a ''delayed'' flag. | |
| |
| ===== Reference ===== | |
| |
| Messages and every field: ''proto/t4/v2/market/market.proto''. Enums (''Quotes'', ''MarketMode'', ''BidOffer''): ''proto/t4/v2/common/enums.proto''. See the [[developers:apiv2:reference|Message Catalog]]. | |
| |