Exchange Protocols and Connectivity¶
Overview¶
Trading requires connecting to exchanges through standardized protocols. Understanding these protocols is essential for building trading systems, ensuring proper order handling, and optimizing execution speed.
Difficulty advanced
fix protocol (financial information exchange)¶
Overview¶
FIX is the industry standard for electronic trading communication:
- Used by most institutional trading systems
- Session layer + Application layer
- Text-based (tag=value) format
- Versions: 4.0, 4.1, 4.2, 4.3, 4.4, 5.0
Not optimized for latency (text parsing overhead).
Used for order routing, not HFT.
Session Layer¶
Message Flow:
1. Logon (MsgType=A)
2. Heartbeat (MsgType=0) every 30 seconds
3. Test Request (MsgType=1) / Resend Request (MsgType=2)
4. Logout (MsgType=5)
Key Fields:
8=FIX.4.4 (BeginString)
9=BodyLength
35=MsgType
34=MsgSeqNum
49=SenderCompID
56=TargetCompID
52=SendingTime
Application Messages¶
New Order Single (MsgType=D):
35=D (New Order Single)
11=ClOrdID (Client order ID)
55=Symbol
54=Side (1=Buy, 2=Sell)
38=OrderQty
40=OrdType (1=Market, 2=Limit)
44=Price (for limit orders)
59=TimeInForce (0=Day, 1=GTC, 3=IOC, 4=FOK)
Execution Report (MsgType=8):
35=8 (Execution Report)
11=ClOrdID
150=ExecType (0=New, 1=Partial Fill, 2=Fill, 4=Canceled, 8=Rejected)
39=OrdStatus (0=New, 1=Partially Filled, 2=Filled, 4=Canceled)
31=LastPx (Last filled price)
32=LastQty (Last filled quantity)
14=CumQty (Cumulative filled quantity)
Cancel Request (MsgType=F):
35=F (Cancel Request)
11=ClOrdID
41=OrigClOrdID (Original order ID to cancel)
55=Symbol
54=Side
38=OrderQty
Exchange-Specific Protocols¶
NASDAQ: OUCH/ITCH¶
OUCH (Order entry):
- Binary protocol
- Ultra-low latency
- Used for order entry to NASDAQ matching engine
- Message types: Enter Order, Replace Order, Cancel Order, Execute
ITCH (Market data):
- Binary protocol
- Full order book data
- Message types: System Event, Stock Directory, Add Order,
Order Executed, Order Delete, Order Replace, Trade
NYSE: Pillar¶
Pillar (Unified platform):
- Replaced legacy Pillar, OpenBook, and Display platforms
- Binary protocol for both orders and market data
- Supports equities, options, and ETFs
CME: SPECTRE/FAST¶
SPECTRE (CME Globex protocol):
- Binary protocol for order entry
- Used for futures and options
FAST (FIX Adapted for Streaming):
- Compressed binary FIX
- Used for market data dissemination
- Reduces bandwidth by 70-90% vs. text FIX
IEX: DEEP/TOUCH¶
DEEP (Dissemination of Equity Execution and Price):
- Real-time depth of book data
- Includes IEX-specific order types (D-Orders, P-Orders)
TOUCH (Top of Book):
- NBBO data from IEX
Order Types by Exchange¶
| Order Type | Description | Supported By |
|---|---|---|
| Market | Execute at best available price | All |
| Limit | Execute at specified price or better | All |
| IOC | Immediate or Cancel | All |
| FOK | Fill or Kill | Most |
| GTC | Good Till Canceled | Most |
| GTD | Good Till Date | Most |
| Stop | Triggered at stop price | Most |
| Stop Limit | Stop + Limit combination | Most |
| Pegged | Price pegged to reference | NASDAQ, NYSE |
| Reserve/Hidden | Display partial quantity | Most |
| Intermarket Sweep | Bypass SIP, sweep multiple venues | US Equities |
Connectivity Architecture¶
┌─────────────┐
│ Trading │
│ System │
└──────┬──────┘
│
┌──────┴──────┐
│ Gateway / │
│ Adapter │
└──────┬──────┘
│
┌────────────┼────────────┐
│ │ │
┌─────┴─────┐ ┌───┴────┐ ┌─────┴─────┐
│ Exchange A│ │Exchange│ │ Exchange C│
│ (FIX) │ │ B (OUCH)│ │ (SPECTRE) │
└───────────┘ └────────┘ └───────────┘
Gateway Responsibilities:
1. Protocol translation (FIX → exchange protocol)
2. Order validation
3. Risk checks
4. Sequence number management
5. Heartbeat monitoring
6. Reconnection handling
Checklist¶
- [ ] FIX session parameters configured correctly
- [ ] Exchange-specific protocol understood
- [ ] Sequence number management implemented
- [ ] Heartbeat monitoring active
- [ ] Automatic reconnection logic
- [ ] Order validation before sending
- [ ] Risk checks in gateway
- [ ] Latency measured and monitored
- [ ] Message logging for audit trail
- [ ] Disaster recovery plan tested
References¶
- FIX Trading Community. (2023). "FIX Protocol Specification." FIX Trading Standards.
- NASDAQ. (2023). "OUCH 5.0 Specification." NASDAQ.
- CME Group. (2023). "SPECTRE Order Entry Specification." CME Group.