How ad-kat/limit-order-book-and-matching-engine works
The product is a C++ price-time-priority limit order book and matching engine, with a FastAPI bridge and live React demo. A typical flow is market-feed data or an order request entering the API, passing through the serialized subprocess bridge to the C++ engine, then returning book/trade events over WebSockets to the dashboard. The README also documents periodic LLM commentary and a fallback chain. Relationships for unsampled subsystems are included only where the README describes them; this is not a claim that their source was inspected.
Main entry points: main.py REST and WS routes · App.jsx Dashboard app · main.cpp Interactive engine · market_feed.py Market feed
Components 17
Matching engine
- Interactive engine
src/main.cpp - Order book
src/order_book.cpp
API and feed
- Market feed
market_feed.py - REST and WS routes
api/main.py - Subprocess bridge
api/engine.py - API models
api/models.py - WS broadcast
api/ws_manager.py
Live commentary
- Commentary agent
api/commentary.py
Dashboard
- Live data hook
lob-dashboard/src/hooks/useLOB.js - Dashboard app
lob-dashboard/src/App.jsx - Stats panel
lob-dashboard/src/components/StatsBar.jsx - Book view
lob-dashboard/src/components/OrderBook.jsx - Trade tape
lob-dashboard/src/components/TradeTape.jsx - Commentary view
lob-dashboard/src/components/Commentary.jsx
Other components
- Order client
- Market data
- LLM providers
Connections 16
- Order client → REST and WS routes: submits orders
- Market data → Market feed: supplies ticks
- Market feed → REST and WS routes: posts orders
- REST and WS routes → Subprocess bridge: dispatches orders
api/main.py - REST and WS routes → API models: uses schemas
api/main.py - Subprocess bridge → Interactive engine: pipes commands
- Interactive engine → Order book: invokes matching
src/main.cpp - REST and WS routes → WS broadcast: broadcasts events
api/main.py - REST and WS routes → Commentary agent: requests narration
api/main.py - Commentary agent → LLM providers: requests narration
- WS broadcast → Live data hook: sends WebSocket events
- Live data hook → Dashboard app: provides live state
lob-dashboard/src/App.jsx - Dashboard app → Stats panel: renders
lob-dashboard/src/App.jsx - Dashboard app → Book view: renders
lob-dashboard/src/App.jsx - Dashboard app → Trade tape: renders
lob-dashboard/src/App.jsx - Dashboard app → Commentary view: renders
lob-dashboard/src/App.jsx