Repository navigation
fix(trade): keep rows sharing an id when paging history executions and orders - #634
Open
hogan-yuan wants to merge 2 commits into
Open
hogan-yuan wants to merge 2 commits into
hogan-yuan wants to merge 2 commits into
Conversation
…d orders history_executions and history_orders deduplicated every row by trade_id / order_id alone, including rows within a single page, so executions or orders reported under one id (e.g. the legs of a multi-leg order) collapsed into the first one. Keep every row of a page and only drop rows a later page repeats from an earlier one, keyed by (order_id, trade_id, symbol) for executions and (order_id, symbol) for orders. Both methods now share fetch_all_pages, which still stops when a page adds nothing new.
…repetition Keying the cross-page dedup on the same id the previous commit kept within a page made the result depend on where the page boundary fell. Return every row as sent and only stop when a page repeats the previous one exactly (same keys, same order), which is the gateway-ignores-page case the dedup guarded against. Keys are computed once per row.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
history_executionsandhistory_orders(paging added in #591 / #627) dedupe every row bytrade_id/order_idalone — including rows on the same page. Any rows the server returns under one id collapse into the first one, silently.What changes
pageand answers every request with page 1 — is kept in a different form: paging stops when a page repeats the previous page exactly (same(order_id, trade_id, symbol)/(order_id, symbol)sequence). It also stops on an empty page, whenhas_moreis false, or after 1000 pages.fetch_all_pages.Return types are unchanged, so no binding needed touching.
Trade-off
A later page that partially overlaps an earlier one (e.g. rows shifting between requests) is no longer deduplicated. With these history endpoints the window is fixed by
start_at/end_at, so this should not occur; I chose not to drop rows over a hypothetical overlap.What I could not verify
I have not observed the gateway returning two rows with the same
trade_id/order_id; multi-leg orders are the obvious candidate. If ids are always unique, the result is identical to today.Tests
fetch_all_pages_tests: same-key rows kept within a page and across a page boundary,has_morepaging, a gateway ignoringpagestops after page 2, an empty page stops.🤖 Generated with Claude Code