pub struct Forex { /* private fields */ }Expand description
Forex API endpoints
Implementations§
Source§impl Forex
impl Forex
Sourcepub async fn get_forex_list(&self) -> Result<Vec<ForexPair>>
pub async fn get_forex_list(&self) -> Result<Vec<ForexPair>>
Get list of available forex pairs
Returns all available forex currency pairs.
§Example
let client = FmpClient::new()?;
let pairs = client.forex().get_forex_list().await?;
for pair in pairs.iter().take(10) {
println!("{}: {}", pair.symbol, pair.name.as_deref().unwrap_or("N/A"));
}Sourcepub async fn get_forex_quote(&self, pair: &str) -> Result<Vec<ForexQuote>>
pub async fn get_forex_quote(&self, pair: &str) -> Result<Vec<ForexQuote>>
Get real-time forex quote
Returns current exchange rate for a forex pair.
§Arguments
pair- Forex pair (e.g., “EURUSD”, “GBPUSD”)
§Example
let client = FmpClient::new()?;
let quote = client.forex().get_forex_quote("EURUSD").await?;
if let Some(q) = quote.first() {
println!("EUR/USD: {:.5}", q.price.unwrap_or(0.0));
println!("Change: {:+.2}%", q.changes_percentage.unwrap_or(0.0));
}Sourcepub async fn get_forex_historical(
&self,
pair: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<ForexHistorical>>
pub async fn get_forex_historical( &self, pair: &str, from: Option<&str>, to: Option<&str>, ) -> Result<Vec<ForexHistorical>>
Get historical forex rates
Returns daily historical exchange rates for a forex pair.
§Arguments
pair- Forex pair (e.g., “EURUSD”)from- Start date (optional, format: YYYY-MM-DD)to- End date (optional, format: YYYY-MM-DD)
§Example
let client = FmpClient::new()?;
let history = client.forex().get_forex_historical("EURUSD", None, None).await?;
for day in history.iter().take(5) {
println!("{}: {:.5}", day.date, day.close);
}Sourcepub async fn get_forex_intraday(
&self,
pair: &str,
interval: &str,
) -> Result<Vec<ForexIntraday>>
pub async fn get_forex_intraday( &self, pair: &str, interval: &str, ) -> Result<Vec<ForexIntraday>>
Get intraday forex rates
Returns intraday exchange rate data at various intervals.
§Arguments
pair- Forex pair (e.g., “EURUSD”)interval- Time interval (“1min”, “5min”, “15min”, “30min”, “1hour”, “4hour”)
§Example
let client = FmpClient::new()?;
let intraday = client.forex().get_forex_intraday("EURUSD", "5min").await?;
for tick in intraday.iter().take(10) {
println!("{}: {:.5}", tick.date, tick.close);
}Auto Trait Implementations§
impl Freeze for Forex
impl !RefUnwindSafe for Forex
impl Send for Forex
impl Sync for Forex
impl Unpin for Forex
impl !UnwindSafe for Forex
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