Book Building
Events can arrive before the snapshot.
- Buffer
md_event_detailmessages. - Load the
snapshotas your book. - Drop buffered events with
seq_numat or belowlatest_seq_num. - Apply the rest in
seq_numorder.
See Message Details for the snapshot and md_event_detail fields.
Example: an XA event
Section titled “Example: an XA event”This example, for XA (see Enums), shows an event detail for a GTC order that trades immediately and then rests its remaining qty. The trade and the remaining resting qty added to the book are reported in one event detail message. Its qty fields are relative to the maker side in the trade (event_side), so the rested qty counts as removed from that side. As a result, the level’s final qty, if computed by event_level_begin_qty + event_level_delta_qty, appears negative. This simply means that the level changed sides: the GTC’s remaining qty now rests there as an opposite-side order (i.e. opposite side to the maker in the trade).
For a simpler and more common event detail, see the example in Message Details.
Book before
Section titled “Book before”| Side | Price | Qty |
|---|---|---|
| Ask | 100,015 | 4,500 |
| Ask | 100,012 | 3,000 |
| Ask | 100,010 | 2,000 |
| Bid | 100,000 | 8,000 |
| Bid | 99,998 | 2,500 |
| Bid | 99,995 | 5,000 |
In this example, a GTC buy of 6,000 qty at 100,012 ticks takes 2,000 qty at 100,010 ticks and 3,000 qty at 100,012 ticks, then rests its remaining 1,000 qty at 100,012 ticks. This entire multi-level trade and rest is communicated in one md_event_detail message, with event_type LIQ_RMD and event_qual XA:
{ "type": "md_event_detail", "data": { "tob": { "ask_qty": "4500", "bid_qty": "1000", "ask_ticks": 100015, "bid_ticks": 100012 }, "data": { "event_type": 2, "event_qual": 4, "event_side": 1, "event_delta_qty": "-6000", "event_abs_ticks": 100012, "event_tick_depth": 2, "event_level_depth": 1, "event_level_begin_qty": "3000", "event_level_delta_qty": "-4000", "event_total_px": "-400044000", "seq_num": "3" }, "order": { "side": 2, "market_id": "1", "qty": "6000", "ticks": 100012, "tif": 2, "origin": 1 } }}| Field | Value | Meaning |
|---|---|---|
event_type |
LIQ_RMD | Event type. See Enums. |
event_qual |
XA | Event qualifier, on LIQ_RMD only. See Enums. |
event_side |
ASK | Side modified; for EX and XA, the maker side in the trade. |
event_delta_qty |
−6,000 | Total quantity change in the event [1]. |
event_abs_ticks |
100,012 | Deepest price touched by the event. |
event_tick_depth |
2 | Ticks from the previous best price. |
event_level_depth [3] |
1 | Levels deep into the book, zero-indexed. |
event_level_begin_qty [3] |
3,000 | Pre-event quantity on the deepest level modified by the event. |
event_level_delta_qty [3] |
−4,000 | Quantity change on the deepest level modified by the event. |
event_total_px |
−400,044,000 | Sum of quantity × ticks over the levels touched [2]. |
Note 1. For XA events, event_delta_qty is negative because the reference side is the maker side; its absolute value in qty units is the qty traded plus the qty rested, here 5,000 + 1,000.
Note 2. For XA events, event_total_px is value rested minus value traded, here 1,000 × 100,012 − (2,000 × 100,010 + 3,000 × 100,012).
Note 3. event_level_* fields are relative to event_side. For an event that trades (EX or XA), event_side is the maker side, here ASK. event_level_delta_qty is negative because liquidity was removed from that side; begin qty + delta qty below zero means the level changed from its previous side (here from ASK to BID) and the remainder rests, here 1,000 qty rests as a BID.
Book after
Section titled “Book after”| Side | Price | Qty |
|---|---|---|
| Ask | 100,015 | 4,500 |
| Bid | 100,012 | 1,000 |
| Bid | 100,000 | 8,000 |
| Bid | 99,998 | 2,500 |
| Bid | 99,995 | 5,000 |
Regulated services provided by 1Money USA, Inc., a licensed money transmitter, NMLS ID 2628653 · Licenses