pub struct AlpacaWebSocketClient { /* private fields */ }Expand description
WebSocket client for Alpaca API
Implementations§
Source§impl AlpacaWebSocketClient
impl AlpacaWebSocketClient
Sourcepub fn new(credentials: Credentials, environment: Environment) -> Self
pub fn new(credentials: Credentials, environment: Environment) -> Self
Create a new WebSocket client for stocks
Sourcepub fn from_env(environment: Environment) -> Result<Self>
pub fn from_env(environment: Environment) -> Result<Self>
Create a new client from environment variables
Sourcepub fn with_feed(
credentials: Credentials,
environment: Environment,
feed: DataFeed,
) -> Self
pub fn with_feed( credentials: Credentials, environment: Environment, feed: DataFeed, ) -> Self
Create a WebSocket client for a specific data feed
Sourcepub fn crypto(credentials: Credentials, environment: Environment) -> Self
pub fn crypto(credentials: Credentials, environment: Environment) -> Self
Create a crypto WebSocket client
Sourcepub fn crypto_from_env(environment: Environment) -> Result<Self>
pub fn crypto_from_env(environment: Environment) -> Result<Self>
Create a crypto client from environment variables
Sourcepub fn trading(credentials: Credentials, environment: Environment) -> Self
pub fn trading(credentials: Credentials, environment: Environment) -> Self
Create a trading WebSocket client
Sourcepub async fn connect(&self) -> Result<AlpacaStream>
pub async fn connect(&self) -> Result<AlpacaStream>
Connect to the WebSocket and return a stream of messages
Sourcepub async fn connect_with_reconnect(
&self,
max_retries: u32,
) -> Result<AlpacaStream>
pub async fn connect_with_reconnect( &self, max_retries: u32, ) -> Result<AlpacaStream>
Connect with automatic reconnection
Sourcepub async fn subscribe_market_data(
&self,
subscription: SubscribeMessage,
) -> Result<MarketDataStream>
pub async fn subscribe_market_data( &self, subscription: SubscribeMessage, ) -> Result<MarketDataStream>
Subscribe to market data
Sourcepub async fn subscribe_trading_updates(&self) -> Result<TradingStream>
pub async fn subscribe_trading_updates(&self) -> Result<TradingStream>
Subscribe to trading updates
Sourcepub async fn send_subscription(
&self,
subscription: SubscribeMessage,
) -> Result<()>
pub async fn send_subscription( &self, subscription: SubscribeMessage, ) -> Result<()>
Send subscription message
Sourcepub async fn send_unsubscription(
&self,
unsubscription: UnsubscribeMessage,
) -> Result<()>
pub async fn send_unsubscription( &self, unsubscription: UnsubscribeMessage, ) -> Result<()>
Send unsubscription message
Sourcepub fn environment(&self) -> &Environment
pub fn environment(&self) -> &Environment
Get the environment
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AlpacaWebSocketClient
impl RefUnwindSafe for AlpacaWebSocketClient
impl Send for AlpacaWebSocketClient
impl Sync for AlpacaWebSocketClient
impl Unpin for AlpacaWebSocketClient
impl UnwindSafe for AlpacaWebSocketClient
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
Mutably borrows from an owned value. Read more