fmp_rs/models/
crypto.rs

1//! Models for cryptocurrency and forex endpoints
2
3use serde::{Deserialize, Serialize};
4
5/// Cryptocurrency information
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct CryptoSymbol {
9    /// Symbol (e.g., "BTCUSD")
10    pub symbol: String,
11    /// Currency name
12    pub name: Option<String>,
13    /// Currency code
14    pub currency: Option<String>,
15    /// Stock exchange
16    pub stock_exchange: Option<String>,
17    /// Exchange short name
18    pub exchange_short_name: Option<String>,
19}
20
21/// Cryptocurrency quote
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub struct CryptoQuote {
25    /// Symbol
26    pub symbol: String,
27    /// Name
28    pub name: Option<String>,
29    /// Current price
30    pub price: Option<f64>,
31    /// Price change
32    pub change: Option<f64>,
33    /// Percent change
34    pub changes_percentage: Option<f64>,
35    /// Day low
36    pub day_low: Option<f64>,
37    /// Day high
38    pub day_high: Option<f64>,
39    /// Year low
40    pub year_low: Option<f64>,
41    /// Year high
42    pub year_high: Option<f64>,
43    /// Market cap
44    pub market_cap: Option<f64>,
45    /// Volume
46    pub volume: Option<f64>,
47    /// Average volume
48    pub avg_volume: Option<f64>,
49    /// Open price
50    pub open: Option<f64>,
51    /// Previous close
52    pub previous_close: Option<f64>,
53    /// Timestamp
54    pub timestamp: Option<i64>,
55}
56
57/// Historical cryptocurrency price
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase")]
60pub struct CryptoHistorical {
61    /// Date
62    pub date: String,
63    /// Open price
64    pub open: f64,
65    /// High price
66    pub high: f64,
67    /// Low price
68    pub low: f64,
69    /// Close price
70    pub close: f64,
71    /// Adjusted close
72    pub adj_close: Option<f64>,
73    /// Volume
74    pub volume: f64,
75}
76
77/// Intraday cryptocurrency price
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(rename_all = "camelCase")]
80pub struct CryptoIntraday {
81    /// Date and time
82    pub date: String,
83    /// Open price
84    pub open: f64,
85    /// High price
86    pub high: f64,
87    /// Low price
88    pub low: f64,
89    /// Close price
90    pub close: f64,
91    /// Volume
92    pub volume: f64,
93}
94
95/// Forex pair information
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(rename_all = "camelCase")]
98pub struct ForexPair {
99    /// Symbol (e.g., "EUR/USD")
100    pub symbol: String,
101    /// Name
102    pub name: Option<String>,
103    /// Currency
104    pub currency: Option<String>,
105    /// Stock exchange
106    pub stock_exchange: Option<String>,
107    /// Exchange short name
108    pub exchange_short_name: Option<String>,
109}
110
111/// Forex quote
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct ForexQuote {
115    /// Symbol
116    pub symbol: String,
117    /// Name
118    pub name: Option<String>,
119    /// Current price/rate
120    pub price: Option<f64>,
121    /// Price change
122    pub change: Option<f64>,
123    /// Percent change
124    pub changes_percentage: Option<f64>,
125    /// Day low
126    pub day_low: Option<f64>,
127    /// Day high
128    pub day_high: Option<f64>,
129    /// Year low
130    pub year_low: Option<f64>,
131    /// Year high
132    pub year_high: Option<f64>,
133    /// Open price
134    pub open: Option<f64>,
135    /// Previous close
136    pub previous_close: Option<f64>,
137    /// Timestamp
138    pub timestamp: Option<i64>,
139}
140
141/// Historical forex rate
142#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(rename_all = "camelCase")]
144pub struct ForexHistorical {
145    /// Date
146    pub date: String,
147    /// Open rate
148    pub open: f64,
149    /// High rate
150    pub high: f64,
151    /// Low rate
152    pub low: f64,
153    /// Close rate
154    pub close: f64,
155    /// Adjusted close
156    pub adj_close: Option<f64>,
157}
158
159/// Intraday forex rate
160#[derive(Debug, Clone, Serialize, Deserialize)]
161#[serde(rename_all = "camelCase")]
162pub struct ForexIntraday {
163    /// Date and time
164    pub date: String,
165    /// Open rate
166    pub open: f64,
167    /// High rate
168    pub high: f64,
169    /// Low rate
170    pub low: f64,
171    /// Close rate
172    pub close: f64,
173}