finance_query/adapters/fmp/
models.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum Period {
12 Annual,
14 Quarter,
16}
17
18impl Period {
19 pub fn as_str(&self) -> &'static str {
21 match self {
22 Self::Annual => "annual",
23 Self::Quarter => "quarter",
24 }
25 }
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
34#[non_exhaustive]
35pub struct FmpQuote {
36 pub symbol: String,
38 pub name: Option<String>,
40 pub price: Option<f64>,
42 pub change: Option<f64>,
44 #[serde(rename = "changesPercentage")]
46 pub changes_percentage: Option<f64>,
47 #[serde(rename = "dayLow")]
49 pub day_low: Option<f64>,
50 #[serde(rename = "dayHigh")]
52 pub day_high: Option<f64>,
53 #[serde(rename = "yearLow")]
55 pub year_low: Option<f64>,
56 #[serde(rename = "yearHigh")]
58 pub year_high: Option<f64>,
59 #[serde(rename = "marketCap")]
61 pub market_cap: Option<f64>,
62 pub volume: Option<f64>,
64 #[serde(rename = "avgVolume")]
66 pub avg_volume: Option<f64>,
67 pub open: Option<f64>,
69 #[serde(rename = "previousClose")]
71 pub previous_close: Option<f64>,
72 pub eps: Option<f64>,
74 pub pe: Option<f64>,
76 pub timestamp: Option<i64>,
78 pub exchange: Option<String>,
80 #[serde(rename = "earningsAnnouncement")]
82 pub earnings_announcement: Option<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
91#[non_exhaustive]
92pub struct HistoricalPrice {
93 pub date: Option<String>,
95 pub open: Option<f64>,
97 pub high: Option<f64>,
99 pub low: Option<f64>,
101 pub close: Option<f64>,
103 #[serde(rename = "adjClose")]
105 pub adj_close: Option<f64>,
106 pub volume: Option<f64>,
108 #[serde(rename = "unadjustedVolume")]
110 pub unadjusted_volume: Option<f64>,
111 pub change: Option<f64>,
113 #[serde(rename = "changePercent")]
115 pub change_percent: Option<f64>,
116 pub vwap: Option<f64>,
118 pub label: Option<String>,
120 #[serde(rename = "changeOverTime")]
122 pub change_over_time: Option<f64>,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[non_exhaustive]
128pub struct HistoricalPriceResponse {
129 pub symbol: Option<String>,
131 pub historical: Vec<HistoricalPrice>,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
137#[non_exhaustive]
138pub struct IntradayPrice {
139 pub date: Option<String>,
141 pub open: Option<f64>,
143 pub high: Option<f64>,
145 pub low: Option<f64>,
147 pub close: Option<f64>,
149 pub volume: Option<f64>,
151}