Expand description
Upbit WebSocket Trading Implementation
This module provides a high-performance WebSocket trading client for Upbit’s private endpoints with JWT authentication, real-time order updates, and asset tracking.
§Features
- JWT authentication: Support for Upbit’s JWT-based WebSocket authentication
- Private channels: Real-time myOrder and myAsset data streams
- Order management: Integration with REST API for order placement
- Asset tracking: Real-time balance and position updates
- Connection health monitoring: Real-time metrics and health status
- Automatic reconnection: Configurable backoff strategy with exponential delays
- Zero-copy message processing: Optimized for low-latency trading
§Connection Management
The client maintains connection health through:
- WebSocket ping/pong frames sent every 2 minutes (Upbit recommendation)
- Automatic reconnection on connection loss
- JWT token refresh before expiration
- Configurable timeout handling
§Private Channels
Supports Upbit’s private WebSocket channels:
myOrder: Real-time order updates (creation/execution/cancellation)myAsset: Real-time asset/balance updates- Event-driven updates only (no snapshot data)
§Usage Example
use rusty_common::auth::exchanges::upbit::{UpbitAuth, UpbitAuthConfig};
use rusty_ems::exchanges::upbit_websocket_trading::UpbitWebSocketTrader;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
let config = UpbitAuthConfig::new("access_key".into(), "secret_key".into());
let auth = Arc::new(UpbitAuth::new(config));
let trader = UpbitWebSocketTrader::new(auth);
let (report_tx, report_rx) = flume::bounded(100);
// Connect and authenticate
trader.connect(report_tx).await?;
Ok(())
}Structs§
- Connection
Health - Connection health information
- Upbit
WebSocket Trader - Upbit WebSocket Trading Client
Enums§
- Upbit
Connection State - Upbit-specific connection state for proper state machine tracking