WEEX Rust SDK
Professional-grade async Rust SDK for WEEX Exchange - Built for HFT bots, AI trading strategies, and production systems.
Features
Core Trading
- ✅ Place/Cancel Orders - Spot & Futures with type-safe enums
- ✅ Batch Orders - Execute multiple orders atomically
- ✅ Position Management - Real-time position tracking
- ✅ Leverage/Margin Control - Configure risk parameters
Market Data
- ✅ Real-time Ticker - Live price feeds
- ✅ Klines/Candlesticks - OHLCV data for TA
- ✅ Orderbook Depth - Level 2 market data
- ✅ Funding Rates - Futures funding info
Production Infrastructure
- ✅ Rate Limiter - Token bucket (10 req/sec)
- ✅ Retry Middleware - Exponential backoff
- ✅ WebSocket - Auto-reconnect with heartbeat
- ✅ Position Sizing - Fixed %, Kelly Criterion
- ✅ State Persistence - Trade logging, PnL tracking
- ✅ Telegram Alerts - Trade notifications
Installation
[]
= "0.5"
= { = "1", = ["full"] }
= "1.33"
Quick Start
use WeexClient;
async
Risk Management
use ;
use Decimal;
let sizer = new;
// Fixed percentage (2% risk per trade)
let size = sizer.fixed_percentage;
// Kelly Criterion
let kelly_size = sizer.kelly_criterion;
State Persistence
use ;
let state = new;
// Log trade
state.log_trade?;
// Get statistics
let stats = state.calculate_stats?;
println!;
Telegram Alerts
use ;
let alerter = new;
alerter.notify_trade.await?;
API Coverage
| Category | Methods |
|---|---|
| Trading | place_order, place_futures_order, cancel_order, post_batch_orders |
| Market | get_ticker, get_klines, get_depth, get_funding_rate |
| Account | get_balance, get_position, get_open_orders, set_leverage, set_margin_mode |
| WebSocket | Public streams, Private streams with auth |
| Bot Infra | Rate limiter, Retry, Position sizing, State, Alerts |
Architecture
weex_rust_sdk/
├── src/
│ ├── client.rs # WeexClient (main entry point)
│ ├── types.rs # Side, OrderType enums
│ ├── risk.rs # Position sizing
│ ├── engine.rs # Strategy orchestration
│ ├── state.rs # Trade persistence
│ ├── alerts.rs # Telegram notifications
│ ├── rate_limiter.rs # Token bucket
│ ├── retry.rs # Exponential backoff
│ └── ws/ # WebSocket handlers
Examples
See examples/ for:
full_test.rs- API endpoint verificationv6_integration_test.rs- Production bot featuresmarket_maker.rs- Strategy template
License
MIT