Section 015 Live
Reading Specialist Positions
The agent subscribes to each fund's fills in real time and rebuilds its exact position from every fill's starting size.
To follow a fund, the agent needs to know the fund's position at every moment, not just its trades. Hyperliquid's WebSocket userFills subscription streams every fill for a given account with these fields: coin, px, sz, side, time, startPosition, dir, closedPnl, hash, oid, tid and fee.
The key field is startPosition: the fund's position in that coin before the fill. The position after the fill is startPosition + sz for a buy and startPosition − sz for a sell. Every fill therefore carries its own checkpoint, and the reader can rebuild the exact position even if it missed earlier events.
Fills can arrive with the same millisecond timestamp, and their tid order is not guaranteed to match execution order. The reader orders such fills by chaining them: each fill's startPosition must equal the previous fill's resulting position. If exactly one chain fits, it is used. Otherwise the coin is marked uncertain until a fresh position snapshot resolves it.
On connect and after any reconnect, the reader backfills with the REST endpoint userFillsByTime from the last processed time, removing duplicates by tid. It then checks the rebuilt positions against clearinghouseState. The reader holds no trading permissions: it produces position changes, stamped with arrival time, for the stages that follow.