Skip to content

Conversation

@opalo1992
Copy link

@opalo1992 opalo1992 commented Dec 5, 2025

Summary

This PR introduces a new method subscribeMarketTradesEvents that enables
real-time market trade event streaming using Server-Sent Events (SSE).

Motivation

The current client only provides getMarketTradesEvents, which requires
polling. SSE provides lower latency, reduced server load, and improved UX for
trading bots and real-time dashboards.

Implementation details

  • Added subscribeMarketTradesEvents method with browser/Node support.
  • Implemented SSE streaming with graceful error handling.
  • Added Node polyfill eventsource.
  • Added import of isBrowser from browser-or-node.
  • No breaking changes.

Testing

Manual testing via browser and Node environments confirms correct message
streaming and reconnection behavior.


Note

Introduce subscribeMarketTradesEvents for real-time market trades via SSE with browser/Node support; add eventsource dependency.

  • Client (src/client.ts):
    • Add subscribeMarketTradesEvents(conditionID, onMessage, onError?) to stream market trade events via SSE and return an unsubscribe function.
    • Support both environments using isBrowser and Node fallback with require("eventsource"); include geo_block_token in URL.
    • Minor setup: import isBrowser, createRequire; define require via createRequire.
  • Dependencies:
    • Add eventsource runtime dependency in package.json.

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

@opalo1992 opalo1992 requested a review from a team as a code owner December 5, 2025 14:59
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.

2 participants