How mike-here/nexuslob works
NexusLOB is a single-writer limit-order-book and matching engine exposed through a fixed-size binary TCP protocol. A client submits orders and cancellations; the epoll listener decodes messages into an ingress ring, the pinned matching loop processes them, and execution reports return through an egress ring to the client. The book handles crossing, price-time fills, resting orders, and cancellation. The README also documents a NumPy momentum workload and execution validator. Relationships shown are supported by the README or excerpts; unsampled implementation details are omitted.
Main entry points: network_listener.cpp epoll listener · order_book.cpp Order book · main.cpp Matching loop · network_listener.h Listener API and rings
Components 12
TCP interface
- epoll listener
src/network_listener.cpp - Binary protocol
include/nexuslob/wire_protocol.h
Matching engine
- Matching loop
src/main.cpp - Order book
src/order_book.cpp - Price-level books
include/nexuslob/order_book.h - Order pool
include/nexuslob/memory_pool.h - Order and execution types
include/nexuslob/types.h
Thread transport
- Ingress SPSC ring
include/nexuslob/ring_buffer.h - Egress SPSC ring
include/nexuslob/ring_buffer.h - Listener API and rings
include/nexuslob/network_listener.h
Workload replay
- Momentum workload
tools/backtest_momentum.py
Other components
- TCP client
Connections 15
- TCP client → epoll listener: sends orders
README.md - epoll listener → Binary protocol: decodes and encodes
src/network_listener.cpp - epoll listener → Ingress SPSC ring: queues messages
src/network_listener.cpp - Matching loop → epoll listener: starts thread
src/main.cpp - Matching loop → Ingress SPSC ring: reads messages
src/main.cpp - Matching loop → Order book: processes messages
src/main.cpp - Order book → Egress SPSC ring: publishes executions
- epoll listener → Egress SPSC ring: drains reports
src/network_listener.cpp - Order book → Price-level books: updates price levels
src/order_book.cpp - Order book → Order pool: allocates resting orders
- Order book → Order and execution types: processes typed messages
src/order_book.cpp - epoll listener → Listener API and rings: implements listener
src/network_listener.cpp - Listener API and rings → Ingress SPSC ring: defines ring type
include/nexuslob/network_listener.h - Listener API and rings → Egress SPSC ring: defines ring type
include/nexuslob/network_listener.h - Momentum workload → TCP client: connects and validates
README.md