Skip to main content

deribit_http/
constants.rs

1//! HTTP client constants
2
3/// Default timeout for HTTP requests in seconds
4pub const DEFAULT_TIMEOUT: u64 = 30;
5
6/// Maximum number of retries for failed requests
7pub const MAX_RETRIES: u32 = 3;
8
9/// Production base URL for Deribit API
10pub const PRODUCTION_BASE_URL: &str = "https://www.deribit.com/api/v2";
11
12/// Testnet base URL for Deribit API
13pub const TESTNET_BASE_URL: &str = "https://test.deribit.com/api/v2";
14
15/// API endpoints
16pub mod endpoints {
17    // Authentication endpoints
18    /// Public authentication endpoint
19    pub const AUTH: &str = "/public/auth";
20
21    // Public market data endpoints
22    /// Get ticker information for an instrument
23    pub const GET_TICKER: &str = "/public/ticker";
24    /// Get instrument information by name
25    pub const GET_INSTRUMENT: &str = "/public/get_instrument";
26    /// Get list of available instruments
27    pub const GET_INSTRUMENTS: &str = "/public/get_instruments";
28    /// Get order book for an instrument
29    pub const GET_ORDER_BOOK: &str = "/public/get_order_book";
30    /// Get book summary by currency
31    pub const GET_BOOK_SUMMARY_BY_CURRENCY: &str = "/public/get_book_summary_by_currency";
32    /// Get book summary by instrument
33    pub const GET_BOOK_SUMMARY_BY_INSTRUMENT: &str = "/public/get_book_summary_by_instrument";
34    /// Get contract size for an instrument
35    pub const GET_CONTRACT_SIZE: &str = "/public/get_contract_size";
36    /// Get list of available currencies
37    pub const GET_CURRENCIES: &str = "/public/get_currencies";
38    /// Get index information
39    pub const GET_INDEX: &str = "/public/get_index";
40    /// Get index price
41    pub const GET_INDEX_PRICE: &str = "/public/get_index_price";
42    /// Get index price names
43    pub const GET_INDEX_PRICE_NAMES: &str = "/public/get_index_price_names";
44    /// Get server time
45    pub const GET_SERVER_TIME: &str = "/public/get_time";
46    /// Test connection to the API
47    pub const TEST_CONNECTION: &str = "/public/test";
48    /// Get API status
49    pub const GET_STATUS: &str = "/public/status";
50    /// Get APR history
51    pub const GET_APR_HISTORY: &str = "/public/get_apr_history";
52    /// Get options information
53    pub const GET_OPTIONS: &str = "/public/get_options";
54    /// Get options pair information
55    pub const GET_OPTIONS_PAIR: &str = "/public/get_options_pair";
56    /// Get last trades by instrument
57    pub const GET_LAST_TRADES_BY_INSTRUMENT: &str = "/public/get_last_trades_by_instrument";
58    /// Get historical volatility data
59    pub const GET_HISTORICAL_VOLATILITY: &str = "/public/get_historical_volatility";
60    /// Get funding chart data
61    pub const GET_FUNDING_CHART_DATA: &str = "/public/get_funding_chart_data";
62    /// Get TradingView chart data
63    pub const GET_TRADINGVIEW_CHART_DATA: &str = "/public/get_tradingview_chart_data";
64    /// Get delivery prices
65    pub const GET_DELIVERY_PRICES: &str = "/public/get_delivery_prices";
66    /// Get expiration dates
67    pub const GET_EXPIRATIONS: &str = "/public/get_expirations";
68    /// Get funding rate history
69    pub const GET_FUNDING_RATE_HISTORY: &str = "/public/get_funding_rate_history";
70    /// Get current funding rate value
71    pub const GET_FUNDING_RATE_VALUE: &str = "/public/get_funding_rate_value";
72    /// Get last settlements by currency
73    pub const GET_LAST_SETTLEMENTS_BY_CURRENCY: &str = "/public/get_last_settlements_by_currency";
74    /// Get last settlements by instrument
75    pub const GET_LAST_SETTLEMENTS_BY_INSTRUMENT: &str =
76        "/public/get_last_settlements_by_instrument";
77    /// Get last trades by currency
78    pub const GET_LAST_TRADES_BY_CURRENCY: &str = "/public/get_last_trades_by_currency";
79    /// Get last trades by currency and time
80    pub const GET_LAST_TRADES_BY_CURRENCY_AND_TIME: &str =
81        "/public/get_last_trades_by_currency_and_time";
82    /// Get last trades by instrument and time
83    pub const GET_LAST_TRADES_BY_INSTRUMENT_AND_TIME: &str =
84        "/public/get_last_trades_by_instrument_and_time";
85    /// Get order book by instrument ID
86    pub const GET_ORDER_BOOK_BY_INSTRUMENT_ID: &str = "/public/get_order_book_by_instrument_id";
87    /// Get mark price history
88    pub const GET_MARK_PRICE_HISTORY: &str = "/public/get_mark_price_history";
89    /// Get supported index names
90    pub const GET_SUPPORTED_INDEX_NAMES: &str = "/public/get_supported_index_names";
91    /// Get trade volumes
92    pub const GET_TRADE_VOLUMES: &str = "/public/get_trade_volumes";
93    /// Get volatility index data
94    pub const GET_VOLATILITY_INDEX_DATA: &str = "/public/get_volatility_index_data";
95    /// Get index chart data
96    pub const GET_INDEX_CHART_DATA: &str = "/public/get_index_chart_data";
97
98    // Public combo books endpoints
99    /// Get combo details by ID
100    pub const GET_COMBO_DETAILS: &str = "/public/get_combo_details";
101    /// Get list of combo IDs by currency and state
102    pub const GET_COMBO_IDS: &str = "/public/get_combo_ids";
103    /// Get all active combos by currency
104    pub const GET_COMBOS: &str = "/public/get_combos";
105
106    // Private combo books endpoints
107    /// Create or verify a combo book
108    pub const CREATE_COMBO: &str = "/private/create_combo";
109    /// Get individual leg prices for a combo structure
110    pub const GET_LEG_PRICES: &str = "/private/get_leg_prices";
111
112    // Private trading endpoints
113    /// Place a buy order
114    pub const BUY: &str = "/private/buy";
115    /// Place a sell order
116    pub const SELL: &str = "/private/sell";
117    /// Cancel a specific order
118    pub const CANCEL: &str = "/private/cancel";
119    /// Cancel all orders
120    pub const CANCEL_ALL: &str = "/private/cancel_all";
121    /// Cancel all orders by currency
122    pub const CANCEL_ALL_BY_CURRENCY: &str = "/private/cancel_all_by_currency";
123    /// Cancel all orders by currency pair
124    pub const CANCEL_ALL_BY_CURRENCY_PAIR: &str = "/private/cancel_all_by_currency_pair";
125    /// Cancel all orders by instrument
126    pub const CANCEL_ALL_BY_INSTRUMENT: &str = "/private/cancel_all_by_instrument";
127    /// Cancel all orders by kind or type
128    pub const CANCEL_ALL_BY_KIND_OR_TYPE: &str = "/private/cancel_all_by_kind_or_type";
129    /// Cancel orders by label
130    pub const CANCEL_BY_LABEL: &str = "/private/cancel_by_label";
131    /// Edit order
132    pub const EDIT: &str = "/private/edit";
133    /// Edit order by label
134    pub const EDIT_BY_LABEL: &str = "/private/edit_by_label";
135    /// Cancel quotes
136    pub const CANCEL_QUOTES: &str = "/private/cancel_quotes";
137    /// Close an existing position
138    pub const CLOSE_POSITION: &str = "/private/close_position";
139    /// Get margin requirements
140    pub const GET_MARGINS: &str = "/private/get_margins";
141    /// Get MMP configuration
142    pub const GET_MMP_CONFIG: &str = "/private/get_mmp_config";
143    /// Get MMP status
144    pub const GET_MMP_STATUS: &str = "/private/get_mmp_status";
145    /// Set MMP configuration
146    pub const SET_MMP_CONFIG: &str = "/private/set_mmp_config";
147    /// Reset MMP limits
148    pub const RESET_MMP: &str = "/private/reset_mmp";
149    /// Get order margin by IDs
150    pub const GET_ORDER_MARGIN_BY_IDS: &str = "/private/get_order_margin_by_ids";
151    /// Get order state by label
152    pub const GET_ORDER_STATE_BY_LABEL: &str = "/private/get_order_state_by_label";
153    /// Get settlement history by currency
154    pub const GET_SETTLEMENT_HISTORY_BY_CURRENCY: &str =
155        "/private/get_settlement_history_by_currency";
156    /// Get settlement history by instrument
157    pub const GET_SETTLEMENT_HISTORY_BY_INSTRUMENT: &str =
158        "/private/get_settlement_history_by_instrument";
159    /// Get trigger order history
160    pub const GET_TRIGGER_ORDER_HISTORY: &str = "/private/get_trigger_order_history";
161
162    // Private account endpoints
163    /// Get account summary information
164    pub const GET_ACCOUNT_SUMMARY: &str = "/private/get_account_summary";
165    /// Get account summaries for all currencies
166    pub const GET_ACCOUNT_SUMMARIES: &str = "/private/get_account_summaries";
167    /// Get position
168    pub const GET_POSITION: &str = "/private/get_position";
169    /// Get current positions
170    pub const GET_POSITIONS: &str = "/private/get_positions";
171    /// Get subaccount information
172    pub const GET_SUBACCOUNTS: &str = "/private/get_subaccounts";
173    /// Get subaccounts details with positions
174    pub const GET_SUBACCOUNTS_DETAILS: &str = "/private/get_subaccounts_details";
175    /// Create a new subaccount
176    pub const CREATE_SUBACCOUNT: &str = "/private/create_subaccount";
177    /// Remove an empty subaccount
178    pub const REMOVE_SUBACCOUNT: &str = "/private/remove_subaccount";
179    /// Change the name of a subaccount
180    pub const CHANGE_SUBACCOUNT_NAME: &str = "/private/change_subaccount_name";
181    /// Enable or disable login for a subaccount
182    pub const TOGGLE_SUBACCOUNT_LOGIN: &str = "/private/toggle_subaccount_login";
183    /// Set email address for a subaccount
184    pub const SET_EMAIL_FOR_SUBACCOUNT: &str = "/private/set_email_for_subaccount";
185    /// Enable or disable notifications for a subaccount
186    pub const TOGGLE_NOTIFICATIONS_FROM_SUBACCOUNT: &str =
187        "/private/toggle_notifications_from_subaccount";
188    /// Get transaction log
189    pub const GET_TRANSACTION_LOG: &str = "/private/get_transaction_log";
190    /// Get deposits
191    pub const GET_DEPOSITS: &str = "/private/get_deposits";
192    /// Get withdrawals
193    pub const GET_WITHDRAWALS: &str = "/private/get_withdrawals";
194    /// Submit transfer to subaccount
195    pub const SUBMIT_TRANSFER_TO_SUBACCOUNT: &str = "/private/submit_transfer_to_subaccount";
196    /// Submit transfer to user
197    pub const SUBMIT_TRANSFER_TO_USER: &str = "/private/submit_transfer_to_user";
198    /// Get transfers list
199    pub const GET_TRANSFERS: &str = "/private/get_transfers";
200    /// Cancel a transfer by ID
201    pub const CANCEL_TRANSFER_BY_ID: &str = "/private/cancel_transfer_by_id";
202    /// Submit transfer between subaccounts
203    pub const SUBMIT_TRANSFER_BETWEEN_SUBACCOUNTS: &str =
204        "/private/submit_transfer_between_subaccounts";
205    /// Move positions between subaccounts
206    pub const MOVE_POSITIONS: &str = "/private/move_positions";
207
208    // Private order endpoints
209    /// Get all open orders
210    pub const GET_OPEN_ORDERS: &str = "/private/get_open_orders";
211    /// Get open orders by label
212    pub const GET_OPEN_ORDERS_BY_LABEL: &str = "/private/get_open_orders_by_label";
213    /// Get order state
214    pub const GET_ORDER_STATE: &str = "/private/get_order_state";
215    /// Get open orders by currency
216    pub const GET_OPEN_ORDERS_BY_CURRENCY: &str = "/private/get_open_orders_by_currency";
217    /// Get open orders by instrument
218    pub const GET_OPEN_ORDERS_BY_INSTRUMENT: &str = "/private/get_open_orders_by_instrument";
219    /// Get order history by currency
220    pub const GET_ORDER_HISTORY_BY_CURRENCY: &str = "/private/get_order_history_by_currency";
221    /// Get order history by instrument
222    pub const GET_ORDER_HISTORY_BY_INSTRUMENT: &str = "/private/get_order_history_by_instrument";
223
224    // Private trade endpoints
225    /// Get user trades by instrument
226    pub const GET_USER_TRADES_BY_INSTRUMENT: &str = "/private/get_user_trades_by_instrument";
227    /// Get user trades by currency
228    pub const GET_USER_TRADES_BY_CURRENCY: &str = "/private/get_user_trades_by_currency";
229    /// Get user trades by currency and time
230    pub const GET_USER_TRADES_BY_CURRENCY_AND_TIME: &str =
231        "/private/get_user_trades_by_currency_and_time";
232    /// Get user trades by instrument and time
233    pub const GET_USER_TRADES_BY_INSTRUMENT_AND_TIME: &str =
234        "/private/get_user_trades_by_instrument_and_time";
235    /// Get user trades by order
236    pub const GET_USER_TRADES_BY_ORDER: &str = "/private/get_user_trades_by_order";
237
238    // API Key Management endpoints
239    /// Create a new API key
240    pub const CREATE_API_KEY: &str = "/private/create_api_key";
241    /// Edit an existing API key
242    pub const EDIT_API_KEY: &str = "/private/edit_api_key";
243    /// Disable an API key
244    pub const DISABLE_API_KEY: &str = "/private/disable_api_key";
245    /// Enable an API key
246    pub const ENABLE_API_KEY: &str = "/private/enable_api_key";
247    /// List all API keys
248    pub const LIST_API_KEYS: &str = "/private/list_api_keys";
249    /// Remove an API key
250    pub const REMOVE_API_KEY: &str = "/private/remove_api_key";
251    /// Reset an API key secret
252    pub const RESET_API_KEY: &str = "/private/reset_api_key";
253    /// Change API key name
254    pub const CHANGE_API_KEY_NAME: &str = "/private/change_api_key_name";
255    /// Change API key scope
256    pub const CHANGE_SCOPE_IN_API_KEY: &str = "/private/change_scope_in_api_key";
257
258    // Address Beneficiary endpoints
259    /// Save address beneficiary information
260    pub const SAVE_ADDRESS_BENEFICIARY: &str = "/private/save_address_beneficiary";
261    /// Delete address beneficiary information
262    pub const DELETE_ADDRESS_BENEFICIARY: &str = "/private/delete_address_beneficiary";
263    /// Get address beneficiary information
264    pub const GET_ADDRESS_BENEFICIARY: &str = "/private/get_address_beneficiary";
265    /// List address beneficiaries with pagination
266    pub const LIST_ADDRESS_BENEFICIARIES: &str = "/private/list_address_beneficiaries";
267    /// Set clearance originator for a deposit
268    pub const SET_CLEARANCE_ORIGINATOR: &str = "/private/set_clearance_originator";
269
270    // Wallet endpoints
271    /// Create a new withdrawal request
272    pub const WITHDRAW: &str = "/private/withdraw";
273    /// Cancel a pending withdrawal
274    pub const CANCEL_WITHDRAWAL: &str = "/private/cancel_withdrawal";
275    /// Create a new deposit address
276    pub const CREATE_DEPOSIT_ADDRESS: &str = "/private/create_deposit_address";
277    /// Get the current deposit address
278    pub const GET_CURRENT_DEPOSIT_ADDRESS: &str = "/private/get_current_deposit_address";
279    /// Add an address to the address book
280    pub const ADD_TO_ADDRESS_BOOK: &str = "/private/add_to_address_book";
281    /// Remove an address from the address book
282    pub const REMOVE_FROM_ADDRESS_BOOK: &str = "/private/remove_from_address_book";
283    /// Update an address in the address book
284    pub const UPDATE_IN_ADDRESS_BOOK: &str = "/private/update_in_address_book";
285    /// Get addresses from the address book
286    pub const GET_ADDRESS_BOOK: &str = "/private/get_address_book";
287
288    // Remaining account endpoints
289    /// Get account access log
290    pub const GET_ACCESS_LOG: &str = "/private/get_access_log";
291    /// Get user account locks
292    pub const GET_USER_LOCKS: &str = "/private/get_user_locks";
293    /// List custody accounts
294    pub const LIST_CUSTODY_ACCOUNTS: &str = "/private/list_custody_accounts";
295    /// Simulate portfolio margin
296    pub const SIMULATE_PORTFOLIO: &str = "/private/simulate_portfolio";
297    /// PME margin simulation
298    pub const PME_SIMULATE: &str = "/private/pme/simulate";
299    /// Change margin model
300    pub const CHANGE_MARGIN_MODEL: &str = "/private/change_margin_model";
301    /// Set self-trading configuration
302    pub const SET_SELF_TRADING_CONFIG: &str = "/private/set_self_trading_config";
303    /// Set disabled trading products
304    pub const SET_DISABLED_TRADING_PRODUCTS: &str = "/private/set_disabled_trading_products";
305    /// Get public announcements
306    pub const GET_ANNOUNCEMENTS: &str = "/public/get_announcements";
307    /// Get new (unread) announcements
308    pub const GET_NEW_ANNOUNCEMENTS: &str = "/private/get_new_announcements";
309    /// Mark announcement as read
310    pub const SET_ANNOUNCEMENT_AS_READ: &str = "/private/set_announcement_as_read";
311    /// Enable affiliate program
312    pub const ENABLE_AFFILIATE_PROGRAM: &str = "/private/enable_affiliate_program";
313    /// Get affiliate program information
314    pub const GET_AFFILIATE_PROGRAM_INFO: &str = "/private/get_affiliate_program_info";
315    /// Set email language preference
316    pub const SET_EMAIL_LANGUAGE: &str = "/private/set_email_language";
317    /// Get email language preference
318    pub const GET_EMAIL_LANGUAGE: &str = "/private/get_email_language";
319
320    // Block Trade endpoints
321    /// Approve a pending block trade
322    pub const APPROVE_BLOCK_TRADE: &str = "/private/approve_block_trade";
323    /// Execute a block trade with counterparty signature
324    pub const EXECUTE_BLOCK_TRADE: &str = "/private/execute_block_trade";
325    /// Get a specific block trade by ID
326    pub const GET_BLOCK_TRADE: &str = "/private/get_block_trade";
327    /// Get pending block trade requests
328    pub const GET_BLOCK_TRADE_REQUESTS: &str = "/private/get_block_trade_requests";
329    /// List block trades with optional filters
330    pub const GET_BLOCK_TRADES: &str = "/private/get_block_trades";
331    /// Get broker trade requests
332    pub const GET_BROKER_TRADE_REQUESTS: &str = "/private/get_broker_trade_requests";
333    /// List broker trades
334    pub const GET_BROKER_TRADES: &str = "/private/get_broker_trades";
335    /// Invalidate a block trade signature
336    pub const INVALIDATE_BLOCK_TRADE_SIGNATURE: &str = "/private/invalidate_block_trade_signature";
337    /// Reject a pending block trade
338    pub const REJECT_BLOCK_TRADE: &str = "/private/reject_block_trade";
339    /// Simulate if a block trade can be executed
340    pub const SIMULATE_BLOCK_TRADE: &str = "/private/simulate_block_trade";
341    /// Verify and create a block trade signature
342    pub const VERIFY_BLOCK_TRADE: &str = "/private/verify_block_trade";
343
344    // Block RFQ endpoints
345    /// Get recent Block RFQ trades (public)
346    pub const GET_BLOCK_RFQ_TRADES: &str = "/public/get_block_rfq_trades";
347    /// Create a new Block RFQ (taker)
348    pub const CREATE_BLOCK_RFQ: &str = "/private/create_block_rfq";
349    /// Cancel a Block RFQ (taker)
350    pub const CANCEL_BLOCK_RFQ: &str = "/private/cancel_block_rfq";
351    /// Accept a Block RFQ quote (taker)
352    pub const ACCEPT_BLOCK_RFQ: &str = "/private/accept_block_rfq";
353    /// Get list of Block RFQs
354    pub const GET_BLOCK_RFQS: &str = "/private/get_block_rfqs";
355    /// Get open quotes for Block RFQs (maker)
356    pub const GET_BLOCK_RFQ_QUOTES: &str = "/private/get_block_rfq_quotes";
357    /// Add a quote to a Block RFQ (maker)
358    pub const ADD_BLOCK_RFQ_QUOTE: &str = "/private/add_block_rfq_quote";
359    /// Edit a Block RFQ quote (maker)
360    pub const EDIT_BLOCK_RFQ_QUOTE: &str = "/private/edit_block_rfq_quote";
361    /// Cancel a single Block RFQ quote (maker)
362    pub const CANCEL_BLOCK_RFQ_QUOTE: &str = "/private/cancel_block_rfq_quote";
363    /// Cancel all Block RFQ quotes (maker)
364    pub const CANCEL_ALL_BLOCK_RFQ_QUOTES: &str = "/private/cancel_all_block_rfq_quotes";
365}
366
367/// HTTP headers
368pub mod headers {
369    /// Content-Type header name
370    pub const CONTENT_TYPE: &str = "Content-Type";
371    /// JSON content type value
372    pub const APPLICATION_JSON: &str = "application/json";
373    /// Authorization header name
374    pub const AUTHORIZATION: &str = "Authorization";
375    /// User-Agent header name
376    pub const USER_AGENT: &str = "User-Agent";
377}