Skip to main content

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    /// Public unsubscribe from all channels
28    pub const PUBLIC_UNSUBSCRIBE_ALL: &str = "public/unsubscribe_all";
29    /// Private subscription method
30    pub const PRIVATE_SUBSCRIBE: &str = "private/subscribe";
31    /// Private unsubscription method
32    pub const PRIVATE_UNSUBSCRIBE: &str = "private/unsubscribe";
33    /// Private unsubscribe from all channels
34    pub const PRIVATE_UNSUBSCRIBE_ALL: &str = "private/unsubscribe_all";
35
36    // Session management
37    /// Set heartbeat interval
38    pub const PUBLIC_SET_HEARTBEAT: &str = "public/set_heartbeat";
39    /// Disable heartbeat
40    pub const PUBLIC_DISABLE_HEARTBEAT: &str = "public/disable_heartbeat";
41
42    // Market data
43    /// Get ticker information
44    pub const PUBLIC_GET_TICKER: &str = "public/ticker";
45    /// Get order book data
46    pub const PUBLIC_GET_ORDERBOOK: &str = "public/get_order_book";
47    /// Get trade history
48    pub const PUBLIC_GET_TRADES: &str = "public/get_last_trades_by_instrument";
49    /// Get instrument information
50    pub const PUBLIC_GET_INSTRUMENTS: &str = "public/get_instruments";
51
52    // Trading
53    /// Place buy order
54    pub const PRIVATE_BUY: &str = "private/buy";
55    /// Place sell order
56    pub const PRIVATE_SELL: &str = "private/sell";
57    /// Cancel specific order
58    pub const PRIVATE_CANCEL: &str = "private/cancel";
59    /// Cancel all orders
60    pub const PRIVATE_CANCEL_ALL: &str = "private/cancel_all";
61    /// Cancel all orders by currency
62    pub const PRIVATE_CANCEL_ALL_BY_CURRENCY: &str = "private/cancel_all_by_currency";
63    /// Cancel all orders by instrument
64    pub const PRIVATE_CANCEL_ALL_BY_INSTRUMENT: &str = "private/cancel_all_by_instrument";
65    /// Edit an existing order
66    pub const PRIVATE_EDIT: &str = "private/edit";
67    /// Get open orders
68    pub const PRIVATE_GET_OPEN_ORDERS: &str = "private/get_open_orders";
69
70    // Account
71    /// Get account summary
72    pub const PRIVATE_GET_ACCOUNT_SUMMARY: &str = "private/get_account_summary";
73    /// Get positions
74    pub const PRIVATE_GET_POSITIONS: &str = "private/get_positions";
75    /// Get subaccounts
76    pub const PRIVATE_GET_SUBACCOUNTS: &str = "private/get_subaccounts";
77    /// Get order state
78    pub const PRIVATE_GET_ORDER_STATE: &str = "private/get_order_state";
79    /// Get order history by currency
80    pub const PRIVATE_GET_ORDER_HISTORY_BY_CURRENCY: &str = "private/get_order_history_by_currency";
81
82    // Position management
83    /// Close an existing position
84    pub const PRIVATE_CLOSE_POSITION: &str = "private/close_position";
85    /// Move positions between subaccounts
86    pub const PRIVATE_MOVE_POSITIONS: &str = "private/move_positions";
87
88    // Cancel-on-disconnect
89    /// Enable cancel-on-disconnect
90    pub const PRIVATE_ENABLE_CANCEL_ON_DISCONNECT: &str = "private/enable_cancel_on_disconnect";
91    /// Disable cancel-on-disconnect
92    pub const PRIVATE_DISABLE_CANCEL_ON_DISCONNECT: &str = "private/disable_cancel_on_disconnect";
93    /// Get cancel-on-disconnect status
94    pub const PRIVATE_GET_CANCEL_ON_DISCONNECT: &str = "private/get_cancel_on_disconnect";
95
96    // Test
97    /// Test connection
98    pub const PUBLIC_TEST: &str = "public/test";
99    /// Get server time
100    pub const PUBLIC_GET_TIME: &str = "public/get_time";
101    /// Hello message
102    pub const PUBLIC_HELLO: &str = "public/hello";
103}
104
105/// Subscription channels
106pub mod channels {
107    /// Ticker channel
108    pub const TICKER: &str = "ticker";
109    /// Order book channel
110    pub const ORDERBOOK: &str = "book";
111    /// Trades channel
112    pub const TRADES: &str = "trades";
113    /// User orders channel
114    pub const USER_ORDERS: &str = "user.orders";
115    /// User trades channel
116    pub const USER_TRADES: &str = "user.trades";
117    /// User portfolio channel
118    pub const USER_PORTFOLIO: &str = "user.portfolio";
119    /// Incremental ticker channel
120    pub const INCREMENTAL_TICKER: &str = "incremental_ticker";
121    /// Price ranking channel
122    pub const PRICE_RANKING: &str = "deribit_price_ranking";
123    /// Price statistics channel
124    pub const PRICE_STATISTICS: &str = "deribit_price_statistics";
125    /// Volatility index channel
126    pub const VOLATILITY_INDEX: &str = "deribit_volatility_index";
127    /// Platform state channel
128    pub const PLATFORM_STATE: &str = "platform_state";
129    /// Platform state public methods channel
130    pub const PLATFORM_STATE_PUBLIC_METHODS: &str = "platform_state.public_methods_state";
131    /// Instrument state channel
132    pub const INSTRUMENT_STATE: &str = "instrument.state";
133    /// Perpetual channel
134    pub const PERPETUAL: &str = "perpetual";
135    /// Mark price options channel
136    pub const MARKPRICE_OPTIONS: &str = "markprice.options";
137    /// Quote channel
138    pub const QUOTE: &str = "quote";
139    /// Block RFQ trades channel
140    pub const BLOCK_RFQ_TRADES: &str = "block_rfq.trades";
141    /// Block trade confirmations channel
142    pub const BLOCK_TRADE_CONFIRMATIONS: &str = "block_trade_confirmations";
143    /// User MMP trigger channel
144    pub const USER_MMP_TRIGGER: &str = "user.mmp_trigger";
145    /// User access log channel
146    pub const USER_ACCESS_LOG: &str = "user.access_log";
147    /// User lock channel
148    pub const USER_LOCK: &str = "user.lock";
149}