Class QuoteFlyweight

java.lang.Object
com.quantfinlib.sbe.QuoteFlyweight

public final class QuoteFlyweight extends Object
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 Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      Message type discriminator at offset 0.
      See Also:
    • BLOCK_LENGTH

      public static final int BLOCK_LENGTH
      Total encoded size in bytes.
      See Also:
  • Constructor Details

    • QuoteFlyweight

      public QuoteFlyweight()
  • Method Details

    • wrap

      public QuoteFlyweight wrap(ByteBuffer buffer, int offset)
      Positions this flyweight over buffer at offset.
    • 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

      public static int typeAt(ByteBuffer buffer, int offset)
      Reads the type discriminator without wrapping a flyweight.