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:
[]
= "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
# Stream trade updates (order fills)
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:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the project still builds and all tests pass.
- Commit your changes and push your branch to your forked repository.
- 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
- Author: Joaquín Béjar García
- Email: jb@taunais.com
- Telegram: @joaquin_bejar
- Repository: https://github.com/joaquinbejar/alpaca-rs
- Documentation: https://docs.rs/alpaca-websocket
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.