Skip to content

feat(ws): typed subscribe_ebattle_scores (#575) — 22.11.0 - #577

Merged
TexasCoding merged 2 commits into
mainfrom
fix/575-ws-channel
Nov 10, 2026
Merged

TexasCoding merged 2 commits into
mainfrom
fix/575-ws-channel

Conversation

@TexasCoding

Copy link
Copy Markdown
Owner

Closes #575

Reconciles today's nightly spec-drift failure: AsyncAPI grew from 15 to 16 channels. batch_communications is still gone; the new channel is ebattle_scores (live eSoccer/eFootball and eBasketball scores). Yesterday's #575 items (POST /margin/fcm/positions/transfers, ApiKey.key_type) already shipped in v22.10.0 via #576 and are not revisited here.

This is a minor release (22.11.0). Additive only; nothing was renamed or removed.

What changed

  • New typed KalshiWebSocket.subscribe_ebattle_scores(*, match_ids=None, maxsize=1000).
    A fresh subscription is empty until matches are requested. Passing match_ids (e.g. ["all"] or Kalshi milestone IDs) sends update_subscription with action=subscribe_matches immediately after the subscribe ack, while the recv loop is still paused.
  • New models: EbattleScoresMessage / EbattleScoresPayload and EbattleScoresMatchlistMessage / EbattleScoresMatchlistPayload. msg.data is left as a JSON-encoded string (same as CF Benchmarks data).
  • Dispatch recognizes ebattle_scores and ebattle_scores_matchlist.
  • SubscriptionManager.update_subscription accepts match_ids and, for subscribe_matches / unsubscribe_matches / matchlist, sends the spec's required scalar params.sid (not params.sids). Existing market and CF Benchmarks actions still send sids.
  • Channel-count assertion updated (15 → 16) while still requiring batch_communications to stay absent.
  • OpenAPI drift in this sync is description-only (RFQ create 429 open_rfq_limit_exceeded / 400 rfq_market_not_open; balance_breakdown and subaccount-balance wording). Recorded in the changelog; no REST model changes.

Blast radius

GitNexus is unavailable; this is a hand-written impact note.

Direct

  • kalshi/ws/models/ebattle.py (new)
  • kalshi/ws/models/__init__.py — exports
  • kalshi/ws/dispatch.py — MESSAGE_MODELS
  • kalshi/ws/channels.py — _CHANNEL_PARAMS["ebattle_scores"] (empty; match_ids is not a subscribe-command param) and update_subscription wire format for match actions
  • kalshi/ws/client.py — subscribe_ebattle_scores
  • kalshi/_contract_map.py — WS_CONTRACT_MAP entries
  • tests/test_contracts.py — test_batch_communications_channel_removed
  • WS tests: test_models.py, test_client.py, test_channels.py, test_dispatch.py
  • Docs: docs/websockets.md, README.md, docs/index.md, CLAUDE.md, CHANGELOG.md
  • Version: pyproject.toml, kalshi/__init__.py → 22.11.0
  • Specs: specs/asyncapi.yaml, specs/openapi.yaml (synced; _generated/ unchanged)

Likely callers / behavior

  • Existing subscribe_* helpers and generic subscribe(channel, ...) are untouched.
  • update_subscription for add_markets / delete_markets / get_snapshot / subscribe_indices / unsubscribe_indices / indexlist still sends params.sids. Only the three new eBattle actions take the singular sid path.
  • CONTROL_TYPES still treats ok as a control frame, so subscribedMatchesResponse (type ok) is consumed as the update ack, not yielded on the iterator.
  • pyth_value, root, and control_frames remain escape-hatch-only.
  • REST resources, generated models, and perps (REST + WS) are unchanged.
  • The WS client remains async-only.

Risks

  • If Kalshi's server accepted sids for eBattle and rejected sid, seeding match_ids would fail. The AsyncAPI schema requires sid and does not list sids for this command, so the singular form matches the contract.
  • Public access to ebattle_scores is temporary and may later require individual approval; unapproved subscriptions then end. Documented on the method and in docs/websockets.md.

AsyncAPI gained the public ebattle_scores WebSocket channel (15 → 16;
batch_communications remains gone). OpenAPI changes are description-only
plus a documented 429 on RFQ create.
Add models, dispatch, subscribe helper, and update_subscription
support (singular sid + match_ids) for Kalshi's new ebattle_scores
WebSocket channel. Bump to 22.11.0.
@TexasCoding
TexasCoding merged commit 65a0ecb into main Nov 10, 2026
6 checks passed
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.

Nightly spec-drift: strict contract tests failing (since 2026-11-09)

1 participant