Skip to main content

Overview

Last ID (LI) is a sequence number Pacifica stamps on exchange events. It increases monotonically within a symbol (and within an account or order), so you can order updates, detect gaps, and correlate effects of the same event across streams. It is not a timestamp, so it is unaffected by clock drift. It is the li field on WebSocket messages and snapshot rows, and the last_order_id key on REST snapshot responses.

Usage

  • Order events and detect gaps within the same symbol, account, or order — a larger LI is strictly later.
  • Correlate effects of one event: a trade, its order update, and the resulting position change share the same LI.
  • Compare LI only within the same symbol/account/order — not across them.

Snapshots

Snapshot responses carry LI on each row (the latest event for that position or order; null for rows the engine has not touched yet) and once on the envelope — last_order_id (REST) or the outer li (WebSocket account_positions) — for the whole set. The envelope advances on closes and labels an empty set. On reconnect, treat the snapshot as your baseline: replace local state with it, apply live snapshots with an equal or newer LI, and discard older ones.

Where it appears