Skip to content

Commit 6d63ba9

Browse files
committed
Made several fields in TickerData non-optional, updated serialization behavior, and adjusted test assertions.
1 parent a1f98f3 commit 6d63ba9

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/model/ticker.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,17 @@ pub struct TickerData {
4848
#[serde(skip_serializing_if = "Option::is_none")]
4949
pub last_price: Option<f64>,
5050
/// Current mark price
51-
#[serde(skip_serializing_if = "Option::is_none")]
52-
pub mark_price: Option<f64>,
51+
pub mark_price: f64,
5352
/// Best bid price available
5453
#[serde(skip_serializing_if = "Option::is_none")]
5554
pub best_bid_price: Option<f64>,
5655
/// Best ask price available
5756
#[serde(skip_serializing_if = "Option::is_none")]
5857
pub best_ask_price: Option<f64>,
5958
/// Amount available at best bid price
60-
#[serde(skip_serializing_if = "Option::is_none")]
61-
pub best_bid_amount: Option<f64>,
59+
pub best_bid_amount: f64,
6260
/// Amount available at best ask price
63-
#[serde(skip_serializing_if = "Option::is_none")]
64-
pub best_ask_amount: Option<f64>,
61+
pub best_ask_amount: f64,
6562
/// Trading volume in base currency
6663
#[serde(skip_serializing_if = "Option::is_none")]
6764
pub volume: Option<f64>,
@@ -100,8 +97,7 @@ pub struct TickerData {
10097
#[serde(skip_serializing_if = "Option::is_none")]
10198
pub settlement_price: Option<f64>,
10299
/// Additional ticker statistics
103-
#[serde(skip_serializing_if = "Option::is_none")]
104-
pub stats: Option<TickerStats>,
100+
pub stats: TickerStats,
105101
/// Greeks for options (delta, gamma, vega, theta, rho)
106102
#[serde(skip_serializing_if = "Option::is_none")]
107103
pub greeks: Option<Greeks>,
@@ -191,11 +187,11 @@ mod tests {
191187
assert_eq!(ticker_data.timestamp, 1757433676689);
192188
assert_eq!(ticker_data.state, "open");
193189
assert_eq!(ticker_data.last_price, Some(0.0002));
194-
assert_eq!(ticker_data.mark_price, Some(0.0001));
190+
assert_eq!(ticker_data.mark_price, 0.0001);
195191
assert_eq!(ticker_data.best_bid_price, Some(0.0001));
196192
assert_eq!(ticker_data.best_ask_price, Some(0.0002));
197-
assert_eq!(ticker_data.best_bid_amount, Some(2.2));
198-
assert_eq!(ticker_data.best_ask_amount, Some(4.1));
193+
assert_eq!(ticker_data.best_bid_amount, 2.2);
194+
assert_eq!(ticker_data.best_ask_amount, 4.1);
199195
assert_eq!(ticker_data.open_interest, Some(18.6));
200196
assert_eq!(ticker_data.settlement_price, Some(2.533e-4));
201197
assert_eq!(ticker_data.min_price, Some(0.0001));
@@ -213,7 +209,7 @@ mod tests {
213209
assert_eq!(ticker_data.index_price, Some(110881.2));
214210

215211
// Verify stats
216-
let stats = ticker_data.stats.as_ref().expect("Stats should be present");
212+
let stats = ticker_data.stats.clone();
217213
assert_eq!(stats.high, Some(0.0002));
218214
assert_eq!(stats.low, Some(0.0001));
219215
assert_eq!(stats.price_change, Some(100.0));

0 commit comments

Comments
 (0)