rust · clearing infrastructure

open clearing engine

an open-source, nsccl-grade clearing & settlement engine in rust.

rust clearing house settlement novation multilateral netting span margin event sourcing central counterparty apache-2.0

what it is

a clearing house sits between two sides of a trade and guarantees it settles. this engine takes executed trades and turns them into regulator-grade settlement obligations, through the same pipeline a real clearing corporation uses — novation → position keeping → multilateral netting → settlement — with a span portfolio-risk engine sitting on top.

it's not a toy. it's built for determinism, reproducibility, and scale. the embedded implementations run with zero infrastructure today; the production stack (kafka/redpanda, rocksdb, clickhouse, k3s) plugs in behind the existing ports with no domain rewrite. the codebase is a cargo workspace laid out hexagonally — ports and adapters — so the financial logic never depends on the plumbing.

the clearing cycle

novation — the clearing house steps in as the counterparty to both sides, so neither side carries the other's default risk
position keeping — net positions tracked per member, per instrument
multilateral netting — collapse a mountain of obligations into the fewest possible settlements
span margin — portfolio-level risk margin computed per member
settlement obligations — a deterministic, replayable, regulator-grade output file
rustlanguage
~40tests (incl. replay e2e)
rest + wsapi surface
apache-2.0license

why event sourcing

every state change is an event. that means the whole settlement run can be replayed from the log and produce a byte-identical result — which is exactly the property a regulator or an auditor wants. it also makes the determinism tests possible: pin a golden obligation file, then prove the engine never drifts from it.

i wanted to understand how money actually settles, not just read about it. building the cycle end to end — and forcing it to be deterministic — taught me more than any explanation could.

iteration 1 is complete: foundation, ports, market data, the vertical slice, span, api/cli, dashboard, and a dev deployment — all green. the deferred scaling work is enumerated with its seam in the docs. this is research and learning infrastructure, not a live clearing corporation.


built by dharun ashokkumar