Install
tokio and serde_json:
Constructing an exchange
ExchangeInner is enum-dispatched — match over Kalshi(_) and
Polymarket(_), no dyn Exchange vtable.
Direct exchange types
If you don’t need the unified facade, construct exchanges directly:Exchange trait, so callers can be generic over either.
Re-exports
openpx::* re-exports everything from px-core, plus:
ExchangeInnerandWebSocketInner— enum-dispatched facadesKalshi,KalshiConfigPolymarket,PolymarketConfig,PolymarketSignatureTypeCryptoPriceWebSocket(frompx-crypto)SportsWebSocket(frompx-sports)
WebSocket
Errors
All methods returnResult<T, OpenPxError>. The hierarchy is defined in
engine/core/src/error.rs:
OpenPxError::NetworkOpenPxError::Exchange(ExchangeError)— includesNotSupported,MarketNotFound,Authentication,InsufficientFunds,Api,RateLimitedOpenPxError::ConfigOpenPxError::SerializationOpenPxError::WebSocket(WebSocketError)
ExchangeError. See the
define_exchange_error! macro
for the canonical pattern.