alpaca-websocket

Crates.ioalpaca-websocket
lib.rsalpaca-websocket
version0.3.1
created_at2026-01-01 19:51:45.010346+00
updated_at2026-01-02 07:33:44.234903+00
descriptionWebSocket client for Alpaca trading platform real-time data
homepagehttps://github.com/joaquinbejar/alpaca-rs
repositoryhttps://github.com/joaquinbejar/alpaca-rs
max_upload_size
id2017374
size120,146
Joaquin Bejar Garcia (joaquinbejar)

documentation

README

alpaca-rs

License Crates.io Downloads Documentation

alpaca-websocket

WebSocket client for the Alpaca trading platform real-time data and account updates.

Overview

alpaca-websocket provides a real-time streaming interface for Alpaca's market data and account events. It's built on top of tokio-tungstenite for high-performance asynchronous streaming.

Features

  • Real-time Market Data: Stream trades, quotes, and bars for stocks and crypto.
  • Account Updates: Receive real-time notifications about order fills and account changes.
  • Automatic Reconnection: Built-in logic to handle network disruptions.
  • Easy Subscription: Clean API for subscribing to multiple symbols.

Installation

Add to your Cargo.toml:

[dependencies]
alpaca-websocket = "0.3.1"

Examples

Run examples with cargo run -p alpaca-websocket --example <name>:

Example Description
ws_stock_trades_stream Stream real-time stock trades
ws_stock_quotes_stream Stream real-time stock quotes
ws_stock_bars_stream Stream real-time stock bars
ws_crypto_stream Stream real-time crypto data
ws_trade_updates Stream order/trade updates
ws_websocket_config Configure WebSocket client
ws_reconnection Handle disconnections and reconnect
ws_stream_news Subscribe to real-time news
# Stream stock trades
cargo run -p alpaca-websocket --example ws_stock_trades_stream

# Stream trade updates (order fills)
cargo run -p alpaca-websocket --example ws_trade_updates

Note: Examples require ALPACA_API_KEY and ALPACA_API_SECRET environment variables.

Contribution and Contact

We welcome contributions to this project! If you would like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and ensure that the project still builds and all tests pass.
  4. Commit your changes and push your branch to your forked repository.
  5. Submit a pull request to the main repository.

If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:

Contact Information

We appreciate your interest and look forward to your contributions!

License: MIT

Disclaimer

This software is not officially associated with Alpaca Markets. Trading financial instruments carries risk, and this library is provided as-is without any guarantees. Always test thoroughly with a paper trading account before using in a live trading environment.

Commit count: 2

cargo fmt