1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! # Deribit Exchange Connector
//!
//! Full implementation of Deribit derivatives exchange connector.
//!
//! ## Overview
//!
//! Deribit is a cryptocurrency derivatives exchange specializing in:
//! - Bitcoin (BTC) and Ethereum (ETH) options and futures
//! - USDC-settled linear instruments (SOL, XRP, etc.)
//! - Perpetual contracts (inverse and linear)
//! - European-style options
//!
//! ## Key Characteristics
//!
//! - **Protocol**: JSON-RPC 2.0 (over HTTP and WebSocket)
//! - **Authentication**: OAuth 2.0 (access token + refresh token)
//! - **Rate Limits**: Credit-based system
//! - **Settlement**: Cash settlement only (no physical delivery)
//! - **WebSocket**: Preferred transport for real-time data
//!
//! ## Module Structure
//!
//! - `endpoints` - JSON-RPC methods, URLs, symbol formatting
//! - `auth` - OAuth 2.0 authentication (client credentials, client signature)
//! - `parser` - JSON-RPC response parsing (REST and WebSocket)
//! - `connector` - DeribitConnector + trait implementations
//! - `websocket` - WebSocket client (subscriptions, notifications)
//!
//! ## Usage
//!
//! ```ignore
//! use connectors_v5::exchanges::deribit::DeribitConnector;
//! use connectors_v5::core::{Credentials, AccountType, Symbol};
//! use connectors_v5::core::traits::MarketData;
//!
//! // Create connector
//! let credentials = Credentials::new("client_id", "client_secret");
//! let connector = DeribitConnector::new(Some(credentials), false).await?;
//!
//! // Get market data
//! let symbol = Symbol::new("BTC", "USD");
//! let price = connector.get_price(&symbol, AccountType::FuturesCross).await?;
//!
//! // Place order
//! use connectors_v5::core::traits::Trading;
//! use connectors_v5::core::types::OrderSide;
//! let order = connector.market_order(&symbol, OrderSide::Buy, 100.0, AccountType::FuturesCross).await?;
//! ```
//!
//! ## Instrument Name Formats
//!
//! - **Perpetuals**: `BTC-PERPETUAL`, `ETH-PERPETUAL`
//! - **Linear Perpetuals**: `SOL_USDC-PERPETUAL`, `XRP_USDC-PERPETUAL`
//! - **Futures**: `BTC-29MAR24`, `ETH-27DEC24`
//! - **Options**: `BTC-27DEC24-50000-C`, `ETH-29MAR24-3000-P`
//!
//! ## Authentication
//!
//! Deribit uses OAuth 2.0:
//! 1. Call `public/auth` with client credentials or client signature
//! 2. Receive access token (15 min expiry) and refresh token
//! 3. Use `Authorization: Bearer {token}` header for private requests
//! 4. Refresh token proactively before expiration
//!
//! ## JSON-RPC Format
//!
//! All requests use JSON-RPC 2.0:
//!
//! ```json
//! {
//! "jsonrpc": "2.0",
//! "id": 1,
//! "method": "public/get_instruments",
//! "params": {
//! "currency": "BTC",
//! "kind": "future"
//! }
//! }
//! ```
//!
//! Response:
//!
//! ```json
//! {
//! "jsonrpc": "2.0",
//! "id": 1,
//! "result": [ /* data */ ],
//! "testnet": false,
//! "usIn": 1234567890,
//! "usOut": 1234567892,
//! "usDiff": 2
//! }
//! ```
pub use ;
pub use DeribitAuth;
pub use DeribitParser;
pub use DeribitConnector;
pub use DeribitWebSocket;