pub struct AxMdWebSocketClient { /* private fields */ }Expand description
Market data WebSocket client for Ax.
Provides streaming market data including tickers, trades, order books, and candles.
Requires Bearer token authentication obtained via the HTTP /api/authenticate endpoint.
Implementations§
Source§impl AxMdWebSocketClient
impl AxMdWebSocketClient
Sourcepub fn new(
url: String,
auth_token: String,
heartbeat: u64,
transport_backend: TransportBackend,
proxy_url: Option<String>,
) -> Self
pub fn new( url: String, auth_token: String, heartbeat: u64, transport_backend: TransportBackend, proxy_url: Option<String>, ) -> Self
Creates a new Ax market data WebSocket client.
The auth_token is a Bearer token obtained from the HTTP /api/authenticate endpoint.
Sourcepub fn without_auth(
url: String,
heartbeat: u64,
transport_backend: TransportBackend,
proxy_url: Option<String>,
) -> Self
pub fn without_auth( url: String, heartbeat: u64, transport_backend: TransportBackend, proxy_url: Option<String>, ) -> Self
Creates a new Ax market data WebSocket client without authentication.
Use set_auth_token to set the token before connecting.
Sourcepub fn set_auth_token(&mut self, token: String)
pub fn set_auth_token(&mut self, token: String)
Sets the authentication token for subsequent connections.
This should be called before connect() if authentication is required.
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Returns the number of confirmed subscriptions.
Sourcepub fn symbol_data_types(&self) -> Arc<AtomicMap<String, SymbolDataTypes>> ⓘ
pub fn symbol_data_types(&self) -> Arc<AtomicMap<String, SymbolDataTypes>> ⓘ
Returns the symbol data types map (shared with handler).
Sourcepub fn status_invalidations(&self) -> Arc<Mutex<AHashSet<Ustr>>> ⓘ
pub fn status_invalidations(&self) -> Arc<Mutex<AHashSet<Ustr>>> ⓘ
Returns the shared set of symbols whose instrument status cache has been invalidated.
Sourcepub async fn connect(&mut self) -> AxWsResult<()>
pub async fn connect(&mut self) -> AxWsResult<()>
Establishes the WebSocket connection.
§Errors
Sourcepub async fn subscribe_book_deltas(
&self,
symbol: &str,
level: AxMarketDataLevel,
) -> AxWsResult<()>
pub async fn subscribe_book_deltas( &self, symbol: &str, level: AxMarketDataLevel, ) -> AxWsResult<()>
Subscribes to order book deltas for a symbol.
Uses reference counting so the underlying AX subscription is only removed when all data types have been unsubscribed.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn subscribe_quotes(&self, symbol: &str) -> AxWsResult<()>
pub async fn subscribe_quotes(&self, symbol: &str) -> AxWsResult<()>
Subscribes to quote data for a symbol.
Uses reference counting so the underlying AX subscription is only removed when all data types have been unsubscribed.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn subscribe_trades(&self, symbol: &str) -> AxWsResult<()>
pub async fn subscribe_trades(&self, symbol: &str) -> AxWsResult<()>
Subscribes to trade data for a symbol.
Uses reference counting so the underlying AX subscription is only removed when all data types have been unsubscribed.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn unsubscribe_book_deltas(&self, symbol: &str) -> AxWsResult<()>
pub async fn unsubscribe_book_deltas(&self, symbol: &str) -> AxWsResult<()>
Unsubscribes from order book deltas for a symbol.
The underlying AX subscription is only removed when all data types (quotes, trades, book) have been unsubscribed.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub async fn unsubscribe_quotes(&self, symbol: &str) -> AxWsResult<()>
pub async fn unsubscribe_quotes(&self, symbol: &str) -> AxWsResult<()>
Unsubscribes from quote data for a symbol.
The underlying AX subscription is only removed when all data types (quotes, trades, book) have been unsubscribed.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub async fn unsubscribe_trades(&self, symbol: &str) -> AxWsResult<()>
pub async fn unsubscribe_trades(&self, symbol: &str) -> AxWsResult<()>
Unsubscribes from trade data for a symbol.
The underlying AX subscription is only removed when all data types (quotes, trades, book) have been unsubscribed.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub async fn subscribe_mark_prices(&self, symbol: &str) -> AxWsResult<()>
pub async fn subscribe_mark_prices(&self, symbol: &str) -> AxWsResult<()>
Subscribes to mark prices for a symbol.
Ensures at least an L1 subscription so that ticker messages (which carry the mark price field) are received.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn unsubscribe_mark_prices(&self, symbol: &str) -> AxWsResult<()>
pub async fn unsubscribe_mark_prices(&self, symbol: &str) -> AxWsResult<()>
Unsubscribes from mark prices for a symbol.
The underlying AX subscription is only removed when all data types have been unsubscribed.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub async fn subscribe_instrument_status(&self, symbol: &str) -> AxWsResult<()>
pub async fn subscribe_instrument_status(&self, symbol: &str) -> AxWsResult<()>
Subscribes to instrument status for a symbol.
Ensures at least an L1 subscription so that ticker messages (which carry the instrument state field) are received.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn unsubscribe_instrument_status(
&self,
symbol: &str,
) -> AxWsResult<()>
pub async fn unsubscribe_instrument_status( &self, symbol: &str, ) -> AxWsResult<()>
Unsubscribes from instrument status for a symbol.
The underlying AX subscription is only removed when all data types have been unsubscribed.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub async fn subscribe_candles(
&self,
symbol: &str,
width: AxCandleWidth,
) -> AxWsResult<()>
pub async fn subscribe_candles( &self, symbol: &str, width: AxCandleWidth, ) -> AxWsResult<()>
Subscribes to candle data for a symbol.
Skips sending if already subscribed or subscription is pending.
§Errors
Returns an error if the subscription command cannot be sent.
Sourcepub async fn unsubscribe_candles(
&self,
symbol: &str,
width: AxCandleWidth,
) -> AxWsResult<()>
pub async fn unsubscribe_candles( &self, symbol: &str, width: AxCandleWidth, ) -> AxWsResult<()>
Unsubscribes from candle data for a symbol.
§Errors
Returns an error if the unsubscribe command cannot be sent.
Sourcepub fn stream(&mut self) -> impl Stream<Item = AxDataWsMessage> + 'static
pub fn stream(&mut self) -> impl Stream<Item = AxDataWsMessage> + 'static
Returns a stream of WebSocket messages.
§Panics
Panics if called before connect() or if the stream has already been taken.
Sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
Disconnects the WebSocket connection gracefully.
Trait Implementations§
Source§impl Clone for AxMdWebSocketClient
impl Clone for AxMdWebSocketClient
Auto Trait Implementations§
impl Freeze for AxMdWebSocketClient
impl !RefUnwindSafe for AxMdWebSocketClient
impl Send for AxMdWebSocketClient
impl Sync for AxMdWebSocketClient
impl Unpin for AxMdWebSocketClient
impl UnsafeUnpin for AxMdWebSocketClient
impl !UnwindSafe for AxMdWebSocketClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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