Run the complete notebook
Open the executed notebook when you want the same workflow with rendered
tables and charts.
Set up the notebook
Clone the example repository, install itsuv environment, and start
JupyterLab:
bounded_rows prevents the tutorial from silently materializing an unbounded
event stream. fetch_events raises if the query crosses the 100,000-row cap so
later summaries never describe a partial sample.
Find a recent active window
The analysis uses 5 seconds of pre-trade reference data and 65 seconds after the analysis window. This buffer lets every trade find an arrival midpoint and 5s, 30s, and 60s forward references within a 5-second tolerance.Inspect normalized and raw trades
Polaris keeps the normalizeddata projection beside the original venue
message in raw. The normalized projection provides consistent price,
quantity, and side fields. Hyperliquid’s venue-native
WsTrade
payload adds the buyer and seller wallets, transaction hash, and trade ID
required for participant attribution.
users as [buyer, seller] and side as the aggressing
side. The workflow preserves full wallet addresses in its DataFrames and
shortens them only for rendered summaries.
Flatten and deduplicate raw trades
One Hyperliquid WebSocket message can contain a batch of trades. Polaris emits one normalized event per trade while retaining the complete original batch on each projection. Flattening everyraw.data array therefore repeats records.
Use (time, coin, tid) as the composite trade identity. Do not deduplicate on
transaction hash because a zero hash can be valid for TWAP fills.
Attach arrival and forward midpoints
Hyperliquid’s rawactiveAssetCtx message contains midPx. Deduplicate repeated
midpoint projections by exchange timestamp and price before joining them to
trades.
For arrival cost, match backward to the latest midpoint observed within the
5-second lookback. For each markout, match forward from the exact horizon
target. Leave unmatched rows missing and report their coverage instead of
inventing a reference price.
Summarize market-level activity
Weight execution cost and markouts by trade notional so a burst of small prints does not dominate the aggregate result:Attribute roles and flow to wallets
Each trade becomes two participant observations: the buyer receives positive signed flow and the seller receives negative signed flow. The aggressing side determines which wallet demanded liquidity and which wallet supplied it.Plot executions and midpoint
Plot raw executions over Hyperliquid’s midpoint. Marker area scales with trade notional and is capped at the 95th percentile so a single large print does not hide the rest of the sample.Plot wallet liquidity roles
Compare the aggressor and passive notional attributed to the largest wallets:Plot the aggregate markout curve
Plot the notional-weighted markout for aggressors at each forward horizon:Interpret the results carefully
- Wallet addresses are public account identifiers, not verified trader identities. One entity can control many wallets, and one wallet can represent a vault or subaccount.
- The raw trade stream supports participant attribution after execution, but it does not expose complete order lifecycles, client order IDs, fees, positions, or realized P&L.
- Markouts describe short-horizon price movement around an execution. They are not portfolio returns and do not include fees, funding, inventory, hedges, or activity in other markets.
- Zero transaction hashes can be valid for TWAP fills. Use
(time, coin, tid), not hash, as the deduplication key. - Results cover a short, dynamically selected public interval. Treat them as a reproducible workflow example, not a persistent ranking of wallets.
Related documentation
- Events for mixed normalized event queries and raw-event behavior
- Event envelope for collector and exchange timestamps
- Catalog for market identity, coverage, and access metadata
- Perpetuals for funding, trade-flow, liquidity, and order-book workflows
- Liquidity / Microstructure for cross-venue spread, slippage, and L2 depth analysis
- Jupyter Notebook for notebook setup and the curated example index