kalshi-cpp 0.6.2
C++23 client for Kalshi's Predictions API
Loading...
Searching...
No Matches
kalshi::WsConfig Struct Reference

#include <kalshi/websocket.hpp>

Static Public Member Functions

static WsConfig for_environment (Environment environment)
 

Public Attributes

std::string url {websocket_url(Environment::Production)}
 
std::chrono::milliseconds connect_timeout {std::chrono::seconds{10}}
 How long connect() waits for the handshake.
 
bool auto_reconnect {true}
 Reconnect and resubscribe after the connection drops.
 
std::chrono::milliseconds reconnect_delay {std::chrono::milliseconds{500}}
 The first reconnect waits about this long; each failure doubles the wait, with jitter, up to max_reconnect_delay.
 
std::chrono::milliseconds max_reconnect_delay {std::chrono::seconds{30}}
 
std::uint32_t max_reconnect_attempts {0}
 Stop after this many failed attempts in a row; 0 keeps trying.
 
std::chrono::seconds ping_interval {std::chrono::seconds{15}}
 Ping after this much silence, and drop the connection after idle_timeout without a reply.
 
std::chrono::seconds idle_timeout {std::chrono::seconds{30}}
 
bool resync_on_gap {true}
 Request fresh order book snapshots when an orderbook_delta sequence number is skipped.
 

Member Function Documentation

◆ for_environment()

static WsConfig kalshi::WsConfig::for_environment ( Environment  environment)
inlinestatic

Member Data Documentation

◆ url

std::string kalshi::WsConfig::url {websocket_url(Environment::Production)}

◆ connect_timeout

std::chrono::milliseconds kalshi::WsConfig::connect_timeout {std::chrono::seconds{10}}

How long connect() waits for the handshake.

◆ auto_reconnect

bool kalshi::WsConfig::auto_reconnect {true}

Reconnect and resubscribe after the connection drops.

◆ reconnect_delay

std::chrono::milliseconds kalshi::WsConfig::reconnect_delay {std::chrono::milliseconds{500}}

The first reconnect waits about this long; each failure doubles the wait, with jitter, up to max_reconnect_delay.

◆ max_reconnect_delay

std::chrono::milliseconds kalshi::WsConfig::max_reconnect_delay {std::chrono::seconds{30}}

◆ max_reconnect_attempts

std::uint32_t kalshi::WsConfig::max_reconnect_attempts {0}

Stop after this many failed attempts in a row; 0 keeps trying.

A connection that drops within 10 seconds of opening counts as failed.

◆ ping_interval

std::chrono::seconds kalshi::WsConfig::ping_interval {std::chrono::seconds{15}}

Ping after this much silence, and drop the connection after idle_timeout without a reply.

Kalshi pings every 10 seconds.

◆ idle_timeout

std::chrono::seconds kalshi::WsConfig::idle_timeout {std::chrono::seconds{30}}

◆ resync_on_gap

bool kalshi::WsConfig::resync_on_gap {true}

Request fresh order book snapshots when an orderbook_delta sequence number is skipped.

The gap is reported to on_error either way.


The documentation for this struct was generated from the following file: