FIX Feed
ZeptoDB Feed Handler Guide
Section titled “ZeptoDB Feed Handler Guide”Feed Handlers are components that receive real-time market data from exchanges, data vendors, and feed providers and ingest it into ZeptoDB.
Supported Protocols
Section titled “Supported Protocols”1. FIX (Financial Information eXchange)
Section titled “1. FIX (Financial Information eXchange)”Purpose: Integration with data vendors such as Bloomberg, Reuters, ICE
#include "zeptodb/feeds/fix_feed_handler.h"
// FIX configurationfeeds::FeedConfig config;config.host = "bloomberg-feed.com";config.port = 5000;config.username = "APEX_CLIENT";config.password = "password";
feeds::FIXFeedHandler feed_handler(config, &mapper);
// Tick callbackfeed_handler.on_tick([&](const feeds::Tick& tick) { pipeline.ingest(tick.symbol_id, tick.price, tick.volume, tick.timestamp_ns);});
// Connect and subscribefeed_handler.connect();feed_handler.subscribe({"AAPL", "MSFT", "TSLA"});Characteristics:
- TCP-based
- Automatic reconnection
- Heartbeat maintenance
- Latency: 100μs-1ms
2. Multicast UDP (Direct Exchange Connectivity)
Section titled “2. Multicast UDP (Direct Exchange Connectivity)”Purpose: Direct connection to exchanges such as NASDAQ, NYSE, CME
#include "zeptodb/feeds/multicast_receiver.h"
// Multicast receptionfeeds::MulticastReceiver receiver("239.1.1.1", 10000);
receiver.on_packet([&](const uint8_t* data, size_t len) { // Process with protocol-specific parser parser.parse_packet(data, len);});
receiver.join();receiver.start();Characteristics:
- UDP multicast
- Ultra-low latency: 1-5μs
- Packet loss possible (no retransmission)
- High throughput: 10+ Gbps
3. NASDAQ ITCH 5.0
Section titled “3. NASDAQ ITCH 5.0”Purpose: NASDAQ TotalView market data
#include "zeptodb/feeds/nasdaq_itch.h"
feeds::NASDAQITCHParser parser;
receiver.on_packet([&](const uint8_t* data, size_t len) { if (parser.parse_packet(data, len)) { feeds::Tick tick; if (parser.extract_tick(tick, &mapper)) { pipeline.ingest(tick.symbol_id, tick.price, tick.volume, tick.timestamp_ns); } }});Supported messages:
- Add Order (Type A)
- Order Executed (Type E)
- Trade (Type P)
- Order Cancel (Type X)
Characteristics:
- Binary protocol (packed structs)
- Big-endian
- Parsing speed: ~500ns per message
4. Binance WebSocket (Cryptocurrency)
Section titled “4. Binance WebSocket (Cryptocurrency)”Purpose: Binance Spot/Futures real-time data
#include "zeptodb/feeds/binance_feed.h"
// TODO: WebSocket library integration neededfeeds::BinanceFeedHandler feed_handler(config, &mapper);
feed_handler.on_tick([&](const feeds::Tick& tick) { pipeline.ingest(tick.symbol_id, tick.price, tick.volume, tick.timestamp_ns);});
feed_handler.connect();feed_handler.subscribe({"btcusdt@trade", "ethusdt@trade"});Stream types:
@trade- real-time trades@aggTrade- aggregated trades@depth- order book@bookTicker- best bid/ask
Architecture
Section titled “Architecture”┌────────────────────┐│ Exchange Feed │ UDP Multicast / TCP│ (NASDAQ, CME) │└─────────┬──────────┘ ↓┌─────────▼──────────┐│ Feed Handler │ Protocol parser│ (FIX, ITCH, etc) │ - FIX: tag=value└─────────┬──────────┘ - ITCH: binary ↓ - WebSocket: JSON┌─────────▼──────────┐│ Symbol Mapper │ symbol → symbol_id└─────────┬──────────┘ ↓┌─────────▼──────────┐│ ZeptoDB Pipeline │ 5.52M ticks/sec│ ingest() │ zero-copy└────────────────────┘Performance Optimization
Section titled “Performance Optimization”1. Zero-Copy Parsing
Section titled “1. Zero-Copy Parsing”// Bad: copystd::string msg_copy(data, len);parser.parse(msg_copy);
// Good: zero-copyparser.parse(data, len); // pass pointer only2. SIMD Batch Parsing
Section titled “2. SIMD Batch Parsing”// ITCH message batch parsingauto ticks = parser.parse_batch_simd(data, len); // AVX-512pipeline.batch_ingest(ticks); // batch ingestion3. CPU Pinning
Section titled “3. CPU Pinning”// Dedicate a core to Feed Handlercpu_set_t cpuset;CPU_ZERO(&cpuset);CPU_SET(0, &cpuset); // core 0 dedicatedpthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);Production Checklist
Section titled “Production Checklist”Configuration
Section titled “Configuration”- CPU pinning (cores 0-1 dedicated)
- Huge pages (2MB pages)
- IRQ affinity (NIC → dedicated core)
- UDP receive buffer (2MB+)
- Kernel bypass (Solarflare, Mellanox)
Monitoring
Section titled “Monitoring”- Tick throughput (ticks/sec)
- Packet drop rate
- Parse error rate
- Latency (end-to-end)
Failure Handling
Section titled “Failure Handling”- Reconnect logic (FIX)
- Gap fill (sequence gap detection)
- Failover (Primary/Secondary Feed)
- Alerting (PagerDuty)
Examples
Section titled “Examples”Complete Integration Example
Section titled “Complete Integration Example”cd /home/ec2-user/zeptodbmkdir build && cd buildcmake ..make feed_handler_integration
./feed_handler_integration fix
# NASDAQ ITCH./feed_handler_integration itch
# Performance test./feed_handler_integration perfExample file:
examples/feed_handler_integration.cpp
Roadmap
Section titled “Roadmap”Phase 1 (Complete)
Section titled “Phase 1 (Complete)”- FIX protocol parser
- Multicast UDP receiver
- NASDAQ ITCH parser
- Integration example
Phase 2 (TODO)
Section titled “Phase 2 (TODO)”- CME SBE (Simple Binary Encoding)
- NYSE Pillar protocol
- Binance WebSocket (actual implementation)
- Gap fill / retransmission logic
Phase 3 (TODO)
Section titled “Phase 3 (TODO)”- SIMD batch parsing
- Kernel bypass (DPDK)
- GPU offloading
- Multicast Failover
Business Value
Section titled “Business Value”HFT Market Entry
Section titled “HFT Market Entry”✅ Before: HTTP API only (ms-level latency) ✅ After: UDP Multicast + FIX (μs-level latency)
ROI:
- HFT customer targeting possible: $2.5M-12M market
- Full kdb+ replacement: FIX + ITCH support
- Data vendor integration: Bloomberg, Reuters
Competitive Advantages
Section titled “Competitive Advantages”| Item | kdb+ | ClickHouse | ZeptoDB |
|---|---|---|---|
| FIX support | ✅ (external) | ❌ | ✅ Native |
| ITCH support | ✅ (external) | ❌ | ✅ Native |
| Multicast | ✅ | ❌ | ✅ |
| Performance | baseline | N/A | equivalent |
Support
Section titled “Support”For issues:
- GitHub Issues: https://github.com/zeptodb/zeptodb/issues
- Examples:
/home/ec2-user/zeptodb/examples/feed_handler_integration.cpp - Documentation:
/home/ec2-user/zeptodb/docs/feeds/