bybit/models/order_price_limit_request.rs
1use crate::prelude::*;
2
3/// Parameters for requesting order price limits.
4///
5/// This struct defines the parameters for querying order price limits via Bybit's `/v5/market/price-limit` endpoint.
6/// Order price limits define the highest bid price (buyLmt) and lowest ask price (sellLmt) for a given symbol.
7#[derive(Clone, Default)]
8pub struct OrderPriceLimitRequest<'a> {
9 /// The product category (e.g., Spot, Linear, Inverse).
10 ///
11 /// Specifies the type of instrument for the price limit data.
12 /// Valid values: `spot`, `linear`, `inverse`.
13 /// If not specified, defaults to `linear`.
14 pub category: Option<Category>,
15
16 /// The trading pair symbol (e.g., "BTCUSDT").
17 ///
18 /// Identifies the specific instrument for which to retrieve price limits.
19 /// Must be uppercase (e.g., "BTCUSDT", not "btcusdt").
20 pub symbol: Cow<'a, str>,
21}
22
23impl<'a> OrderPriceLimitRequest<'a> {
24 /// Creates a default order price limit request for BTCUSDT.
25 ///
26 /// Returns an `OrderPriceLimitRequest` with `symbol` set to `"BTCUSDT"` and no category specified.
27 /// This will default to `linear` category when sent to the API.
28 pub fn default() -> OrderPriceLimitRequest<'a> {
29 OrderPriceLimitRequest::new(None, "BTCUSDT")
30 }
31
32 /// Constructs a new order price limit request with specified parameters.
33 ///
34 /// # Arguments
35 /// * `category` - Optional product category (spot, linear, inverse)
36 /// * `symbol` - The trading pair symbol (e.g., "BTCUSDT")
37 pub fn new(category: Option<Category>, symbol: &'a str) -> OrderPriceLimitRequest<'a> {
38 OrderPriceLimitRequest {
39 category,
40 symbol: Cow::Borrowed(symbol),
41 }
42 }
43
44 /// Constructs a new order price limit request for linear perpetual contracts.
45 ///
46 /// # Arguments
47 /// * `symbol` - The trading pair symbol (e.g., "BTCUSDT")
48 pub fn linear(symbol: &'a str) -> OrderPriceLimitRequest<'a> {
49 OrderPriceLimitRequest::new(Some(Category::Linear), symbol)
50 }
51
52 /// Constructs a new order price limit request for inverse perpetual contracts.
53 ///
54 /// # Arguments
55 /// * `symbol` - The trading pair symbol (e.g., "BTCUSD")
56 pub fn inverse(symbol: &'a str) -> OrderPriceLimitRequest<'a> {
57 OrderPriceLimitRequest::new(Some(Category::Inverse), symbol)
58 }
59
60 /// Constructs a new order price limit request for spot trading.
61 ///
62 /// # Arguments
63 /// * `symbol` - The trading pair symbol (e.g., "BTCUSDT")
64 pub fn spot(symbol: &'a str) -> OrderPriceLimitRequest<'a> {
65 OrderPriceLimitRequest::new(Some(Category::Spot), symbol)
66 }
67}