tdx_rs/tdx_model/data/
daily_data.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct DailyData {
5    pub date: u32,
6    pub open: f64,
7    pub high: f64,
8    pub low: f64,
9    pub close: f64,
10    // last 4 bytes are padding and should be ignored
11}
12
13impl DailyData {
14    pub fn new(date: u32, open: f64, high: f64, low: f64, close: f64) -> Self {
15        Self {
16            date,
17            open,
18            high,
19            low,
20            close,
21        }
22    }
23}
24
25impl From<DailyData> for (u32, f64, f64, f64, f64) {
26    /// Convert `DailyData` to a tuple of `(date, open, high, low, close)`.
27    fn from(value: DailyData) -> Self {
28        (value.date, value.open, value.high, value.low, value.close)
29    }
30}