Market data processing system built in C++. Retrieves real-time data via WebSocket, detects arbitrage opportunities with low-latency processing.
Real-Time WebSocket Data Handling: Use websocketpp and boost::asio to manage connections to Kraken and Bybit exchange.
Low-Latency Parsing: Optimized JSON parsing using jsoncpp with efficient memory allocation.
Multithreaded Processing: Producer-consumer model for concurrent data processing.
Lock-Free Data Management: Utilize std::atomic<std::shared_ptr> for non-blocking updates to market data.
Arbitrage Calculation: Compute arbitrage opportunities with fee considerations and configurable thresholds.
- main.cpp
Initializes market data feed handler.
- MarketDataHandler.cpp
Manages data feeds, synchronizes market data updates, and invokes arbitrage calculations.
- MarketDataFeed.cpp
Handles WebSocket connections and processes/parse incoming trade messages. Atomically updates trade data.
- ArbitrageCalculator.cpp
Computes arbitrage opportunities based on price differences and trading fees.
Singleton Pattern: Ensures a single instance of market data feeds per exchange.
Observer Pattern: MarketDataHandler observes MarketDataFeed for updates.
Lock-Free Design: Uses std::atomic<std::shared_ptr> for non-blocking updates.
Compression Handling: Supports gzip decompression for WebSocket messages.
-Memory Pool for JSON Parsing, reducing overheads -Orderbook including bid/ask
Requirements:
C++, boost::asio, websocketpp, jsoncpp, ZLIb, CURL, OpenSSL, CMake
Create a third_party folder and install websocketpp.
Run the following to create a build directory, compile, link and run the project:
mkdir build cd build cmake .. make ./market_data_handler