← Back to Projects
C++ Low-Latency Trading Core

Goal: Prove low-latency C++ ability for infra-level work.
Stack: C++17, Boost.Asio, ZeroMQ, pybind11 (for Python bindings)
- ✅ Implement order book and matching engine
- ✅ REST + WebSocket API layer
- ✅ Multi-threaded architecture
- ✅ Nanosecond-level latency tracking
- ✅ Optional replay mode for historical data
- ✅ C++ and Python development
- ✅ Deep C++ expertise (C++17, template metaprogramming, memory management)
- ✅ Low-latency infrastructure knowledge (lock-free programming, cache op timization)
- ✅ Trading systems understanding (order books, matching engines, market data)
- ✅ Python integration for quant team support (pybind11)
- ✅ Modern web UI development (Material 3 Expressive design)
- ✅ Trading infrastructure
- ✅ Quant team tooling and simulation support
- ✅ Data pipelines (historical replay mode)
- ✅ Generalist software role between Quant/Data/Infra teams
Project Structure
```text
trading-core/
├── include/
│ └── trading_core/
│ ├── types.hpp # Core types, fixed-point pricing
│ ├── order.hpp # Cache-aligned Order struct
│ ├── order_book.hpp # Limit order book
│ ├── matching_engine.hpp # Multi-instrument engine
│ ├── memory/
│ │ └── pool_allocator.hpp
│ ├── lockfree/
│ │ ├── spsc_queue.hpp
│ │ └── ring_buffer.hpp
│ ├── timing/
│ │ ├── clock.hpp # RDTSC timing
│ │ └── latency_tracker.hpp
│ └── network/
│ ├── rest_server.hpp
│ └── websocket_server.hpp
│
├── src/
│ ├── order_book.cpp
│ ├── matching_engine.cpp
│ ├── rest_server.cpp
│ ├── websocket_server.cpp
│ └── main.cpp
│
├── python/
│ ├── bindings.cpp # C++ ↔ Python bindings
│ └── examples/
│ └── simple_strategy.py
│
├── gui/
│ └── src/
│ └── components/ # React components (Next.js)
│
├── tests/ # Google Test suites
└── benchmarks/ # Google Benchmark suites
```
Key Components Implemented
1. Lock-Free Memory Pool
- O(1) allocation/deallocation without malloc
- Cache-line aligned blocks
- RAII wrapper for safe usage
2. SPSC Queue & Ring Buffer
- Wait-free single-producer single-consumer queue
- Configurable overwrite policy
- Cache-line padding to prevent false sharing
3. High-Resolution Timing
- RDTSC instruction for nanosecond precision
- TSC calibration on startup
- Latency histogram with P50/P99/P99.9 percentiles
4. Order Book
- Price-time priority matching
- Separate bid/ask
std::mapstructures - Pool-based Order allocation
- Trade/update callbacks
5. Matching Engine
- Lock-free order submission via SPSC queue
- Dedicated matching thread with CPU affinity
- Multi-instrument support
- End-to-end latency tracking
6. Network APIs
- REST API (Boost.Beast) on port 8080
- WebSocket streaming on port 8081
- JSON serialization with nlohmann/json
7. Python Bindings
- Full OrderBook and MatchingEngine exposure
- Example market-making strategy
8. GUI Dashboard
- Material 3 dark theme with glassmorphism
- Real-time order book visualization
- Latency chart with Recharts
- Order entry form