Skip to content

KalshiExchangeOptions.websocket (KalshiWebSocketConfig) not passable through either SDK #1053

Open

Description

@realfishsam

Gap

KalshiExchangeOptions in core accepts an optional websocket?: KalshiWebSocketConfig field for configuring the underlying Kalshi WebSocket connection (custom wsUrl, etc.). Neither the TypeScript SDK Kalshi constructor nor the Python SDK Kalshi.__init__ expose this field, so it is silently ignored and the sidecar always uses the default Kalshi WebSocket URL.

Note: the same class of gap exists for Opinion (OpinionExchangeOptions.websocket, #973) and Probable (wsConfig, #972), and Polymarket (#1052). This issue is specifically for Kalshi.

Core

core/src/exchanges/kalshi/index.ts

  • KalshiExchangeOptions.websocket?: KalshiWebSocketConfig — line 45
  • The config is stored as this.wsConfig (line 55) and read at line 67
  • Used in ensureWs() to construct KalshiWebSocket with a merged config at lines 425–429, 438–442, 456–460

KalshiWebSocketConfig and KalshiWebSocket are defined in core/src/exchanges/kalshi/websocket.ts and re-exported from the exchange index at line 41.

TypeScript SDK

sdks/typescript/pmxt/client.ts — Kalshi class (line 3091–3095):

export class Kalshi extends Exchange {
    constructor(options: ExchangeOptions = {}) {
        super("kalshi", options);
    }
}

ExchangeOptions (the base interface) has no websocket field. The constructor does not define a venue-specific options interface that could carry one.

Python SDK

sdks/python/pmxt/_exchanges.py — Kalshi.__init__ (line 122–150):

def __init__(
    self,
    api_key: Optional[str] = None,
    private_key: Optional[str] = None,
    base_url: Optional[str] = None,
    auto_start_server: Optional[bool] = None,
    pmxt_api_key: Optional[str] = None,
    # websocket parameter absent
) -> None:

Evidence

Users who need a custom Kalshi WebSocket URL (e.g. targeting the Kalshi demo environment's WS endpoint separately from the REST base URL, or using a proxy) have no SDK path:

// Desired — currently impossible in TypeScript SDK:
const kalshi = new pmxt.Kalshi({
    apiKey: "...",
    privateKey: "...",
    websocket: {
        wsUrl: "wss://demo-api.kalshi.co/trade-api/ws/v2",
    },
});
# Desired — currently impossible in Python SDK:
kalshi = pmxt.Kalshi(
    api_key="...",
    private_key="...",
    websocket={"ws_url": "wss://demo-api.kalshi.co/trade-api/ws/v2"},
)

Impact

SDK users cannot override the Kalshi WebSocket endpoint or configure reconnect behavior. The sidecar always derives the WebSocket URL from the hardcoded default. This matters especially for KalshiDemo users who may need a different WS URL than the production instance, and for users behind WebSocket proxies.

Activity

  1. added 9 commits that reference this issue on Jun 16, 2026
    4b8f210
    97e9833
    72dc168
    bcab4d4
    4ea3b1e
    d0bbf9a
    846e814
    01b84fd
    0bd4b6a
  2. added 4 commits that reference this issue on Jul 12, 2026
    503d34a
    f7860cb
    ac74438
    8d0b555
  3. realfishsam commented on Sep 5, 2026

    @realfishsam
    ContributorAuthor

    Additional context from duplicate #1759: PR #1126 ("feat(sdk): expose WebSocket configuration for Polymarket and Kalshi"), which is linked as closing this issue, does not actually fix it. It adds a same-named websocket option to both SDKs, but that option configures WsClientConfig (sdks/typescript/pmxt/ws-client.ts) — the local SDK↔sidecar transport socket — not core's KalshiWebSocketConfig (core/src/exchanges/kalshi/websocket.ts:12-19, exposed as KalshiExchangeOptions.websocket at core/src/exchanges/kalshi/index.ts:45). None of core's real field names (wsUrl, reconnectIntervalMs, watchTimeoutMs as defined on KalshiWebSocketConfig) are wired through, and core/src/server/exchange-factory.ts's createExchange() still takes no websocket-config parameter and passes none through at its new KalshiExchange({...}) call site. This issue should remain open — please don't treat PR #1126 as resolving it.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions