Market Data Feeds and Parsers
Market data feeds are the real-time stream of information that exchanges broadcast to market participants: new orders, cancellations, modifications, and trade executions.
What Feeds Exchanges Publish
When an order book changes, the exchange publishes an update message to every subscriber. These feed handlers are some of the most latency-sensitive systems in finance.
Message types:
- NEW_ORDER → add a bid/ask to the book
- CANCEL → remove a quantity from an existing order
- REPLACE → modify price/quantity of an existing order
- TRADE → a matched buy and sellFeed Protocols
FIX (Financial Information eXchange)
A text-based protocol used for order entry and trade reporting. Human-readable but verbose.
8=FIX.4.2|35=D|55=AAPL|44=150.00|38=100|54=1|
^ ^ ^ ^ ^ ^ ^
Begin Type Symbol Price Qty Side(1=Buy)ITCH / OUCH
Binary protocols used by exchanges like NASDAQ for ultra-low-latency market data.
ITCH (market data):
- Add Order (35=353)
- Order Delete (35=354)
- Order Cancel (35=355)
OUCH (order entry):
- New Order (35=A)
- Modify Order (35=E)
- Cancel Order (35=F)Feed Handlers
A feed handler is the software that receives, parses, and processes market data. Feed handlers must:
- Parse at line rate — Process every byte as it arrives, no buffering.
- Maintain order book state — Apply each update in order to reconstruct the book.
- Handle gaps and replays — Markets pause and resume (circuit breakers); feed handlers must catch up.
- Distribute to strategies — Feed the book to trading algorithms with minimal latency.
Architecture
Network → NIC (kernel bypass) → Feed Handler (C++) → Order Book → Strategy → Order Gateway → Exchange
Latency budget:
- Network: 5-50 μs (colocated)
- Feed handler parse: 100 ns - 1 μs per message
- Order book update: 100 ns
- Strategy decision: 100 ns - 10 μs
- Network return: 5-50 μsBook Reconstruction
The feed handler rebuilds the order book from the message stream:
- Apply adds — Insert new orders at the correct price level.
- Apply cancels — Remove quantity from existing orders.
- Apply deletes — Remove orders entirely.
- Apply trades — Remove matched quantity, record the trade price.
The top of book (best bid/ask) is the most watched — it determines whether incoming market orders will match.