Skip to main content

finance_query/models/commodities/
mod.rs

1//! Commodities market data models.
2//!
3//! Canonical public types for commodity quotes (gold, silver, oil, etc.),
4//! shared across FMP and Alpha Vantage providers.
5
6use serde::{Deserialize, Serialize};
7
8/// A commodity price quote (e.g., gold, silver, crude oil).
9///
10/// Obtain via [`Ticker::quote`](crate::Ticker::quote) using the commodity symbol (e.g., `"GC=F"` for gold).
11#[derive(Debug, Clone, Serialize, Deserialize)]
12#[non_exhaustive]
13pub struct CommodityQuote {
14    /// Commodity symbol (e.g., `"GCUSD"` for gold, `"CLUSD"` for crude oil)
15    pub symbol: String,
16    /// Human-readable commodity name (e.g., `"Gold"`, `"Crude Oil WTI"`)
17    pub name: Option<String>,
18    /// Unit of measurement (e.g., `"troy ounce"`, `"barrel"`)
19    pub unit: Option<String>,
20    /// Current price
21    pub price: Option<f64>,
22    /// Price change
23    pub change: Option<f64>,
24    /// Price change percentage
25    pub change_percent: Option<f64>,
26    /// Unix timestamp of the last update
27    pub timestamp: Option<i64>,
28}