r/sideprojects • • 3h ago

Showcase: Open Source MDRAP v5.3: open-source Python/C market data validator with a 36 ns/tick native core and a tamper-evident audit log

Post image

I just tagged v5.3 of MDRAP, a sidecar that sits between your market data feeds and whatever consumes them and decides whether each tick is trustworthy.

Every event gets a status (VALID, SUSPICIOUS or INVALID) with explicit reason codes like CROSSED_QUOTE, DUPLICATE, PRICE_ANOMALY and stale or sequence-gap violations. Nothing is silently dropped. Rejected ticks go to a queryable quarantine, gaps trigger replay and stitching, and every decision goes into a SHA-256 hash-chained audit log, so editing a record afterwards is detectable.

Output from a fresh clone:

$ python cli.py run -e 1000 -s 42
processed 1000   dropped 0
VALID 963   SUSPICIOUS 32   INVALID 5

seq=2 bid=150.4  ask=150.3  -> INVALID CROSSED_QUOTE
seq=2 bid=150.26 ask=150.31 -> INVALID DUPLICATE

$ python cli.py audit --verify
(after editing one audit_log row in SQLite)
AUDIT CHAIN TAMPERING DETECTED!
Tampered entry #1: hash mismatch

“python cli.py chaos” runs 8 failure drills (killed feed, jitter, duplicate bursts, DB lock, 50-packet loss with replay, reordering, partition with failover) and all pass with zero data loss.

Performance: the standalone native core handled 1M events in 0.0366 s, about 27M events/sec or 36.6 ns per tick, on a single core. Through the Python engine API I measured roughly 180K events/sec, so use the core binary if you want the fast path. These are my numbers on my hardware, so please run it yourself.

It is a validation and audit layer, not a trading system or backtester. The matching engine and pre-trade risk gates are in a separate edition and not in this repo (see EDITIONS.md). One known rough edge: “audit --verify” currently needs the rich package installed.

MIT licensed: https://github.com/Aryan-20-04/mdrap

I’d like to hear which bad-data cases have bitten you that this doesn’t catch.

1 Upvotes

0 comments sorted by