<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw" -->

---
title: Building a Limit Order Book Lab Where the Only Verified...
description: A walkthrough of flowbook, a project combining a C++17 matching engine (exposed via pybind11), market-making strategies, and a from-scratch attention model for...
canonical: https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a Limit Order Book Lab Where the Only Verified Claim Is the Gradient Check | daily.dev
og:description: A walkthrough of flowbook, a project combining a C++17 matching engine (exposed via pybind11), market-making strategies, and a from-scratch attention model for...
og:url: https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw
og:image: https://api.daily.dev/og/posts/HgpIHIChW.png
og:image:alt: Building a Limit Order Book Lab Where the Only Verified Claim Is the Gradient Check
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Limit Order Book Lab Where the Only Verified Claim Is the Gradient Check

**[Medium](https://daily.dev/sources/medium_js)** · 11 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of flowbook, a project combining a C++17 matching engine (exposed via pybind11), market-making strategies, and a from-scratch attention model for order-book direction prediction. The engine uses price-time priority with lazy cancellation and a lock-free SPSC ring buffer for concurrency. Two bugs are documented in detail: a sign error in microprice calculation and a fill-tracking failure for resting quotes. The test suite covers 34 tests including a multi-threaded ring buffer stress test and gradient checks via central finite differences. Performance benchmarks are measured at the pybind11 boundary. The author is candid that the ML model's gradient implementation is verified but out-of-sample classification accuracy barely exceeds the majority-class baseline, and explains why that outcome is expected rather than a failure.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@yusra.faheem_19947/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-6549687cae50>

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building a Limit Order Book Lab Where the Only Verified Claim Is the Gradient Check","url":"https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw"},"datePublished":"2026-07-22T13:34:28.356Z","dateModified":"2026-07-22T13:35:12.724Z","description":"A walkthrough of flowbook, a project combining a C++17 matching engine (exposed via pybind11), market-making strategies, and a from-scratch attention model for...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d6ab0a9a223ee01bc82d647f54feb2d2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d6ab0a9a223ee01bc82d647f54feb2d2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-a-limit-order-book-lab-where-the-only-verified-claim-is-the-gradient-check-hgpihichw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Building a Limit Order Book Lab Where the Only Verified Claim Is the Gradient Check"}]}
```

