Class QuoteFlyweight
java.lang.Object
com.quantfinlib.sbe.QuoteFlyweight
SBE-style flyweight codec for a two-sided quote message — the outbound
format of a market maker (and the inbound format of venue top-of-book
feeds), completing the binary codec family:
TradeFlyweight (trade
in), OrderFlyweight (order out), quote (two-sided out).
Wire layout (little-endian, 48 bytes):
offset 0 int32 messageType = 3 offset 4 int32 symbolId (dense id shared by both ends) offset 8 double bidPrice offset 16 double bidSize offset 24 double askPrice offset 32 double askSize offset 40 int64 timestampNanos (quote creation time)
One-sided quotes carry NaN on the pulled side — the same convention
fx.AggregatedBook consumes. Like its siblings, the flyweight
holds only the wrap position: reuse a single instance for millions of
messages, zero allocation per encode/decode.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTotal encoded size in bytes.static final intMessage type discriminator at offset 0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleaskPrice()doubleaskSize()doublebidPrice()doublebidSize()encode(int symbolId, double bidPrice, double bidSize, double askPrice, double askSize, long timestampNanos) Encodes a full quote message at the wrap position (writes the type header).intsymbolId()longstatic inttypeAt(ByteBuffer buffer, int offset) Reads the type discriminator without wrapping a flyweight.wrap(ByteBuffer buffer, int offset) Positions this flyweight overbufferatoffset.
-
Field Details
-
MESSAGE_TYPE
public static final int MESSAGE_TYPEMessage type discriminator at offset 0.- See Also:
-
BLOCK_LENGTH
public static final int BLOCK_LENGTHTotal encoded size in bytes.- See Also:
-
-
Constructor Details
-
QuoteFlyweight
public QuoteFlyweight()
-
-
Method Details
-
wrap
Positions this flyweight overbufferatoffset. -
encode
public QuoteFlyweight encode(int symbolId, double bidPrice, double bidSize, double askPrice, double askSize, long timestampNanos) Encodes a full quote message at the wrap position (writes the type header). -
symbolId
public int symbolId() -
bidPrice
public double bidPrice() -
bidSize
public double bidSize() -
askPrice
public double askPrice() -
askSize
public double askSize() -
timestampNanos
public long timestampNanos() -
typeAt
Reads the type discriminator without wrapping a flyweight.
-