From dcceea34010fda602f9fdffdf7e25cd55943b0f9 Mon Sep 17 00:00:00 2001 From: massimiliano1991 Date: Mon, 10 Aug 2026 03:23:28 +0200 Subject: [PATCH] docs: spot_meta_and_asset_ctxs returns two non-parallel lists universe (324) and assetCtxs (715) are not parallel; pair them through the universe entry's own `index` field. Positions 0-70 line up, which hides the mismatch during casual testing and returns another asset's prices past that point. The perp sibling meta_and_asset_ctxs() IS parallel, so the intuition does not carry over. Docstring only, no behaviour change. Closes #308. --- hyperliquid/info.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hyperliquid/info.py b/hyperliquid/info.py index 360d0588..d9dafb3d 100644 --- a/hyperliquid/info.py +++ b/hyperliquid/info.py @@ -359,7 +359,29 @@ def spot_meta(self) -> SpotMeta: def spot_meta_and_asset_ctxs(self) -> SpotMetaAndAssetCtxs: """Retrieve exchange spot asset contexts + POST /info + + Note: + The two returned lists are NOT parallel. Pair a universe entry with its context + through the entry's own `index` field, never through its position: + + meta, ctxs = info.spot_meta_and_asset_ctxs() + ctx = ctxs[entry["index"]] # correct + ctx = ctxs[i] # wrong for i >= 71 + + On mainnet (2026-08-10) `universe` has 324 entries and `assetCtxs` has 715. + Positions 0-70 happen to line up, so zipping the two looks correct on every asset + you are likely to eyeball, and returns another asset's prices past that point: + at position 71 (`@72`) zipping gives markPx 1.0 where the asset's own context + says 0.72847. + + Note this differs from `meta_and_asset_ctxs()` (perps), where the two lists ARE + parallel and the asset id IS the list position. This class already encodes the + distinction in `__init__` — perps use `enumerate(...)`, spot uses + `spot_info["index"] + 10000` — so carrying the perp intuition over to spot is + the mistake this note exists to prevent. + Returns: [ {