nautilus_deribit/http/
query.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Deribit HTTP API query parameter builders.
17
18use derive_builder::Builder;
19use serde::{Deserialize, Serialize};
20
21use super::models::{DeribitCurrency, DeribitInstrumentKind};
22
23/// Query parameters for `/public/get_instruments` endpoint.
24#[derive(Clone, Debug, Deserialize, Serialize, Builder)]
25#[builder(setter(into, strip_option))]
26pub struct GetInstrumentsParams {
27    /// Currency filter
28    pub currency: DeribitCurrency,
29    /// Optional instrument kind filter
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[builder(default)]
32    pub kind: Option<DeribitInstrumentKind>,
33    /// Whether to include expired instruments
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[builder(default)]
36    pub expired: Option<bool>,
37}
38
39impl GetInstrumentsParams {
40    /// Creates a new builder for [`GetInstrumentsParams`].
41    #[must_use]
42    pub fn builder() -> GetInstrumentsParamsBuilder {
43        GetInstrumentsParamsBuilder::default()
44    }
45
46    /// Creates parameters for a specific currency.
47    #[must_use]
48    pub fn new(currency: DeribitCurrency) -> Self {
49        Self {
50            currency,
51            kind: None,
52            expired: None,
53        }
54    }
55
56    /// Creates parameters for a specific currency and kind.
57    #[must_use]
58    pub fn with_kind(currency: DeribitCurrency, kind: DeribitInstrumentKind) -> Self {
59        Self {
60            currency,
61            kind: Some(kind),
62            expired: None,
63        }
64    }
65}
66
67/// Query parameters for `/public/get_instrument` endpoint.
68#[derive(Clone, Debug, Deserialize, Serialize, Builder)]
69pub struct GetInstrumentParams {
70    /// Instrument name (e.g., "BTC-PERPETUAL", "ETH-25MAR23-2000-C")
71    pub instrument_name: String,
72}
73
74/// Query parameters for `/private/get_account_summaries` endpoint.
75#[derive(Clone, Debug, Default, Deserialize, Serialize)]
76pub struct GetAccountSummariesParams {
77    /// The user id for the subaccount.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub subaccount_id: Option<String>,
80    /// Include extended fields
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub extended: Option<bool>,
83}
84
85impl GetAccountSummariesParams {
86    /// Creates a new instance with both subaccount ID and extended flag.
87    #[must_use]
88    pub fn new(subaccount_id: String, extended: bool) -> Self {
89        Self {
90            subaccount_id: Some(subaccount_id),
91            extended: Some(extended),
92        }
93    }
94}