Skip to main content

bybit/models/linear_ticker/
linear_ticker_delta.rs

1use crate::prelude::*;
2
3#[derive(Clone, PartialEq, Deserialize, Serialize)]
4#[serde(rename_all = "camelCase")]
5#[serde(deny_unknown_fields)]
6pub struct LinearTickerDataDelta {
7    /// The trading pair symbol (e.g., "BTCUSDT").
8    ///
9    /// The ONLY required field for the ticker data. Bots use this to identify the market they are trading in.
10    ///
11    /// Identifies the perpetual futures contract for the ticker data. Bots use this to verify the correct market.
12    pub symbol: String,
13
14    /// The tick direction of the last price change.
15    ///
16    /// Indicates whether the last price change was an uptick or downtick (e.g., "PlusTick"). Bots use this to analyze short-term price momentum.
17    pub tick_direction: Option<TickDirection>,
18
19    /// The 24-hour price change percentage.
20    ///
21    /// The percentage change in price over the last 24 hours. Bots use this to assess market trends and volatility.
22    #[serde(default, with = "string_to_float_optional")]
23    pub price_24h_pcnt: Option<f64>,
24
25    /// The last traded price.
26    ///
27    /// The most recent price at which the contract was traded. Bots use this for real-time price tracking and technical analysis.
28    #[serde(default, with = "string_to_float_optional")]
29    pub last_price: Option<f64>,
30
31    /// The price 24 hours ago.
32    ///
33    /// The price of the contract 24 hours prior. Bots use this to calculate price changes and validate `price_24h_pcnt`.
34    #[serde(default, with = "string_to_float_optional")]
35    pub prev_price_24h: Option<f64>,
36
37    /// The highest price in the last 24 hours.
38    ///
39    /// The peak price reached in the last 24 hours. Bots use this to identify resistance levels and assess volatility.
40    #[serde(default, with = "string_to_float_optional")]
41    pub high_price_24h: Option<f64>,
42
43    /// The lowest price in the last 24 hours.
44    ///
45    /// The lowest price reached in the last 24 hours. Bots use this to identify support levels and assess volatility.
46    #[serde(default, with = "string_to_float_optional")]
47    pub low_price_24h: Option<f64>,
48
49    /// The price 1 hour ago.
50    ///
51    /// The price of the contract 1 hour prior. Bots use this to calculate short-term price changes and momentum.
52    #[serde(default, with = "string_to_float_optional")]
53    pub prev_price_1h: Option<f64>,
54
55    /// The open interest value in settlement currency.
56    ///
57    /// The monetary value of open interest (`open_interest` * `mark_price`). Bots use this to assess market exposure and leverage levels.
58    #[serde(default, with = "string_to_float_optional")]
59    pub open_interest_value: Option<f64>,
60
61    /// The 24-hour trading turnover.
62    ///
63    /// The total trading value in the last 24 hours, in settlement currency. Bots use this to assess market activity and liquidity.
64    #[serde(default, with = "string_to_float_optional")]
65    pub turnover_24h: Option<f64>,
66
67    /// The 24-hour trading volume.
68    ///
69    /// The total quantity of contracts traded in the last 24 hours. Bots use this to analyze market activity and trading intensity.
70    #[serde(default, with = "string_to_float_optional")]
71    pub volume_24h: Option<f64>,
72
73    /// The best bid price.
74    ///
75    /// The highest price at which someone is willing to buy. Bots use this to assess buy-side liquidity and calculate spreads.
76    #[serde(default, rename = "bid1Price", with = "string_to_float_optional")]
77    pub bid_price: Option<f64>,
78
79    /// The best bid size.
80    ///
81    /// The quantity available at the best bid price. Bots use this to evaluate buy-side liquidity and potential slippage.
82    #[serde(default, rename = "bid1Size", with = "string_to_float_optional")]
83    pub bid_size: Option<f64>,
84
85    /// The best ask price.
86    ///
87    /// The lowest price at which someone is willing to sell. Bots use this to assess sell-side liquidity and calculate spreads.
88    #[serde(default, rename = "ask1Price", with = "string_to_float_optional")]
89    pub ask_price: Option<f64>,
90
91    /// The best ask size.
92    ///
93    /// The quantity available at the best ask price. Bots use this to evaluate sell-side liquidity and potential slippage.
94    #[serde(default, rename = "ask1Size", with = "string_to_float_optional")]
95    pub ask_size: Option<f64>,
96
97    /// The pre-open price, set by Bybit for a trading pair before it enters
98    /// regular trading, often during phases like subscription, announcement,
99    /// or pre-trading for new pairs. This price guides early trading or
100    /// subscription activities.
101    #[serde(default, with = "string_to_float_optional")]
102    pub pre_open_price: Option<f64>,
103
104    /// The pre-open quantity, represents the indicative or reference price for
105    /// a trading pair during a pre-listing or pre-trading phase. This price is
106    /// typically set by the exchange to guide trading activity when the pair is
107    /// not yet fully open for unrestricted trading (e.g., during a subscription
108    /// or announcement phase for new pairs).
109    #[serde(default, with = "string_to_float_optional")]
110    pub pre_qty: Option<f64>,
111
112    /// Indicates the current stage of a trading pair in Bybit’s pre-listing
113    /// process. Pre-listing phases are used for new or upcoming trading pairs
114    /// that are not yet fully available for trading but may be in a preparatory
115    ///  or promotional stage.
116    pub cur_pre_listing_phase: Option<String>,
117
118    /// The current funding rate.
119    ///
120    /// The funding rate applied to positions, as a decimal (e.g., 0.0001 for 0.01%). Bots use this to calculate funding costs or profits for long/short positions.
121    #[serde(default, with = "string_to_float_optional")]
122    pub funding_rate: Option<f64>,
123
124    /// The timestamp of the next funding event in milliseconds.
125    ///
126    /// Indicates when the next funding rate payment will occur. Bots use this to schedule funding fee calculations and position adjustments.
127    #[serde(default, with = "string_to_u64_optional")]
128    pub next_funding_time: Option<u64>,
129
130    /// The current index price.
131    ///
132    /// The index price, based on external spot markets, used for reference in perpetual futures. Bots use this to compare with mark price for funding rate calculations.
133    #[serde(default, with = "string_to_float_optional")]
134    pub index_price: Option<f64>,
135
136    /// The current mark price.
137    ///
138    /// The mark price used for P&L calculations in perpetual futures. Bots use this to calculate unrealized P&L and assess position health.
139    #[serde(default, with = "string_to_float_optional")]
140    pub mark_price: Option<f64>,
141
142    /// The open interest in contracts.
143    ///
144    /// The total number of open contracts in the market. Bots use this to gauge market participation and liquidity.
145    #[serde(default, with = "string_to_float_optional")]
146    pub open_interest: Option<f64>,
147}
148
149impl std::fmt::Debug for LinearTickerDataDelta {
150    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
151        let mut debug_struct = fmt.debug_struct("LinearTickerDataDelta");
152
153        debug_struct.field("symbol", &self.symbol);
154
155        if let Some(index_price) = &self.index_price {
156            debug_struct.field("index_price", index_price);
157        }
158        if let Some(tick_direction) = &self.tick_direction {
159            debug_struct.field("tick_direction", tick_direction);
160        }
161        if let Some(price_24h_pcnt) = &self.price_24h_pcnt {
162            debug_struct.field("price_24h_pcnt", price_24h_pcnt);
163        }
164        if let Some(last_price) = &self.last_price {
165            debug_struct.field("last_price", last_price);
166        }
167        if let Some(prev_price_24h) = &self.prev_price_24h {
168            debug_struct.field("prev_price_24h", prev_price_24h);
169        }
170        if let Some(high_price_24h) = &self.high_price_24h {
171            debug_struct.field("high_price_24h", high_price_24h);
172        }
173        if let Some(low_price_24h) = &self.low_price_24h {
174            debug_struct.field("low_price_24h", low_price_24h);
175        }
176        if let Some(prev_price_1h) = &self.prev_price_1h {
177            debug_struct.field("prev_price_1h", prev_price_1h);
178        }
179        if let Some(mark_price) = &self.mark_price {
180            debug_struct.field("mark_price", mark_price);
181        }
182        if let Some(open_interest) = &self.open_interest {
183            debug_struct.field("open_interest", open_interest);
184        }
185        if let Some(open_interest_value) = &self.open_interest_value {
186            debug_struct.field("open_interest_value", open_interest_value);
187        }
188        if let Some(turnover_24h) = &self.turnover_24h {
189            debug_struct.field("turnover_24h", turnover_24h);
190        }
191        if let Some(volume_24h) = &self.volume_24h {
192            debug_struct.field("volume_24h", volume_24h);
193        }
194        if let Some(next_funding_time) = &self.next_funding_time {
195            debug_struct.field("next_funding_time", next_funding_time);
196        }
197        if let Some(funding_rate) = &self.funding_rate {
198            debug_struct.field("funding_rate", funding_rate);
199        }
200        if let Some(bid_price) = &self.bid_price {
201            debug_struct.field("bid_price", bid_price);
202        }
203        if let Some(bid_size) = &self.bid_size {
204            debug_struct.field("bid_size", bid_size);
205        }
206        if let Some(ask_price) = &self.ask_price {
207            debug_struct.field("ask_price", ask_price);
208        }
209        if let Some(ask_size) = &self.ask_size {
210            debug_struct.field("ask_size", ask_size);
211        }
212        if let Some(pre_qty) = &self.pre_qty {
213            debug_struct.field("pre_qty", pre_qty);
214        }
215        if let Some(cur_pre_listing_phase) = &self.cur_pre_listing_phase {
216            debug_struct.field("cur_pre_listing_phase", cur_pre_listing_phase);
217        }
218        if let Some(pre_open_price) = &self.pre_open_price {
219            debug_struct.field("pre_open_price", pre_open_price);
220        }
221
222        debug_struct.finish()
223    }
224}