deribit_base/model/ticker.rs
1use serde::{Deserialize, Serialize};
2
3/// Ticker stats sub-structure
4#[derive(Clone, Serialize, Deserialize)]
5pub struct TickerStats {
6 /// Trading volume
7 pub volume: f64,
8 /// Price change from previous period
9 pub price_change: Option<f64>,
10 /// Highest price in the period
11 pub high: Option<f64>,
12 /// Lowest price in the period
13 pub low: Option<f64>,
14}
15
16/// Ticker data structure with corrected field types
17#[derive(Clone, Serialize, Deserialize)]
18pub struct TickerData {
19 /// Name of the instrument
20 pub instrument_name: String,
21 /// Last traded price
22 pub last_price: Option<f64>,
23 /// Current mark price
24 pub mark_price: f64,
25 /// Best bid price available
26 pub best_bid_price: Option<f64>,
27 /// Best ask price available
28 pub best_ask_price: Option<f64>,
29 /// Amount available at best bid price
30 pub best_bid_amount: f64,
31 /// Amount available at best ask price
32 pub best_ask_amount: f64,
33 /// Trading volume in base currency
34 pub volume: Option<f64>,
35 /// Trading volume in USD
36 pub volume_usd: Option<f64>,
37 /// Open interest for the instrument
38 pub open_interest: Option<f64>,
39 /// Highest price in 24h period
40 pub high: Option<f64>,
41 /// Lowest price in 24h period
42 pub low: Option<f64>,
43 /// Absolute price change in 24h
44 pub price_change: Option<f64>,
45 /// Percentage price change in 24h
46 pub price_change_percentage: Option<f64>,
47 /// Implied volatility at best bid
48 pub bid_iv: Option<f64>,
49 /// Implied volatility at best ask
50 pub ask_iv: Option<f64>,
51 /// Mark implied volatility
52 pub mark_iv: Option<f64>,
53 /// Timestamp of the ticker data
54 pub timestamp: u64,
55 /// Current state of the instrument
56 pub state: String,
57 /// Settlement price (for expired instruments)
58 pub settlement_price: Option<f64>,
59 /// Additional ticker statistics
60 pub stats: TickerStats,
61}
62
63crate::impl_json_display!(TickerData);
64crate::impl_json_debug_pretty!(TickerData);
65
66crate::impl_json_display!(TickerStats);
67crate::impl_json_debug_pretty!(TickerStats);