pub struct Commodities { /* private fields */ }Expand description
Commodities API endpoints
Implementations§
Source§impl Commodities
impl Commodities
Sourcepub async fn get_commodity_list(&self) -> Result<Vec<CommoditySymbol>>
pub async fn get_commodity_list(&self) -> Result<Vec<CommoditySymbol>>
Get list of available commodities
Returns all available commodity symbols (gold, silver, oil, etc.).
§Example
let client = FmpClient::new()?;
let commodities = client.commodities().get_commodity_list().await?;
for commodity in commodities.iter().take(10) {
println!("{}: {}", commodity.symbol, commodity.name.as_deref().unwrap_or("N/A"));
}Sourcepub async fn get_commodity_quote(
&self,
symbol: &str,
) -> Result<Vec<CommodityQuote>>
pub async fn get_commodity_quote( &self, symbol: &str, ) -> Result<Vec<CommodityQuote>>
Get real-time commodity quote
Returns current price and market data for a commodity.
§Arguments
symbol- Commodity symbol (e.g., “GCUSD” for gold, “CLUSD” for crude oil)
§Example
let client = FmpClient::new()?;
let quote = client.commodities().get_commodity_quote("GCUSD").await?;
if let Some(q) = quote.first() {
println!("Gold Price: ${:.2}/oz", q.price.unwrap_or(0.0));
println!("Change: {:+.2}%", q.changes_percentage.unwrap_or(0.0));
}Sourcepub async fn get_commodity_historical(
&self,
symbol: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<CommodityHistorical>>
pub async fn get_commodity_historical( &self, symbol: &str, from: Option<&str>, to: Option<&str>, ) -> Result<Vec<CommodityHistorical>>
Get historical commodity prices
Returns daily historical price data for a commodity.
§Arguments
symbol- Commodity symbol (e.g., “GCUSD” for gold)from- Start date (optional, format: YYYY-MM-DD)to- End date (optional, format: YYYY-MM-DD)
§Example
let client = FmpClient::new()?;
let history = client.commodities().get_commodity_historical("GCUSD", None, None).await?;
for day in history.iter().take(5) {
println!("{}: ${:.2}/oz", day.date, day.close);
}Sourcepub async fn get_commodity_intraday(
&self,
symbol: &str,
interval: &str,
) -> Result<Vec<CommodityIntraday>>
pub async fn get_commodity_intraday( &self, symbol: &str, interval: &str, ) -> Result<Vec<CommodityIntraday>>
Get intraday commodity prices
Returns intraday price data at various intervals.
§Arguments
symbol- Commodity symbol (e.g., “GCUSD”)interval- Time interval (“1min”, “5min”, “15min”, “30min”, “1hour”, “4hour”)
§Example
let client = FmpClient::new()?;
let intraday = client.commodities().get_commodity_intraday("GCUSD", "5min").await?;
for tick in intraday.iter().take(10) {
println!("{}: ${:.2}", tick.date, tick.close);
}Auto Trait Implementations§
impl Freeze for Commodities
impl !RefUnwindSafe for Commodities
impl Send for Commodities
impl Sync for Commodities
impl Unpin for Commodities
impl !UnwindSafe for Commodities
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more