Skip to content

feat(perps): support 50-level book subscriptions - #379

Open
kartojal wants to merge 2 commits into
mainfrom
fix/perps-book-depth
Open

kartojal wants to merge 2 commits into
mainfrom
fix/perps-book-depth

Conversation

@kartojal

@kartojal kartojal commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Add depth=50 to Perps book subscriptions while retaining the 20-level default. Parse omitted, ::20 and ::50 channel suffixes and route simultaneous depths independently. REST book depth choices are unchanged.

Validation: 81 event and local WebSocket tests passed; Ruff lint/format and Pyright passed. Tests ran offline; channel support does not assert production availability.

Public contract: Perps AsyncAPI.


Note

Low Risk
Experimental perps streaming API extension with backward-compatible defaults; routing changes are scoped to book subscriptions and covered by unit tests.

Overview
Adds optional 50-level Perps order book streaming via PerpsBookSpec(depth=50); default remains 20 levels with no behavior change for existing callers.

Subscription wiring now emits book::{id}::50 when depth is 50 (20-level stays book::{id}), and book event routing is explicit: match_for(PerpsBookSpec) delivers only the subscribed depth—50-level specs ignore 20-level channels, while 20-level specs accept unsuffixed channels and ::20 but not ::50. Incoming frames parse book::{id}, book::{id}::20, and book::{id}::50 via an updated channel regex.

Tests cover subscribe/unsubscribe channel names, independent depth routing, parsing, and invalid depth values.

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

@kartojal
kartojal marked this pull request as ready for review October 26, 2026 13:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3e5d4ba. Configure here.

Comment thread src/polymarket/streams/_specs.py Outdated

This branch has not been deployed

No deployments
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.

1 participant