feat(perps): support account notifications in session reads and events#186
Open
kartojal wants to merge 8 commits into
Open
feat(perps): support account notifications in session reads and events#186kartojal wants to merge 8 commits into
kartojal wants to merge 8 commits into
Conversation
…rt-notifications-in-unified-python-sdk # Conflicts: # tests/unit/test_perps_session.py
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f595e5a. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds perps account notifications to the SDK, covering both REST reads and live session events.
What's included
models/perps/notifications.py): typed, discriminated unionPerpsNotificationcovering position opened/increased/reduced/closed, limit order canceled, liquidation warning (isolated and cross variants, discriminated bymargin_type), and position liquidated. Entries carry account-scoped read state (read_at) viaPerpsNotificationEntry.session.list_notifications(since_seq=..., limit=...)newest-first paginator whose pages also report the account'sunreadcount anddurable_source_seqhigh-water mark (for backfilling after a gap).session.mark_notifications_read(ids=... | up_to=...)mark by explicit ids, or everything up to and including a given entry.PerpsNotificationEventon thenotificationschannel, added toPerpsSessionEvent.notifications. Instead, server-sent resync control frames are surfaced asPerpsResyncEventwith a newreason="server"(plus optionaltimestamp), wheresequenceis the highest engine sequence among the dropped notifications.Tests
Unit coverage for the account actions (listing, paging with
since_seq, mark-read), event parsing (including server resync frames), and session wiring (~380 new test lines).Note
Medium Risk
New authenticated account APIs and session channel behavior;
list_fillspagination semantics change may affect existing callers relying on the old cursor scheme.Overview
Adds perps account notifications end-to-end: discriminated notification models, REST list (newest-first pages with
unreadanddurable_source_seq) and mark read (by ids or inclusiveup_to), plus sessionlist_notifications/mark_notifications_read.Live session work subscribes to
notifications, emitsPerpsNotificationEvent, maps serverresyncframes toPerpsResyncEvent(reason="server"), and skips client sequence-gap resync on that channel so sparse engine sequences do not false-trigger gaps.list_fillsswitches from client-side descending history cursors to the API’s nativesort,cursor, and trade-id pagination (optionalinitial_cursor).Public exports include notification paginator types and
PerpsSortDirection.Reviewed by Cursor Bugbot for commit 00382e7. Bugbot is set up for automated code reviews on this repo. Configure here.