Skip to content

feat: support realtime websocket resubscribe - #11

Open
doskoi wants to merge 1 commit into
atompilot:mainfrom
doskoi:feat/realtime-resubscribe
Open

feat: support realtime websocket resubscribe#11
doskoi wants to merge 1 commit into
atompilot:mainfrom
doskoi:feat/realtime-resubscribe

Conversation

@doskoi

@doskoi doskoi commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • allow /ws/realtime clients to update subscriptions within the same WebSocket connection
  • support action=set, action=subscribe, and action=unsubscribe messages
  • clean up replaced subscriptions on period changes and disconnect
  • add tests using fake xtdata and WebSocket objects

Why

The endpoint currently handles the initial subscription request, then ignores later client messages until disconnect. Long-lived realtime clients often need to add/remove symbols or replace the watched list without reconnecting.

Protocol

Existing clients remain compatible because omitted action defaults to set.

{"stocks": ["000001.SZ", "600000.SH"], "period": "tick"}
{"action": "subscribe", "stocks": ["300750.SZ"]}
{"action": "unsubscribe", "stocks": ["600000.SH"]}
{"action": "set", "stocks": ["000001.SZ"], "period": "1m"}

Tests

  • uv run --with pytest --with fastapi --with numpy --with pandas python -m pytest tests/test_realtime_resubscribe.py -q

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