Class ItchCodec
Decoding is a flyweight: ItchCodec.View.wrap(byte[], int) points at a message inside a
caller-owned buffer and every getter reads the bytes directly — no parsing
step, no objects, zero allocation. Symbols travel as a long of 8
ASCII bytes (packStock(java.lang.String)) so the hot path never touches
String.
Prices are unsigned 32-bit integers with four implied decimals — i.e.
the raw value is the price in 0.0001 ticks, which plugs straight
into tick-indexed books like L3BookBuilder. Domain limit:
this library's tick-indexed pipeline is signed-int throughout, so
prices above 2³¹−1 ticks ($214,748.36) decode negative and are dropped by
band checks downstream — symbols above that price (BRK.A territory) need
a coarser tick or a scaled feed, the same constraint as
HftOrderBook's ladder.
Encoders exist for simulators, replay tooling and tests; a production participant only decodes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classMutable flyweight over one message in a caller-owned buffer. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intencodeAdd(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, byte side, long shares, long packedStock, int priceTick) Encodes an Add Order (A); returns bytes written.static intencodeCancel(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, long cancelledShares) Encodes an Order Cancel (X, partial cancel); returns bytes written.static intencodeDelete(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef) Encodes an Order Delete (D); returns bytes written.static intencodeExecuted(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, long executedShares, long matchNumber) Encodes an Order Executed (E); returns bytes written.static intencodeReplace(byte[] buf, int off, int stockLocate, long timestampNanos, long origRef, long newRef, long shares, int priceTick) Encodes an Order Replace (U); returns bytes written.static intencodeTrade(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, byte side, long shares, long packedStock, int priceTick, long matchNumber) Encodes a non-cross Trade (P); returns bytes written.static intlength(byte type) Wire length of a message type; -1 for types outside the subset.static longPacks up to 8 ASCII chars into a big-endian long, space-padded (ITCH alpha style).static StringunpackStock(long packed) Inverse ofpackStock(java.lang.String): trailing spaces stripped.
-
Field Details
-
ADD
public static final byte ADD- See Also:
-
ADD_MPID
public static final byte ADD_MPID- See Also:
-
EXECUTED
public static final byte EXECUTED- See Also:
-
CANCEL
public static final byte CANCEL- See Also:
-
DELETE
public static final byte DELETE- See Also:
-
REPLACE
public static final byte REPLACE- See Also:
-
TRADE
public static final byte TRADE- See Also:
-
BUY
public static final byte BUY- See Also:
-
SELL
public static final byte SELL- See Also:
-
-
Method Details
-
length
public static int length(byte type) Wire length of a message type; -1 for types outside the subset. -
packStock
Packs up to 8 ASCII chars into a big-endian long, space-padded (ITCH alpha style). -
unpackStock
Inverse ofpackStock(java.lang.String): trailing spaces stripped. Test/logging use only. -
encodeAdd
public static int encodeAdd(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, byte side, long shares, long packedStock, int priceTick) Encodes an Add Order (A); returns bytes written. -
encodeExecuted
public static int encodeExecuted(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, long executedShares, long matchNumber) Encodes an Order Executed (E); returns bytes written. -
encodeCancel
public static int encodeCancel(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, long cancelledShares) Encodes an Order Cancel (X, partial cancel); returns bytes written. -
encodeDelete
public static int encodeDelete(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef) Encodes an Order Delete (D); returns bytes written. -
encodeReplace
public static int encodeReplace(byte[] buf, int off, int stockLocate, long timestampNanos, long origRef, long newRef, long shares, int priceTick) Encodes an Order Replace (U); returns bytes written. -
encodeTrade
public static int encodeTrade(byte[] buf, int off, int stockLocate, long timestampNanos, long orderRef, byte side, long shares, long packedStock, int priceTick, long matchNumber) Encodes a non-cross Trade (P); returns bytes written.
-