nautilus_binance/spot/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//! Query parameter builders for Binance Spot HTTP requests.
17
18use serde::Serialize;
19
20/// Query parameters for the depth endpoint.
21#[derive(Debug, Clone, Serialize)]
22pub struct DepthParams {
23    /// Trading pair symbol (e.g., "BTCUSDT").
24    pub symbol: String,
25    /// Number of price levels to return (default 100, max 5000).
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub limit: Option<u32>,
28}
29
30impl DepthParams {
31    /// Create new depth query params.
32    #[must_use]
33    pub fn new(symbol: impl Into<String>) -> Self {
34        Self {
35            symbol: symbol.into(),
36            limit: None,
37        }
38    }
39
40    /// Set the limit.
41    #[must_use]
42    pub fn with_limit(mut self, limit: u32) -> Self {
43        self.limit = Some(limit);
44        self
45    }
46}
47
48/// Query parameters for the trades endpoint.
49#[derive(Debug, Clone, Serialize)]
50pub struct TradesParams {
51    /// Trading pair symbol (e.g., "BTCUSDT").
52    pub symbol: String,
53    /// Number of trades to return (default 500, max 1000).
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub limit: Option<u32>,
56}
57
58impl TradesParams {
59    /// Create new trades query params.
60    #[must_use]
61    pub fn new(symbol: impl Into<String>) -> Self {
62        Self {
63            symbol: symbol.into(),
64            limit: None,
65        }
66    }
67
68    /// Set the limit.
69    #[must_use]
70    pub fn with_limit(mut self, limit: u32) -> Self {
71        self.limit = Some(limit);
72        self
73    }
74}