Skip to content

About

Low-latency limit order book and trade matching engine prototype built with C# and the Akka.NET Actor Model, including NBench stress benchmarks

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

TradeExchangeActorExample

Low-Latency Limit Order Book & Trade Matching Engine Prototype in C# / Akka.NET

.NET Akka.NET Benchmark


Overview

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.


Architectural Highlights

  • 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, and SellOrder domain value objects preventing cross-currency arithmetic errors (CurrencyMismatchException).
  • 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).

Project Structure

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

Author

Andrey Leskov — CTO & Principal Systems Architect (illumi.one · LinkedIn).

About

Low-latency limit order book and trade matching engine prototype built with C# and the Akka.NET Actor Model, including NBench stress benchmarks

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages