fmp_rs/models/
commodities.rs

1//! Models for commodities endpoints
2
3use serde::{Deserialize, Serialize};
4
5/// Commodity symbol information
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct CommoditySymbol {
9    /// Symbol (e.g., "GCUSD", "CLUSD")
10    pub symbol: String,
11    /// Commodity name
12    pub name: Option<String>,
13    /// Currency
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/// Commodity quote
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub struct CommodityQuote {
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 commodity price
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase")]
60pub struct CommodityHistorical {
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 commodity price
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(rename_all = "camelCase")]
80pub struct CommodityIntraday {
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}