hyperliquid-market-data
Read live Hyperliquid market data from the desk computer with curl or the Python SDK - mid, mark and oracle prices, order book depth, funding (current, predicted, historical), open interest, volume, candles, perp and spot metadata, margin tiers, and how to save datasets for the strategy lab. Read-only, no key. Use for any market brief, depth read, funding question or data pull.
Galleon Labs · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add galleonlabs/hypergrok-trading-desk --skill hyperliquid-market-data技能说明
name: hyperliquid-market-data description: Read live Hyperliquid market data from the desk computer with curl or the Python SDK - mid, mark and oracle prices, order book depth, funding (current, predicted, historical), open interest, volume, candles, perp and spot metadata, margin tiers, and how to save datasets for the strategy lab. Read-only, no key. Use for any market brief, depth read, funding question or data pull. license: MIT metadata: version: "1.1.0" author: Galleon Labs category: hyperliquid network-default: mainnet-for-reads
Hyperliquid market data
All reads are POST /info with a JSON body; no key, no signing. Market data is usually read from mainnet even when the desk trades on testnet, because testnet prices and books are thin; say which network a figure came from. Every figure the desk reports carries source (request type), network and UTC time.
BASE=https://api.hyperliquid.xyz # or https://api.hyperliquid-testnet.xyz
hl() { curl -sS -m 15 -X POST "$BASE/info" -H 'Content-Type: application/json' -d "$1"; }
Python header (SDK):
from hyperliquid.info import Info
from hyperliquid.utils import constants
info = Info(constants.MAINNET_API_URL, skip_ws=True) # TESTNET_API_URL for testnet
Prices
hl '{"type":"allMids"}' | jq '{BTC, ETH, SOL}' # mid per coin, strings
allMids falls back to last trade when the book is empty. For mark, oracle and mid together use metaAndAssetCtxs below. Python: info.all_mids().
Market metadata, funding, open interest, volume
hl '{"type":"metaAndAssetCtxs"}' | jq -r '
.[0].universe as $u | .[1] | to_entries[] | . as $e | $u[$e.key] as $m
| select($m.name == "BTC" or $m.name == "ETH" or $m.name == "SOL")
| [$m.name, $e.value.midPx, $e.value.markPx, $e.value.oraclePx, $e.value.funding, $e.value.openInterest, $e.value.dayNtlVlm, $e.value.premium, $m.maxLeverage, $m.szDecimals] | @tsv'
Fields per asset (same order as meta.universe): midPx, markPx, oraclePx, funding (hourly rate as a decimal: 0.0000125 = 0.00125%/h), openInterest (coin units), dayNtlVlm (24h USD volume), premium (impact bid/ask versus oracle, the input to funding), prevDayPx, impactPxs. Universe fields: name, szDecimals, maxLeverage, marginTableId, onlyIsolated/marginMode, isDelisted.
Python: meta, ctxs = info.meta_and_asset_ctxs().
Derived numbers the desk uses (show the formula): OI notional = openInterest x markPx; annualised funding = funding x 24 x 365; 24h change = markPx / prevDayPx - 1.
Margin tiers (max leverage by notional) come from meta:
hl '{"type":"meta"}' | jq --arg c BTC '(.universe[] | select(.name==$c)) as $u | ($u.marginTableId // $u.maxLeverage) as $id
| {name:$u.name, maxLeverage:$u.maxLeverage, marginTableId:$id,
tiers: (if $id < 50 then [{lowerBound:"0.0", maxLeverage:$id}]
else ((.marginTables[] | select(.[0]==$id) | .[1].marginTiers) // [{lowerBound:"0.0", maxLeverage:$u.maxLeverage}]) end)}'
Ids below 50 are single-tier tables whose max leverage equals the id, and they are not listed under marginTables, so the snippet synthesises that tier; ids of 50 and above are looked up.
Order book and depth
hl '{"type":"l2Book","coin":"ETH"}' | jq '{time, bids: .levels[0][:5], asks: .levels[1][:5]}'
Up to 20 levels per side; each level is {px, sz, n} (n = number of orders). Optional nSigFigs (2-5) aggregates price levels; mantissa (1, 2 or 5) only with nSigFigs: 5.
Twenty levels is a page, not the book. On a liquid perp those levels stop a few bps from the mid - around 8 bps on ETH and under 3 bps on BTC at normal spreads - so a 25 bps band summed from the default response is whatever the page happened to contain, not the depth within 25 bps. Read the reach before quoting a band: when the side came back with 20 levels and the furthest one is nearer than the band, the number is a floor. To reach further, re-request with nSigFigs: 4, which buckets prices coarsely enough to push 20 levels out to roughly 20-25 bps on a major perp (measured live: 82 bps ETH, 25 BTC, 24 HYPE, 20 SOL), and drop to nSigFigs: 3 when even that stops short. Read each band off the finest page that reaches it - the coarse page moves the band edges by up to one bucket, and its top of book is not the real one - and say which page a figure came from. scripts/opening_bell.py is that ladder in code.
Depth within a band, the way the Risk Manager and Execution Trader want it:
hl '{"type":"l2Book","coin":"ETH"}' | jq '
(.levels[0][0].px|tonumber) as $bb | (.levels[1][0].px|tonumber) as $ba | (($bb+$ba)/2) as $mid
| def within(side; bps): [side[] | select((((.px|tonumber) - $mid) | fabs) / $mid * 10000 <= bps) | .sz|tonumber] | add // 0;
def reach(side): (((side[-1].px|tonumber) - $mid) | fabs) / $mid * 10000;
{mid: $mid, spread_bps: (($ba-$bb)/$mid*10000),
levels: [(.levels[0]|length), (.levels[1]|length)], reach_bps: [reach(.levels[0]), reach(.levels[1])],
bid_5bps: within(.levels[0]; 5), ask_5bps: within(.levels[1]; 5),
bid_10bps: within(.levels[0]; 10), ask_10bps: within(.levels[1]; 10),
bid_25bps: within(.levels[0]; 25), ask_25bps: within(.levels[1]; 25)}'
reach_bps is the answer's own scope: any band wider than it, on a side that returned 20 levels, is a floor and is quoted as >= size. Two bands reporting the same total is that cut-off, not a flat book.
Expected slippage for a size: walk the relevant side accumulating sz until the target size is reached; report the volume-weighted price versus mid in bps. If the size exceeds the visible 20 levels, say "beyond visible depth". Python: info.l2_snapshot("ETH").
Recent trades: hl '{"type":"recentTrades","coin":"ETH"}' (public prints: px, sz, side, time).
Candles
END=$(date +%s000); START=$((END - 48*3600*1000))
hl "{\"type\":\"candleSnap
阅读完整来源 ↗