Skip to content
zhou.
Forum

N-Lib Release Note v0.4.0

zhouzhouzhouzhouN-Lib27 Aug 2026

v0.4.0 — 2026-08-23

common.h became the whole vocabulary of the feed path: L2 records, the framing, the variants, and the book node. metrics grows from 120 to 136 bytes, so every consumer must be rebuilt together.

  • nlib::level, the L2 record, 48 bytes. qty is the total resting quantity at price, absolute rather than a delta, so a repeated record changes nothing and qty <= 0 removes the level. A feed that publishes aggregated depth needs no order flow to drive a book.
  • The framing moved into the header. order_tag (0), trade_tag (1), and level_tag (2) are declared here, so a publisher and a receiver read the same constants instead of each writing their own.
  • feed_event and record. feed_event is the variant over order, trade, and level — one record as a feed delivers it. record adds book, for a pipeline that stores its own snapshots. overloaded builds the std::visit overload set over either, so a consumer passes one lambda per alternative.
  • nlib::price_level, the node a book builds from these records: the total quantity at one price plus the head and tail of its FIFO order queue. An order-backed (L3) level links its orders through their prev / next hooks and sums their quantities; an aggregate (L2) level keeps head == nullptr and takes qty straight from the feed. Every book in the stack was writing this struct itself.
  • metrics counts levels. feed_levels and writer_levels join the feed and writer counters, which moves every later offset and takes the record from 120 to 136 bytes. The sizeof assert catches a stale consumer at compile time.
  • common_test.cpp covers the tags, both variants, overloaded, and the price_level defaults, so common.h now has a test binary like every container.

v0.3.0 — 2026-08-22

order carries the quantity an action means in its own field. order grows from 72 to 88 bytes, so every consumer must be rebuilt together.

  • cancel_qty and new_qty. A cancel puts the quantity leaving the book in cancel_qty, a modify puts the new remaining quantity in new_qty (<= 0 removes the order); both are 0 for the actions that do not use them. qty keeps one meaning — the resting quantity on an add — so a consumer no longer reads one field against action to learn what it holds.
  • cancel is no longer all-or-nothing. It shrinks the resting order by cancel_qty and the order leaves only when nothing remains, which is what a feed reporting one quantity per event actually sends. A full cancel is the case where cancel_qty is the whole remainder.
  • Both fields are inserted before event_ns, not appended, so every offset from event_ns on has moved. The sizeof asserts catch a stale consumer at compile time.

Comments

Sign in to join the discussion.

No comments yet. Be the first.