Skip to content

Async positions_all omits the event_positions caveat present on the sync docstring #337

Closed

Description

@TexasCoding

Problem

PortfolioResource.positions_all (sync) carries a multi-line docstring explaining that the helper deliberately does not surface event_positions aggregates because page boundaries make concatenated event-level totals meaningless, and pointing callers at iterating positions() page-by-page if they need that view.

AsyncPortfolioResource.positions_all is a one-liner that only says "Async counterpart of PortfolioResource.positions_all." An async caller using IDE hover, help(client.portfolio.positions_all), or Sphinx-rendered docs sees no warning, assumes event_positions are returned alongside (the underlying endpoint does return them), and silently builds dashboards missing event-level exposure aggregates. Same risk class as the docstring drift the changelog flagged in #299.

Evidence

  • kalshi/resources/portfolio.py:115-124 (sync — has the caveat):
) -> Iterator[MarketPosition]:
    """Auto-paginate ``/portfolio/positions``, yielding each ``MarketPosition``.

    Mirrors :meth:`settlements_all`. The endpoint response also carries
    ``event_positions`` (aggregate roll-ups over the same underlying
    markets); those are *not* surfaced here because page boundaries cut
    the aggregate arbitrarily and concatenating across pages would not
    recompute a meaningful event-level total. Callers that need the
    event view should iterate :meth:`positions` page-by-page.
    """
  • kalshi/resources/portfolio.py:337-338 (async — one-liner):
) -> AsyncIterator[MarketPosition]:
    """Async counterpart of :meth:`PortfolioResource.positions_all`. Use ``async for``."""

Suggested fix

Either change the async docstring to a cross-reference Sphinx can resolve (e.g. See :meth:\PortfolioResource.positions_all` for the event_positions caveat and the page-by-page workaround.) so the full prose renders on the async page, or duplicate the event_positionsparagraph verbatim. The same pattern already used byamend_v2/decrease_v2` keeps both sides in sync.

Source

Round-3 independent audit (reviewer: sync_async_parity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions