Skip to content

Hyperliquid ledger read to the end; a folded funding day's payment count (0.13.0) - #35

Merged
foscomputerservices merged 1 commit into
mainfrom
hyperliquid-funding-pages
Oct 21, 2026
Merged

foscomputerservices merged 1 commit into
mainfrom
hyperliquid-funding-pages

Conversation

@foscomputerservices

Copy link
Copy Markdown
Owner

fosline's ask of 2026-10-20, in David's word: the Hyperliquid funding read stopped at the exchange's 500th item with no sign that more existed, and dropped nSamples.

Established before coding (David's caution: not a testnet quirk). Hyperliquid's documentation, network-neutral: "Responses that take a time range will only return 500 elements or distinct blocks of data. To query larger ranges, use the last returned timestamp as the next startTime for pagination"; userFillsByTime "at most 2000 fills per response". Probed on mainnet's public info endpoint, 2026-10-20: a userFunding from 0 answered exactly 500 of a trader's 969 items, and from the 500th's time the other 469. Funding older than about a week is folded on mainnet exactly as on testnet: one item per coin per day at 00:00:00.000 UTC with nSamples 1–24, null on an hourly payment. The documentation lists nSamples without stating the fold.

Changed

  • ExchangeClientLedgerItem.funding gains payments: Int? = nil, last (breaking for positional patterns, one more _; construction unchanged). Shared, per David's generalize rule: the count the exchange states a summary item sums, nil for one payment.
  • Hyperliquid ledgerItems walks all three windowed reads page by page: a page shorter than the documented cap is the last; a full page is followed from its last item's time (the window is inclusive, so the items already held at that time are dropped); a page adding nothing ends the walk.
  • The funding item's payments is nSamples.
  • OHLCV chains and the behavioral test support take the wider pattern.

Tests: the replay route now honours startTime as the exchange does; new tests cover a two-page funding walk (the boundary item once, later payments kept, the request sequence), a short page read once, a read from a cursor, and a folded day's count against the recording. Hyperliquid, exchange, Kraken, Coinbase and OHLCV suites pass locally.

Noted for David's pen (in the doc comment and CHANGELOG): the fold is relative to the present, so a re-read from a cursor older than a week hands up folded days where an earlier read handed up their payments. The library does not unfold.

CHANGELOG 0.13.0 rides in this PR per CONTRIBUTING; tag the merge commit.

…e end, as the documentation directs (500 items a page, 2000 fills, the next page from the last item's time, the window's repeats dropped); the shared funding item carries payments, the count the exchange states a folded day sums (Hyperliquid's nSamples, null on a payment), confirmed on mainnet and testnet alike 2026-10-20; CHANGELOG 0.13.0
@foscomputerservices
foscomputerservices merged commit 5a9b948 into main Oct 21, 2026
5 checks passed
@foscomputerservices
foscomputerservices deleted the hyperliquid-funding-pages branch October 21, 2026 07:01
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