CME MDP 3.0 Protocol
Thenano-feed crate provides a complete implementation of the CME MDP 3.0 binary protocol with zero-copy parsing for ultra-low latency.
Message Types
MDP 3.0 messages are parsed into strongly-typed Rust structures:nano-feed/src/messages.rs:354-373
Book Update Messages
Book updates contain incremental changes to the order book:nano-feed/src/messages.rs:183-198, 146-160
Price Encoding
CME uses mantissa-exponent encoding for prices:-2for ES futures (0.01 precision)-3for higher precision instruments
nano-feed/src/messages.rs:163-168
Trade Messages
Trade messages contain executed trades with aggressor side:nano-feed/src/messages.rs:274-289, 235-247
Zero-Copy Parsing
NanoARB uses thenom parser combinator library for zero-copy, zero-allocation parsing of binary MDP 3.0 messages.
Parser Architecture
nano-feed/src/parser.rs:170-193
Message Parser
TheMdpParser maintains sequence tracking and handles incomplete buffers:
nano-feed/src/parser.rs:35-94
Sequence Gap Detection
The parser automatically detects missing messages:nano-feed/src/parser.rs:115-133
Synthetic Data Generation
For development and backtesting,SyntheticGenerator creates realistic market data:
Configuration
nano-feed/src/synthetic.rs:14-40
Preset Configurations
Pre-configured settings for common instruments:nano-feed/src/synthetic.rs:62-92
Generating Events
nano-feed/src/synthetic.rs:157-176, 365-373
Realistic Market Dynamics
The generator simulates:- Price movement: Random walk with configurable volatility
- Bid-ask spread: Maintains realistic spread in ticks
- Depth levels: Multiple price levels with varying quantities
- Trade flow: Alternating buy/sell trades that consume liquidity
- Time progression: Realistic timestamps with configurable intervals
nano-feed/src/synthetic.rs:166-169
Usage Example
Real Market Data
Synthetic Data for Testing
Performance Characteristics
Parsing Latency
The zero-copy parser achieves:- BookUpdate parsing: ~200-400ns per message
- Trade parsing: ~150-300ns per message
- Sequence validation: ~10ns overhead per message
Memory Usage
The parser maintains minimal state:- MdpParser: 16 bytes (sequence counter + flags)
- Per-message allocation: Only for variable-length entry vectors
- Zero-copy: No intermediate buffers for parsing
Error Handling
Next Steps
Feature Extraction
Extract LOB features from market data
Order Book
Reconstruct the limit order book
ML Integration
Feed data into ML models
Backtesting
Backtest strategies on historical data