Trading API & SDK · SDK Setup & Authentication · 3/8
Read Market Data Challenge
Test your knowledge of Hyperliquid market data structures and the Info API. These questions cover order book parsing, position data extraction, and funding rate calculations.
1. In Hyperliquid's L2 order book snapshot, how are bids and asks organized in the `levels` array?
In the Hyperliquid L2 snapshot, levels[0] contains bids and levels[1] contains asks. Each level is an object with "px" (price) and "sz" (size) as strings, plus "n" (number of orders).
2. What is the correct way to calculate spread in basis points from an order book?
Spread in basis points is calculated as (best_ask - best_bid) / mid_price * 10000, where mid_price = (best_bid + best_ask) / 2.
3. In the Hyperliquid user state, how do you determine if a position is long or short?
The "szi" (signed size) field determines the side: positive values mean long, negative values mean short. There is no explicit "side" field.
4. How do you convert an hourly funding rate of 0.0001 (0.01%) to an annualized percentage rate (APR)?
APR = hourly_rate * 24 (hours/day) * 365 (days/year) * 100 (to percentage). So 0.0001 * 24 * 365 * 100 = 87.6%.
5. What fields does each entry in the `assetPositions` array contain for accessing position data?
Each entry in assetPositions has a nested "position" object containing "coin", "szi" (signed size), "entryPx" (entry price), and "unrealizedPnl". All numeric values are strings that need to be converted to floats.