paginate_trades

Defined in dccd.transport.paginate

async paginate_trades(fetch_page, cap, start_ns, end_ns, *, emit_progress=None, max_pages=1000000)[source]

Paginate trades by cursor, draining the [start_ns, end_ns] window.

Unlike OHLC (fixed-size time windows), trades are far denser than any single page: a one-day window on a liquid pair holds millions of trades but a page is capped at cap.max_per_request. Advancing by a fixed time window — the previous design — silently dropped everything past the first page. This paginator instead follows the adapter’s opaque cursor until the window is exhausted.

Parameters:
fetch_pageasync callable

Closure with symbol bound: fetch_page(start_ns, end_ns, limit, cursor) -> (items, next_cursor). cursor is None on the first call.

capCapability

Source capability (provides max_per_request).

start_ns, end_nsint

Inclusive time range in nanoseconds. Items outside it are filtered out.

emit_progresscallable or None

Called with (pages_done, -1) after each page (total is unknown).

max_pagesint

Hard safety cap on the number of pages, to bound a misbehaving cursor.