Class Nbbo
java.lang.Object
com.quantfinlib.marketdata.Nbbo
National Best Bid and Offer: aggregates per-venue top-of-book quotes for
one symbol into the consolidated best bid/ask, the size available at those
prices, and a bitmask of which venues are at the inside — the three inputs
a smart order router actually consumes. The equities counterpart of
fx.AggregatedBook, in integer ticks.
Zero allocation per update; single-writer (one consolidated-feed thread). Recomputation is a linear scan over venues — with the ≤ 64 venues of a real consolidated tape, a branch-predictable scan over four parallel arrays beats any incremental structure.
An optional Nbbo.Listener fires only when the NBBO actually changes
(price or size at the inside), so downstream logic is naturally conflated
to inside-quote updates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFired after the NBBO (price or inside size) changes. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongaskSize()Total displayed size at the national best offer, across venues.intaskTick()National best offer in ticks;NO_ASKwhen no venue offers.longBitmask of venues quoting at the national best offer.longbidSize()Total displayed size at the national best bid, across venues.intbidTick()National best bid in ticks;NO_BIDwhen no venue bids.longBitmask of venues quoting at the national best bid (bit v = venue v).longUpdates that moved the inside (price or size) — the conflation ratio.booleancrossed()Crossed market flag (NBB above NBO — locked/crossed tape condition).voidInstalls the (single) inside-change callback.booleanlocked()Locked market flag (NBB equal to NBO).doublemidTick()Mid in tick units, NaN when either side is absent.booleanonVenueDown(int venue, long timestampNanos) Removes a venue's quotes (feed loss / venue halt).booleanonVenueQuote(int venue, int bid, long bidSz, int ask, long askSz, long timestampNanos) One venue's new top of book.long
-
Field Details
-
NO_BID
public static final int NO_BID- See Also:
-
NO_ASK
public static final int NO_ASK- See Also:
-
-
Constructor Details
-
Nbbo
public Nbbo(int venueCount) - Parameters:
venueCount- number of venues (≤ 64, so venue sets fit one bitmask)
-
-
Method Details
-
listener
Installs the (single) inside-change callback. -
onVenueQuote
public boolean onVenueQuote(int venue, int bid, long bidSz, int ask, long askSz, long timestampNanos) One venue's new top of book. PassNO_BID/NO_ASK(or zero sizes) for an empty side; useonVenueDown(int, long)when the venue drops entirely. Returns true when the NBBO changed. -
onVenueDown
public boolean onVenueDown(int venue, long timestampNanos) Removes a venue's quotes (feed loss / venue halt). Returns true on NBBO change. -
bidTick
public int bidTick()National best bid in ticks;NO_BIDwhen no venue bids. -
bidSize
public long bidSize()Total displayed size at the national best bid, across venues. -
askTick
public int askTick()National best offer in ticks;NO_ASKwhen no venue offers. -
askSize
public long askSize()Total displayed size at the national best offer, across venues. -
bidVenues
public long bidVenues()Bitmask of venues quoting at the national best bid (bit v = venue v). -
askVenues
public long askVenues()Bitmask of venues quoting at the national best offer. -
crossed
public boolean crossed()Crossed market flag (NBB above NBO — locked/crossed tape condition). -
locked
public boolean locked()Locked market flag (NBB equal to NBO). -
midTick
public double midTick()Mid in tick units, NaN when either side is absent. -
updateCount
public long updateCount() -
changeCount
public long changeCount()Updates that moved the inside (price or size) — the conflation ratio.
-