BANGER
Product status: Banger’s public beta is paper-only. References to live execution are future-looking. Venue rules and legal claims can change; verify current primary sources for your jurisdiction.
2026-11-17 · 6 min read · facts as of 2026-11-17

Audit Pagination in a Market-History Download

If you pull historical trades or markets and silently drop pages, every backtest downstream inherits the gap. The general pipeline design lives in our how-to-build-a-prediction-market-data-pipeline post. This one is narrower: a download audit you can run on each paginated pull that records page identity, confirms the first and last observation on every page, checks for overlap between pages, and stops on an explicit condition instead of a guessed one.

Verify the venue's pagination before you assume it

Do not assume offset or page-number semantics. Kalshi's list endpoints are cursor-based. The documented contract is to make the first request without a cursor, read the cursor field from the response, and pass that value as the cursor query parameter on the next request.

Kalshi's pagination guide covers cursor-based pagination for list endpoints including Get Markets, Get Events, and Get Series. The individual endpoint reference pages confirm cursor pagination for Get Trades, Get Historical Trades, Get Historical Fills, and Get Orders as well. Page size is controlled by a limit parameter. The documented behavior differs by endpoint, so read the specific reference page for the endpoint you are calling rather than copying a limit from a different one.

For Get Trades specifically, the official reference states the endpoint returns a paginated response, that limit controls page size up to 1000 (defaulting to 100), and documents two behaviors that matter for an audit: a cursor that cannot be decoded is ignored and the first page is returned, so you must pass the cursor back exactly as received; and min_ts and max_ts must be in seconds, with millisecond values rejected as a 400 bad_request. If you build a stopping condition around a time window, those timestamp units are part of the contract.

The stopping condition is an explicit rule, not a vibe

The documented terminator for Kalshi cursor pagination is the cursor itself. Continue requesting until the cursor comes back null, empty, or missing. The Get Trades reference states plainly that an empty cursor indicates no more pages are available. Encode exactly that, and nothing clever:

cursor = None
pages = 0
MAX_PAGES = 5000   # hard ceiling so a bug can't loop forever

while True:
    params = {"limit": 100}
    if cursor:
        params["cursor"] = cursor

    resp = get(url, params=params)      # your HTTP call
    page = resp.json()

    yield page
    pages += 1

    cursor = page.get("cursor")         # Kalshi returns next cursor here
    if not cursor:                      # empty/missing => done, per docs
        break
    if pages >= MAX_PAGES:              # audit guard, not the real end
        raise RuntimeError("page ceiling hit: investigate before trusting data")

The MAX_PAGES guard is not a substitute for the cursor check. It is a tripwire. If you hit it, a response shape changed or you are re-requesting the same page, and you want a loud failure, not a truncated dataset that looks complete.

Record page identity on every request

Page identity is the metadata that lets you prove, after the fact, which request produced which rows. For each page, log at minimum:

Storing the sent cursor and the received cursor side by side catches the most common silent failure: a cursor that was not decoded, so the venue returned page 0 again. The Get Trades docs describe exactly that fallback for an undecodable cursor, which is why the sent/received pair is worth recording.

Overlap and gap checks between adjacent pages

Cursor pagination over a time-ordered feed should produce pages that abut without overlapping. With Kalshi trades sorted by created_time, two checks cover most corruption:

Keep these as assertions that halt the pull, not warnings you scroll past. A download that fails loudly on page 40 is cheaper than a backtest you have to retract. Preserve anything you cannot explain rather than smoothing it over; an unexplained gap is a finding, not noise to delete.

Use exact arithmetic for prices and identity keys

Prices and any derived identity keys should not pass through binary float. Python's decimal module is built for this: the standard library documentation notes that decimal numbers can be represented exactly, that the exactness carries over into arithmetic, and gives the example that 0.1 + 0.1 + 0.1 - 0.3 is exactly zero in decimal. That is the property you want when comparing or hashing price fields across pages, so parse price strings straight into Decimal and never round-trip them through float.

Where a paper sandbox fits

An audited download is input. What you do with it is a separate question. Banger is a paper-research beta for prediction-market strategies: you can write a Python strategy or clone one, inspect versioned historical backtests, and run bounded paper experiments. Its hosted historical backtesting currently supports Kalshi binary markets. Public live deployments and local --live are blocked, so nothing here places a real order. Treat a paper result as evidence under a specific data, fill, fee, and valuation model, not proof of real venue execution. A clean pagination audit makes that evidence worth more, because the backtest is reading a dataset you have actually verified is complete.

Checklist

Primary source for the pagination contract: the Kalshi pagination guide at docs.kalshi.com/getting_started/pagination. Reverify it at the time you build, since endpoint limits and behaviors change. If you want to take an audited Kalshi dataset into bounded paper experiments, you can explore paper research via /sign-up. No fills, returns, or live execution are implied.

Sources

Keep reading

Run your first strategy free

Paper-trade on Polymarket and Kalshi market data without venue keys.

Start free