Skip to content

feat(cli): native real-time websocket integration with organized output#35

Open
max-de-bug wants to merge 6 commits intoPolymarket:mainfrom
max-de-bug:feature/websocket-connection
Open

feat(cli): native real-time websocket integration with organized output#35
max-de-bug wants to merge 6 commits intoPolymarket:mainfrom
max-de-bug:feature/websocket-connection

Conversation

@max-de-bug
Copy link

@max-de-bug max-de-bug commented Mar 8, 2026

Native Real-Time WebSocket Integration

Summary

Adds the polymarket stream command suite — a native WebSocket client that connects directly to the Polymarket CLOB real-time API (wss://ws-subscriptions-clob.polymarket.com/ws/market) using tokio-tungstenite. No dependency on the SDK's WebSocket module.

Motivation

Users previously had no way to monitor live market activity from the CLI. This feature enables real-time streaming of orderbook depth, price changes, trade executions, and midpoint prices — essential for market-making bots, live dashboards, and manual monitoring workflows.

New Commands

| Command | | Description |
| polymarket stream orderbook <token_ids> | Live bid/ask depth snapshots |
| polymarket stream prices <token_ids> | Real-time price changes (BUY/SELL) |
| polymarket stream last-trade <token_ids> | Trade execution updates |
| polymarket stream midpoints <token_ids> | Continuous midpoint price feeds |

polymatket_cli_wb_video.mp4

Note

Medium Risk
Adds new network-facing WebSocket functionality and several new TLS/WebSocket dependencies, which could introduce runtime/connectivity issues despite being largely isolated from existing command flows.

Overview
Adds a new polymarket stream command family (orderbook, price changes, last trade, midpoints) that opens a native WebSocket connection to Polymarket’s CLOB endpoint, filters events by event_type, supports --max-events, and exits cleanly on Ctrl+C.

Introduces a small ws module to manage subscription and tolerant event parsing (handles single-object vs array frames and skips non-event messages), plus a dedicated output::stream formatter for NDJSON or compact table-style lines. Updates dependencies to include tokio-tungstenite/rustls/futures-util and enables Tokio’s signal feature; adds an example WebSocket test and CLI help/arg coverage in integration tests.

Written by Cursor Bugbot for commit 1de653c. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

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 and found 1 potential issue.

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

@max-de-bug
Copy link
Author

@suhailkakar I’d appreciate your feedback on this feature.

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