Expand description
WebSocket client for real-time market data and account-scoped updates.
Connects to the Hypercall WS endpoint (/ws) for streaming:
- Public: orderbook, trades, index prices, options chain
- Account-scoped: order updates, fills, portfolio, position changes
§Example
use hypercall_client::WsClient;
let ws = WsClient::new();
ws.connect("https://api.hypercall.xyz", None).await?;
// Subscribe to fills (options + perps, distinguished by instrument_type)
ws.subscribe(vec!["fills", "order_updates"]).await?;
// Wait for a message
let msg = ws.wait_for_message(|_| true, 5000).await;
println!("{:?}", msg);§Channels
| Channel | Auth | Description |
|---|---|---|
orderbook | No | L2 orderbook updates (filterable by symbols) |
trades | No | Public trade events |
index_prices | No | Spot/index prices for all underlyings |
indicative_market_data | No | Aggregated quote-provider prices, one row per frame |
indicative_market_data_v2 | No | The same prices in batch frames, see WsClient::subscribe_indicative_market_data |
order_updates | Yes | Order status changes (includes instrument_type) |
fills | Yes | Fill notifications (includes instrument_type) |
portfolio | Yes | Portfolio balance + position updates |
§Compression
The client offers RFC 7692 permessage-deflate on every connection. When the
server accepts, compressed frames are inflated transparently, with the same
size limit as uncompressed messages; when it does not, the connection runs
uncompressed with identical JSON messages. Opt out with
WsClient::with_permessage_deflate.
§Batched indicative market data
WsClient::subscribe_indicative_market_data subscribes to
indicative_market_data_v2, which delivers IndicativeMarketDataBatch
frames, each carrying the rows of one short batch window. Servers that
predate that channel confirm any channel name, so the client checks the
confirmation: only {"type":"Subscribed","channel":"indicative_market_data_v2","batch":true}
means the server batches. Any other confirmation makes the client switch
that subscription to indicative_market_data (one row per frame) for the
rest of the client’s life. crate::indicative decodes both. Opt out
with WsClient::with_batched_indicative.
Structs§
- WsClient
- WebSocket client for Hypercall.
- WsClient
Config - Reconnection and handshake policy for
WsClient. - WsRecovery
Plan - Application work required before state is continuous after a reconnect.
Enums§
- WsConnection
State - Current lifecycle state of the client-managed WebSocket session.
- WsDisconnect
Reason - Why an established WebSocket session ended.