How xxnik/c-electronic-trading works
This is a C++ low-latency electronic trading engine. Trading clients send binary TCP order and cancel requests; the server executable routes decoded requests into the matching engine, which validates risk and processes orders against per-symbol price-time books. Execution reports return to clients, while book events feed asynchronous market-data publication. The README documents the principal gateway, sequencer, risk, book, execution-report, and market-data capabilities; sampled main and header excerpts confirm key wiring, but matching-engine and server implementation details are not shown here.
Main entry points: matching_engine.cpp Matching Engine · tcp_server.cpp TCP Server · main.cpp Server Orchestrator · order_book.cpp Limit Order Book
Components 18
Order Gateway
- TCP Server
src/net/tcp_server.cpp - Binary Protocol
include/trading_engine/protocol/binary_protocol.hpp - Server Orchestrator
src/main.cpp - Client Simulator
tools/client_simulator.cpp - Socket Compatibility
src/net/socket_compat.cpp - TCP Client
include/trading_engine/net/tcp_client.hpp
Matching Core
- Matching Engine
src/engine/matching_engine.cpp - SPSC Sequencer
include/trading_engine/common/ring_buffer.hpp - Pre-Trade Risk
src/engine/risk_manager.cpp - Limit Order Book
src/orderbook/order_book.cpp - Price Levels
src/orderbook/price_level.cpp - Memory Pools
include/trading_engine/common/memory_pool.hpp
Market Data
- Market Data Feed
src/market_data/market_data_feed.cpp - Market Data Events
include/trading_engine/market_data/market_data_types.hpp - Market Data Listener
tools/market_data_listener.cpp
Runtime Support
- Async Logger
src/common/logger.cpp - Time Utilities
include/trading_engine/common/time_utils.hpp
Other components
- Trading Clients
Connections 20
- Trading Clients → TCP Server: send binary
README.md - Client Simulator → TCP Client: sends requests
tools/client_simulator.cpp - TCP Server → Server Orchestrator: delivers messages
- Server Orchestrator → TCP Server: configures callbacks
src/main.cpp - Server Orchestrator → Matching Engine: submits orders
src/main.cpp - Matching Engine → SPSC Sequencer: queues commands
README.md - Matching Engine → Pre-Trade Risk: validates orders
README.md - Matching Engine → Limit Order Book: processes orders
README.md - Limit Order Book → Price Levels: manages levels
- Limit Order Book → Memory Pools: allocates objects
- Matching Engine → Market Data Feed: publishes updates
README.md - Market Data Feed → Market Data Events: queues events
- Market Data Feed → Market Data Listener: broadcasts updates
- Matching Engine → Server Orchestrator: reports executions
src/main.cpp - Server Orchestrator → TCP Server: sends reports
src/main.cpp - TCP Server → Binary Protocol: frames messages
- TCP Client → Binary Protocol: encodes requests
include/trading_engine/net/tcp_client.hpp - TCP Server → Socket Compatibility: uses sockets
- Matching Engine → Async Logger: logs activity
src/engine/matching_engine.cpp - Async Logger → Time Utilities: timestamps entries