deribit_websocket/
constants.rs

1//! Constants for WebSocket client
2
3/// Default heartbeat interval in seconds
4pub const DEFAULT_HEARTBEAT_INTERVAL: u64 = 30;
5
6/// Maximum reconnection attempts
7pub const MAX_RECONNECT_ATTEMPTS: u32 = 5;
8
9/// WebSocket URLs
10pub const PRODUCTION_WS_URL: &str = "wss://www.deribit.com/ws/api/v2";
11/// WebSocket URL for Deribit testnet
12pub const TESTNET_WS_URL: &str = "wss://test.deribit.com/ws/api/v2";
13
14/// JSON-RPC methods
15pub mod methods {
16    // Authentication
17    /// Public authentication method
18    pub const PUBLIC_AUTH: &str = "public/auth";
19    /// Private logout method
20    pub const PRIVATE_LOGOUT: &str = "private/logout";
21
22    // Subscriptions
23    /// Public subscription method
24    pub const PUBLIC_SUBSCRIBE: &str = "public/subscribe";
25    /// Public unsubscription method
26    pub const PUBLIC_UNSUBSCRIBE: &str = "public/unsubscribe";
27    /// Private subscription method
28    pub const PRIVATE_SUBSCRIBE: &str = "private/subscribe";
29    /// Private unsubscription method
30    pub const PRIVATE_UNSUBSCRIBE: &str = "private/unsubscribe";
31
32    // Market data
33    /// Get ticker information
34    pub const PUBLIC_GET_TICKER: &str = "public/ticker";
35    /// Get order book data
36    pub const PUBLIC_GET_ORDERBOOK: &str = "public/get_order_book";
37    /// Get trade history
38    pub const PUBLIC_GET_TRADES: &str = "public/get_last_trades_by_instrument";
39    /// Get instrument information
40    pub const PUBLIC_GET_INSTRUMENTS: &str = "public/get_instruments";
41
42    // Trading
43    /// Place buy order
44    pub const PRIVATE_BUY: &str = "private/buy";
45    /// Place sell order
46    pub const PRIVATE_SELL: &str = "private/sell";
47    /// Cancel specific order
48    pub const PRIVATE_CANCEL: &str = "private/cancel";
49    /// Cancel all orders
50    pub const PRIVATE_CANCEL_ALL: &str = "private/cancel_all";
51    /// Get open orders
52    pub const PRIVATE_GET_OPEN_ORDERS: &str = "private/get_open_orders";
53
54    // Account
55    /// Get account summary
56    pub const PRIVATE_GET_ACCOUNT_SUMMARY: &str = "private/get_account_summary";
57    /// Get positions
58    pub const PRIVATE_GET_POSITIONS: &str = "private/get_positions";
59    /// Get subaccounts
60    pub const PRIVATE_GET_SUBACCOUNTS: &str = "private/get_subaccounts";
61
62    // Test
63    /// Test connection
64    pub const PUBLIC_TEST: &str = "public/test";
65    /// Get server time
66    pub const PUBLIC_GET_TIME: &str = "public/get_time";
67    /// Hello message
68    pub const PUBLIC_HELLO: &str = "public/hello";
69}
70
71/// Subscription channels
72pub mod channels {
73    /// Ticker channel
74    pub const TICKER: &str = "ticker";
75    /// Order book channel
76    pub const ORDERBOOK: &str = "book";
77    /// Trades channel
78    pub const TRADES: &str = "trades";
79    /// User orders channel
80    pub const USER_ORDERS: &str = "user.orders";
81    /// User trades channel
82    pub const USER_TRADES: &str = "user.trades";
83    /// User portfolio channel
84    pub const USER_PORTFOLIO: &str = "user.portfolio";
85}