Module bithumb_websocket_trading

Source
Expand description

Bithumb WebSocket Trading Implementation

This module provides a high-performance WebSocket trading client for Bithumb’s private endpoints with JWT authentication, real-time order updates, and asset tracking.

§Features

  • JWT authentication: Support for Bithumb’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
  • Automatic reconnection on connection loss
  • JWT token refresh before expiration
  • Configurable timeout handling

§Private Channels

Supports Bithumb’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::bithumb::BithumbAuth;
use rusty_ems::exchanges::bithumb_websocket_trading::BithumbWebSocketTrader;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<()> {
    let auth = Arc::new(BithumbAuth::new("access_key".into(), "secret_key".into()));

    let trader = BithumbWebSocketTrader::new(auth);
    let (report_tx, report_rx) = flume::bounded(100);

    // Connect and authenticate
    trader.connect(report_tx).await?;

    Ok(())
}

Structs§

BithumbConnectionHealth
Connection health information for Bithumb WebSocket
BithumbWebSocketTrader
Bithumb WebSocket Trading Client

Enums§

BithumbConnectionState
Bithumb-specific connection state for proper state machine tracking