pub struct Indexes { /* private fields */ }Expand description
Indexes API endpoints
Implementations§
Source§impl Indexes
impl Indexes
Sourcepub async fn get_index_list(&self) -> Result<Vec<IndexSymbol>>
pub async fn get_index_list(&self) -> Result<Vec<IndexSymbol>>
Get list of available market indexes
Returns all available market index symbols (S&P 500, Nasdaq, Dow Jones, etc.).
§Example
let client = FmpClient::new()?;
let indexes = client.indexes().get_index_list().await?;
for index in indexes.iter().take(10) {
println!("{}: {}", index.symbol, index.name.as_deref().unwrap_or("N/A"));
}Sourcepub async fn get_index_quote(&self, symbol: &str) -> Result<Vec<IndexQuote>>
pub async fn get_index_quote(&self, symbol: &str) -> Result<Vec<IndexQuote>>
Get real-time index quote
Returns current level and market data for an index.
§Arguments
symbol- Index symbol (e.g., “^GSPC” for S&P 500, “^DJI” for Dow Jones)
§Example
let client = FmpClient::new()?;
let quote = client.indexes().get_index_quote("^GSPC").await?;
if let Some(q) = quote.first() {
println!("S&P 500: {:.2}", q.price.unwrap_or(0.0));
println!("Change: {:+.2}%", q.changes_percentage.unwrap_or(0.0));
}Sourcepub async fn get_index_historical(
&self,
symbol: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<IndexHistorical>>
pub async fn get_index_historical( &self, symbol: &str, from: Option<&str>, to: Option<&str>, ) -> Result<Vec<IndexHistorical>>
Get historical index data
Returns daily historical data for an index.
§Arguments
symbol- Index symbol (e.g., “^GSPC”)from- Start date (optional, format: YYYY-MM-DD)to- End date (optional, format: YYYY-MM-DD)
§Example
let client = FmpClient::new()?;
let history = client.indexes().get_index_historical("^GSPC", None, None).await?;
for day in history.iter().take(5) {
println!("{}: {:.2}", day.date, day.close);
}Sourcepub async fn get_index_constituents(
&self,
symbol: &str,
) -> Result<Vec<IndexConstituent>>
pub async fn get_index_constituents( &self, symbol: &str, ) -> Result<Vec<IndexConstituent>>
Get index constituents
Returns all component stocks that make up an index (e.g., S&P 500 companies).
§Arguments
symbol- Index symbol (e.g., “^GSPC” for S&P 500 constituents)
§Example
let client = FmpClient::new()?;
let constituents = client.indexes().get_index_constituents("^GSPC").await?;
println!("S&P 500 has {} components", constituents.len());
for stock in constituents.iter().take(10) {
println!("{}: {} ({})",
stock.symbol,
stock.name.as_deref().unwrap_or("N/A"),
stock.sector.as_deref().unwrap_or("N/A"));
}Auto Trait Implementations§
impl Freeze for Indexes
impl !RefUnwindSafe for Indexes
impl Send for Indexes
impl Sync for Indexes
impl Unpin for Indexes
impl !UnwindSafe for Indexes
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