A high-fidelity electronic trading platform featuring a real-time CLOB matching engine, nanosecond latency profiling, strategy execution framework, and live monitoring dashboards — built to professional HFT infrastructure standards.
Every design decision mirrors patterns used in production exchange infrastructure. The matching engine never touches I/O — events fan out through a bounded in-process bus at nanosecond cost to persistence and WebSocket consumers.
Six independently testable components, each with a defined hot/cold boundary and a replaceable interface for Python, C++, FPGA, or cloud-native upgrade paths.
5,000 rounds per scenario on Windows/MSVC. The frame path separates native matching cost from service projection overhead — exactly the view needed before committing to a slab allocator or binary transport layer.
| Path / Backend | Scenario | p50 | p99 | p999 | Ops/sec | Relative |
|---|---|---|---|---|---|---|
| Frame / C++ | Resting insert | 1.6µs | 5.7µs | 26.3µs | 542,788 | |
| Frame / C++ | Single fill | 1.5µs | 6.5µs | 25.4µs | 583,512 | |
| Frame / C++ | 10-level sweep | 3.2µs | 8.1µs | 13.7µs | 282,892 | |
| Object / C++ | Resting insert | 19.2µs | 35.7µs | 73.0µs | 49,870 | |
| Object / Python | Single fill | 9.2µs | 12.2µs | 23.1µs | 107,345 | |
| Object / Python | Resting insert | 231.3µs | 656.6µs | 4,450µs | 3,492 |
The engine boundary enforces a zero-I/O invariant. No FastAPI, no SQLAlchemy, no asyncio — pure computation behind a single protocol that Python, C++, and FPGA all implement identically.
# Python, C++, and FPGA all implement this. # OrderService never sees a concrete engine. class MatchingHAL(Protocol): def submit_order( self, order: Order ) -> MatchResult: ... def cancel_order( self, order_id: str ) -> Order | None: ... def get_snapshot( self, symbol: str ) -> BookSnapshot | None: ...
# publish_nowait: ~100ns. # Never blocks the matching hot path. # DB and WS push drain independently. class EventBus: def publish_nowait( self, event: DomainEvent ) -> None: for q in self._queues[event.type]: try: q.put_nowait(event) except asyncio.QueueFull: # metric, not an error self.drop_count += 1
Each milestone adds one major capability without breaking existing test coverage or API contracts.
Each layer sits in the right position on the hot/cold spectrum with a seam for production upgrade to FPGA or cloud-native infrastructure.