Low-Latency Limit Order Book & Trade Matching Engine Prototype in C# / Akka.NET
TradeExchangeActorExample is a reference architecture and performance prototype for an actor-based financial limit order book and order matching engine written in C# and Akka.NET.
It models high-concurrency order intake, price-time priority matching, and atomic user balance management using isolated actor state rather than shared-memory locks.
- Lock-Free Actor Concurrency:
OrderBookActor— Maintains bid/ask queues per trading pair (Symbol) and executes deterministic price-time matching.BuyOrderActor/SellOrderActor(OrderActor) — Encapsulates individual order lifecycle, partial fills, and settlement notifications.UserBalance— Tracks multi-currency account balances and reservation invariants.
- Rich Financial Domain Primitives:
- Strongly-typed
Money,Currency,Symbol,BuyOrder, andSellOrderdomain value objects preventing cross-currency arithmetic errors (CurrencyMismatchException).
- Strongly-typed
- Deterministic Throughput & Stress Benchmarking:
TradeExchange.Tests.Stress(OrderMatchBench.cs) — Throughput and allocation benchmarks powered by NBench to measure order matching latency under load.TradeExchangeTests— Unit and actor-system integration tests (OrderProcessingTests,BalanceTests,Market).
TradeExchangeActorExample/
├── TradeExchangeDomain/ # Core domain primitives (Money, Currency, Symbol, Orders) & Actors
│ ├── Actors/ # OrderBookActor, BuyOrderActor, SellOrderActor, UserBalance
│ └── Orders/ # Order, BuyOrder, SellOrder domain models
├── TradeExchangeTests/ # Functional & ActorSystem verification tests
├── TradeExchange.Tests.Stress/ # NBench high-throughput order matching benchmarks
└── TradeExchangeStressTests/ # Stress test runner
Andrey Leskov — CTO & Principal Systems Architect (illumi.one · LinkedIn).