Skip to content

docs/resources/portfolio.md says positions_all() does not exist; it has shipped since v2.4 (#269) #319

Closed

Description

@TexasCoding

Problem

The portfolio reference page explicitly tells readers positions_all() does not exist and shows a hand-rolled cursor loop as the workaround. But #269 (v2.4) added positions_all() to both PortfolioResource and AsyncPortfolioResource, and the method is live in v2.6.0. Users following the docs write ~10 lines of cursor boilerplate when the SDK already ships an iterator.

The stale warning also obscures the non-trivial reason event_positions are intentionally dropped from the helper — that rationale is now documented only in the method's docstring.

Evidence

  • docs/resources/portfolio.md:67-80
!!! warning "`positions()` does not return Page[T]"
    It returns `PositionsResponse` — two parallel lists (`market_positions`
    and `event_positions`) plus its own `cursor` and `has_next`. There is no
    `positions_all()` helper. Walk it manually:
  • kalshi/resources/portfolio.py:105-138 — sync positions_all exists
def positions_all(
    self, *,
    limit: int | None = None,
    ...
) -> Iterator[MarketPosition]:
    """Auto-paginate ``/portfolio/positions``, yielding each ``MarketPosition``.
    ...event_positions are *not* surfaced here because page boundaries cut
    the aggregate arbitrarily...
    """
  • kalshi/resources/portfolio.py:327-343 — async counterpart present.
  • CHANGELOG.md:286-288 — v2.4 entry for #269.

Suggested fix

Replace the warning block with an accurate description: positions_all() exists on sync and async resources and yields MarketPosition rows from market_positions only. Lift the event_positions caveat verbatim from PortfolioResource.positions_all's docstring and direct callers wanting the event view to iterate positions() page-by-page.

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