Skip to content

docs: clarify market stream and orderbook fields#45

Merged
cesarenaldi merged 1 commit into
mainfrom
feature/dev-135-document-python-sdk-orderbook-sorting-and-market-stream
May 26, 2026
Merged

docs: clarify market stream and orderbook fields#45
cesarenaldi merged 1 commit into
mainfrom
feature/dev-135-document-python-sdk-orderbook-sorting-and-market-stream

Conversation

@cesarenaldi
Copy link
Copy Markdown
Collaborator

@cesarenaldi cesarenaldi commented May 26, 2026

Summary

  • Document OrderBook bids and asks sort order.
  • Clarify that MarketSpec custom_feature_enabled enables best bid/ask plus market lifecycle events.

Verification

  • uv run ruff check src/polymarket/models/clob/order_book.py src/polymarket/streams/_specs.py
  • uv run pyright src/polymarket/models/clob/order_book.py src/polymarket/streams/_specs.py

Linear: DEV-135
Closes #42
Closes #43


Note

Low Risk
Comment-only changes with no runtime, API, or security impact.

Overview
Documentation-only updates so consumers interpret CLOB data and market subscriptions correctly.

OrderBook now documents that bids are sorted ascending (lowest bid first) and asks descending (highest ask first), which matters when reading top-of-book from full book snapshots.

MarketSpec docstrings clarify that token_ids selects which tokens receive events, and that custom_feature_enabled=True also enables MarketBestBidAskEvent, NewMarketEvent, and MarketResolvedEvent on top of the default market stream behavior.

Reviewed by Cursor Bugbot for commit cb5fc33. Bugbot is set up for automated code reviews on this repo. Configure here.

@Nexory
Copy link
Copy Markdown

Nexory commented May 26, 2026

Looks great — both pieces land in the right place. A couple of observations:

  1. Putting the custom_feature_enabled docs on MarketSpec (the public surface) is actually clearer than the ClobMarketStreamManager.subscribe() spot I suggested in docs: clarify what custom_feature_enabled gates on ClobMarketStreamManager.subscribe #43, since that's what users construct directly.

  2. The event list (MarketBestBidAskEvent, NewMarketEvent, MarketResolvedEvent) matches match_for in _internal/streams/clob/market_protocol.py:91-108 exactly. tick_size_change / last_trade_price are correctly omitted because those fire regardless of the flag.

  3. The OrderBook field docstrings line up 1:1 with what the live API returns (verified against an active high-volume market: 60 ask levels in descending order, 8 bid levels in ascending order).

LGTM to proceed.

@cesarenaldi cesarenaldi merged commit ae23142 into main May 26, 2026
7 checks passed
@cesarenaldi cesarenaldi deleted the feature/dev-135-document-python-sdk-orderbook-sorting-and-market-stream branch May 26, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: clarify what custom_feature_enabled gates on ClobMarketStreamManager.subscribe docs: document OrderBook.bids/asks sort convention

2 participants