Skip to content

fix(hyperliquid): honor marketId/eventId filters and OHLCV/trades limit - #1254

Merged
realfishsam merged 1 commit into
mainfrom
fix/hl-marketid-eventid-filters-and-limits
Jun 21, 2026
Merged

fix(hyperliquid): honor marketId/eventId filters and OHLCV/trades limit#1254
realfishsam merged 1 commit into
mainfrom
fix/hl-marketid-eventid-filters-and-limits

Conversation

@realfishsam

Copy link
Copy Markdown
Contributor

Summary

Assertion-based SDK verification surfaced 4 silent HL bugs the prior "did it throw" matrix missed:

Bug Before After
fetchMarket(marketId=X) returned the first market fetchRawMarkets ignored params.marketId filter applied via fromMarketId (accepts canonical id or outcome token)
fetchEvent(eventId=X) returned the first event fetchRawEvents ignored params.eventId filter applied
fetchMarkets(eventId=X) not filtered also ignored filter applied
fetchOHLCV(..., limit=N) returned full window fetchRawOHLCV didn't slice client-side trim (most recent N)
fetchTrades(..., limit=N) returned fixed page fetchRawTrades didn't slice client-side trim

Limit slicing happens client-side because HL's candleSnapshot and recentTrades both return a fixed window/page.

Verified locally (both SDKs)

Before fix: Python 41/45, TS 42/45.
After fix: Python 45/45, TS 45/45.

Test script asserts behavioral properties (id round-trips, monotonic timestamps, OHLC sanity, length bounds, no crossed book, etc.) — not just "call didn't throw".

Followup worth doing

Mirror this verify pattern for the other venues. The 'did it throw' matrix style hid HL's hardcoded volume24h: 0 for months and would hide the same class of bug elsewhere.

HL fetcher silently ignored four filters that the unified API contract
promises:

- fetchRawMarkets ignored params.marketId — fetchMarket(marketId=X)
  returned the first market in the venue list instead of X
- fetchRawMarkets / fetchRawEvents ignored params.eventId — fetchEvent
  always returned the first question
- fetchRawOHLCV ignored params.limit — returned the entire window
- fetchRawTrades ignored params.limit — returned a fixed page

These all passed the prior smoke matrix because it only checked
'did the call throw'. The new assertion-based verify suite catches
each one (45/45 pass after fix, both SDKs).

marketId filter uses fromMarketId so it accepts either canonical
hl-outcome-{N} or a raw outcome token, matching the resolution we
added for fetchOrderBook / fetchOHLCV / fetchTrades single-fetch.

Limit slicing is client-side after the venue call returns, since HL's
candleSnapshot and recentTrades both return a fixed window/page.
@realfishsam
realfishsam merged commit 9751080 into main Jun 21, 2026
7 of 12 checks passed
@realfishsam
realfishsam deleted the fix/hl-marketid-eventid-filters-and-limits branch June 21, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant