Feed Handlers and Normalization
Feed handlers connect to exchange data feeds and convert each venue's format into one standard internal format. Learn the design, symbol mapping and common pitfalls.
Every exchange publishes market data in its own format. One sends JSON over WebSocket with prices as strings; another sends compact binary messages over multicast; a third names the same instrument differently and uses a different time unit. A feed handler is the component that connects to one venue's feed, decodes its messages and converts them into a single standard internal format. Everything downstream, from bar builders to strategies, then works with one consistent model regardless of where the data came from.
What a feed handler does#
| Task | Example |
|---|---|
| Connect and subscribe | Open the WebSocket or join multicast groups, log on, subscribe to symbols |
| Decode | Parse JSON, FIX or binary messages. See Binary Protocols |
| Validate | Check sequence numbers and message integrity. See Sequence Numbers, Dropped Packets and Out-of-Order Messages |
| Recover | Request snapshots or replays after gaps |
| Normalise | Convert to the internal format: instrument ID, side, price, size, timestamps |
| Publish | Pass normalised events to the rest of the system. See Message Queues |
| Monitor | Report latency, message rates, gaps and disconnects |
Normalisation: the details that matter#
| Field | Venue differences | Normalised form |
|---|---|---|
| Symbol | BTCUSDT, BTC-USDT, XBT/USD, tBTCUSD | Internal instrument ID with a mapping table |
| Price | String, float, integer in ticks, scaled integer | One consistent numeric type |
| Size | Base units, contracts, lots | One unit, with contract size known |
| Side | "buy", "B", 1, "bid", or aggressor flags | One enumeration |
| Time | Seconds, milliseconds, microseconds, nanoseconds; local or UTC | UTC nanoseconds |
| Event type | Trade, quote, book delta, status | One set of event types |
Price representation#
Floating point numbers cannot represent many decimal prices exactly, so 0.1 plus 0.2 does not equal exactly 0.3. For research this rarely matters, but order prices must be exact multiples of the tick size. Many systems store prices as integers in tick units or as scaled integers and convert only for display. See Tick Size and Tick Value.
Symbol and reference data#
A reference data service holds each instrument's details: venue symbols, tick size, lot size, contract multiplier, trading hours and status. Feed handlers use it to map and scale values. Keeping it current is critical, because venues add, delist and change instruments frequently. See Contract Specifications.
Design principles#
- One handler per venue, isolating venue specific quirks.
- Fail loudly on unknown message types or fields rather than guessing.
- Keep the raw message or a raw log for debugging and replay. See Market Data Replay.
- Timestamp on arrival as well as keeping the venue's timestamp. See Timestamps, Time Zones and Daylight Saving.
- Measure latency from venue time to publish time. See Exchange vs Receive Timestamps and Latency Measurement.
Build or buy#
Writing feed handlers for a few crypto exchanges is a manageable project. Covering many traditional exchanges with binary multicast feeds is a large engineering effort, which is why firms often buy normalised data from vendors or use open source libraries that already support many venues, such as CCXT for crypto REST and WebSocket APIs.
Frequently asked questions#
What is a feed handler?#
Software that connects to a venue's market data feed, decodes its messages and converts them into a standard internal format for the rest of a trading system.
Why is data normalisation needed?#
Each venue uses different symbols, units, number formats and timestamps; normalisation lets strategies treat data from all venues the same way.
Should prices be stored as floats?#
For research floats are usually fine, but for order prices many systems use integers in tick units to avoid rounding errors.
Next, learn how sequence numbers keep feeds reliable in Sequence Numbers, Dropped Packets and Out-of-Order Messages.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- Data Pipelines and ETLProgramming and Data
- Trading Infrastructure ExplainedTrading Infrastructure
- Networking for TradersTrading Infrastructure
- Quant Developer and Trading EngineerThe Trading Industry