pub struct KalshiDataClient { /* private fields */ }Expand description
Streams selected binary markets as exact YES-priced L2 books, quotes, trades, status, and closes.
Connection publishes fresh definitions for every selected market before streaming. Subscriptions are reference counted independently for books, quotes, and trades, and survive stop or disconnect. Book, quote, and trade channels each share one wire subscription across the selected markets. Per-market demand controls delivery; the wire subscription ends when its last reference is released. Reset clears demand; disposal permanently closes admission. Ticker quotes require both prices and positive sizes in the same message. Incomplete and empty sides are not carried forward.
Implementations§
Source§impl KalshiDataClient
impl KalshiDataClient
Sourcepub fn new(
client_id: ClientId,
config: KalshiDataClientConfig,
instruments: Vec<InstrumentId>,
sender: EventSender<DataEvent>,
) -> Result<Self>
pub fn new( client_id: ClientId, config: KalshiDataClientConfig, instruments: Vec<InstrumentId>, sender: EventSender<DataEvent>, ) -> Result<Self>
Creates a disconnected client for a nonempty set of distinct native markets.
The sender accepts the engine dispatch sender or a standalone Tokio sender converted with
into(). Only selected markets can stream; explicit instrument requests remain fresh and
preserve their original filters and correlation IDs.
§Errors
Returns an error if configuration is invalid, markets are empty, repeated, or foreign, or HTTP transport setup fails.
Trait Implementations§
Source§impl DataClient for KalshiDataClient
impl DataClient for KalshiDataClient
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
true if the client is currently connected.Source§fn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
true if the client is currently disconnected.Source§fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn subscribe_quotes(&mut self, command: SubscribeQuotes) -> Result<()>
fn subscribe_quotes(&mut self, command: SubscribeQuotes) -> Result<()>
Source§fn subscribe_trades(&mut self, command: SubscribeTrades) -> Result<()>
fn subscribe_trades(&mut self, command: SubscribeTrades) -> Result<()>
Source§fn unsubscribe_quotes(&mut self, command: &UnsubscribeQuotes) -> Result<()>
fn unsubscribe_quotes(&mut self, command: &UnsubscribeQuotes) -> Result<()>
Source§fn unsubscribe_trades(&mut self, command: &UnsubscribeTrades) -> Result<()>
fn unsubscribe_trades(&mut self, command: &UnsubscribeTrades) -> Result<()>
Source§fn subscribe_book_deltas(&mut self, command: SubscribeBookDeltas) -> Result<()>
fn subscribe_book_deltas(&mut self, command: SubscribeBookDeltas) -> Result<()>
Source§fn unsubscribe_book_deltas(
&mut self,
command: &UnsubscribeBookDeltas,
) -> Result<()>
fn unsubscribe_book_deltas( &mut self, command: &UnsubscribeBookDeltas, ) -> Result<()>
Source§fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
Source§fn request_trades(&self, request: RequestTrades) -> Result<()>
fn request_trades(&self, request: RequestTrades) -> Result<()>
Source§fn request_bars(&self, request: RequestBars) -> Result<()>
fn request_bars(&self, request: RequestBars) -> Result<()>
Source§fn request_quotes(&self, _request: RequestQuotes) -> Result<()>
fn request_quotes(&self, _request: RequestQuotes) -> Result<()>
Source§fn request_instrument(&self, request: RequestInstrument) -> Result<()>
fn request_instrument(&self, request: RequestInstrument) -> Result<()>
Source§fn request_instruments(&self, request: RequestInstruments) -> Result<()>
fn request_instruments(&self, request: RequestInstruments) -> Result<()>
Source§fn subscribe_instrument_status(
&mut self,
command: SubscribeInstrumentStatus,
) -> Result<()>
fn subscribe_instrument_status( &mut self, command: SubscribeInstrumentStatus, ) -> Result<()>
Source§fn unsubscribe_instrument_status(
&mut self,
command: &UnsubscribeInstrumentStatus,
) -> Result<()>
fn unsubscribe_instrument_status( &mut self, command: &UnsubscribeInstrumentStatus, ) -> Result<()>
Source§fn subscribe_instrument_close(
&mut self,
command: SubscribeInstrumentClose,
) -> Result<()>
fn subscribe_instrument_close( &mut self, command: SubscribeInstrumentClose, ) -> Result<()>
Source§fn unsubscribe_instrument_close(
&mut self,
command: &UnsubscribeInstrumentClose,
) -> Result<()>
fn unsubscribe_instrument_close( &mut self, command: &UnsubscribeInstrumentClose, ) -> Result<()>
Source§fn subscribe(&mut self, _command: SubscribeCustomData) -> Result<()>
fn subscribe(&mut self, _command: SubscribeCustomData) -> Result<()>
Source§fn subscribe_instruments(
&mut self,
_command: SubscribeInstruments,
) -> Result<()>
fn subscribe_instruments( &mut self, _command: SubscribeInstruments, ) -> Result<()>
Source§fn subscribe_instrument(&mut self, _command: SubscribeInstrument) -> Result<()>
fn subscribe_instrument(&mut self, _command: SubscribeInstrument) -> Result<()>
Source§fn subscribe_book_depth(&mut self, _command: SubscribeBookDepth) -> Result<()>
fn subscribe_book_depth(&mut self, _command: SubscribeBookDepth) -> Result<()>
Source§fn subscribe_mark_prices(&mut self, _command: SubscribeMarkPrices) -> Result<()>
fn subscribe_mark_prices(&mut self, _command: SubscribeMarkPrices) -> Result<()>
Source§fn subscribe_index_prices(
&mut self,
_command: SubscribeIndexPrices,
) -> Result<()>
fn subscribe_index_prices( &mut self, _command: SubscribeIndexPrices, ) -> Result<()>
Source§fn subscribe_funding_rates(
&mut self,
_command: SubscribeFundingRates,
) -> Result<()>
fn subscribe_funding_rates( &mut self, _command: SubscribeFundingRates, ) -> Result<()>
Source§fn subscribe_bars(&mut self, _command: SubscribeBars) -> Result<()>
fn subscribe_bars(&mut self, _command: SubscribeBars) -> Result<()>
Source§fn subscribe_option_greeks(
&mut self,
_command: SubscribeOptionGreeks,
) -> Result<()>
fn subscribe_option_greeks( &mut self, _command: SubscribeOptionGreeks, ) -> Result<()>
Source§fn unsubscribe(&mut self, _command: &UnsubscribeCustomData) -> Result<()>
fn unsubscribe(&mut self, _command: &UnsubscribeCustomData) -> Result<()>
Source§fn unsubscribe_instruments(
&mut self,
_command: &UnsubscribeInstruments,
) -> Result<()>
fn unsubscribe_instruments( &mut self, _command: &UnsubscribeInstruments, ) -> Result<()>
Source§fn unsubscribe_instrument(
&mut self,
_command: &UnsubscribeInstrument,
) -> Result<()>
fn unsubscribe_instrument( &mut self, _command: &UnsubscribeInstrument, ) -> Result<()>
Source§fn unsubscribe_book_depth(
&mut self,
_command: &UnsubscribeBookDepth,
) -> Result<()>
fn unsubscribe_book_depth( &mut self, _command: &UnsubscribeBookDepth, ) -> Result<()>
Source§fn unsubscribe_mark_prices(
&mut self,
_command: &UnsubscribeMarkPrices,
) -> Result<()>
fn unsubscribe_mark_prices( &mut self, _command: &UnsubscribeMarkPrices, ) -> Result<()>
Source§fn unsubscribe_index_prices(
&mut self,
_command: &UnsubscribeIndexPrices,
) -> Result<()>
fn unsubscribe_index_prices( &mut self, _command: &UnsubscribeIndexPrices, ) -> Result<()>
Source§fn unsubscribe_funding_rates(
&mut self,
_command: &UnsubscribeFundingRates,
) -> Result<()>
fn unsubscribe_funding_rates( &mut self, _command: &UnsubscribeFundingRates, ) -> Result<()>
Source§fn unsubscribe_bars(&mut self, _command: &UnsubscribeBars) -> Result<()>
fn unsubscribe_bars(&mut self, _command: &UnsubscribeBars) -> Result<()>
Source§fn unsubscribe_option_greeks(
&mut self,
_command: &UnsubscribeOptionGreeks,
) -> Result<()>
fn unsubscribe_option_greeks( &mut self, _command: &UnsubscribeOptionGreeks, ) -> Result<()>
§fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<(), Error>
fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<(), Error>
§fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<(), Error>
fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<(), Error>
§fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<(), Error>
fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<(), Error>
§fn subscribe_pool_liquidity_updates(
&mut self,
cmd: SubscribePoolLiquidityUpdates,
) -> Result<(), Error>
fn subscribe_pool_liquidity_updates( &mut self, cmd: SubscribePoolLiquidityUpdates, ) -> Result<(), Error>
§fn subscribe_pool_fee_collects(
&mut self,
cmd: SubscribePoolFeeCollects,
) -> Result<(), Error>
fn subscribe_pool_fee_collects( &mut self, cmd: SubscribePoolFeeCollects, ) -> Result<(), Error>
§fn subscribe_pool_flash_events(
&mut self,
cmd: SubscribePoolFlashEvents,
) -> Result<(), Error>
fn subscribe_pool_flash_events( &mut self, cmd: SubscribePoolFlashEvents, ) -> Result<(), Error>
§fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<(), Error>
fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<(), Error>
§fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<(), Error>
fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<(), Error>
§fn unsubscribe_pool_swaps(
&mut self,
cmd: &UnsubscribePoolSwaps,
) -> Result<(), Error>
fn unsubscribe_pool_swaps( &mut self, cmd: &UnsubscribePoolSwaps, ) -> Result<(), Error>
§fn unsubscribe_pool_liquidity_updates(
&mut self,
cmd: &UnsubscribePoolLiquidityUpdates,
) -> Result<(), Error>
fn unsubscribe_pool_liquidity_updates( &mut self, cmd: &UnsubscribePoolLiquidityUpdates, ) -> Result<(), Error>
§fn unsubscribe_pool_fee_collects(
&mut self,
cmd: &UnsubscribePoolFeeCollects,
) -> Result<(), Error>
fn unsubscribe_pool_fee_collects( &mut self, cmd: &UnsubscribePoolFeeCollects, ) -> Result<(), Error>
§fn unsubscribe_pool_flash_events(
&mut self,
cmd: &UnsubscribePoolFlashEvents,
) -> Result<(), Error>
fn unsubscribe_pool_flash_events( &mut self, cmd: &UnsubscribePoolFlashEvents, ) -> Result<(), Error>
§fn request_data(&self, _request: RequestCustomData) -> Result<(), Error>
fn request_data(&self, _request: RequestCustomData) -> Result<(), Error>
§fn request_funding_rates(
&self,
_request: RequestFundingRates,
) -> Result<(), Error>
fn request_funding_rates( &self, _request: RequestFundingRates, ) -> Result<(), Error>
§fn request_option_chain_reference_price(
&self,
request: RequestOptionChainReferencePrice,
) -> Result<(), Error>
fn request_option_chain_reference_price( &self, request: RequestOptionChainReferencePrice, ) -> Result<(), Error>
§fn request_book_depth(&self, _request: RequestBookDepth) -> Result<(), Error>
fn request_book_depth(&self, _request: RequestBookDepth) -> Result<(), Error>
Auto Trait Implementations§
impl !RefUnwindSafe for KalshiDataClient
impl !Send for KalshiDataClient
impl !Sync for KalshiDataClient
impl !UnwindSafe for KalshiDataClient
impl Freeze for KalshiDataClient
impl Unpin for KalshiDataClient
impl UnsafeUnpin for KalshiDataClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more