webull-rs
A Rust client for the Webull trading API.
Overview
webull-rs is a Rust crate that provides a robust, type-safe, and idiomatic interface to the Webull trading API. It enables developers to build trading applications, algorithms, and bots in Rust.
Features
- Type-safe API client for Webull trading platform
- Comprehensive error handling with detailed error types
- Async/await support with Tokio
- Authentication with support for multi-factor authentication and token refresh
- Account management for retrieving account information, positions, and balances
- Market data for quotes, bars, option chains, and more
- Trading operations for placing, modifying, and canceling orders (including options trading)
- Streaming data via WebSockets for real-time updates
- Rate limiting with configurable strategies to avoid API rate limit violations
- Response caching for improved performance
- Secure credential storage with encryption
- Strongly-typed models for all API entities
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
use ;
use Duration;
async
Examples
The crate includes several examples to help you get started:
- Authentication: Demonstrates how to authenticate with the Webull API
- Account Information: Shows how to retrieve account information
- Market Data: Demonstrates how to get quotes, bars, and option chains
- Order Placement: Shows how to place, modify, and cancel orders
- Streaming Data: Demonstrates how to use the WebSocket client for real-time data
- Credential Storage: Shows how to use the secure credential storage
- Caching: Demonstrates how to use response caching for improved performance
- Paper Trading: Shows how to use paper trading
- Account Extended: Demonstrates advanced account functionality
- Market Data Extended: Shows advanced market data functionality
- Orders Extended: Demonstrates advanced order functionality including options trading
- Error Handling: Shows comprehensive error handling strategies
- Combined Operations: Demonstrates combining multiple API calls for complex operations
To run an example:
Architecture
The crate is organized into several modules:
client: The main WebullClient and builderauth: Authentication and token managementendpoints: API endpoints for different domainsmodels: Data models for API requests and responsesstreaming: WebSocket client for streaming datautils: Utility functions and helpers
Advanced Usage
Secure Credential Storage
use ;
use EncryptedCredentialStore;
use Duration;
async
Streaming Data
use ;
use EventType;
use SubscriptionRequest;
use Duration;
async
Documentation
For detailed documentation, see docs.rs/webull-rs.
For a comprehensive getting started guide, see GETTING_STARTED.md.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Security
Please see SECURITY.md for security policies and best practices.
Changelog
See CHANGELOG.md for a list of changes in each release.
License
This project is licensed under the MIT License - see the LICENSE file for details.