pub struct Etf { /* private fields */ }Expand description
ETF API endpoints
Implementations§
Source§impl Etf
impl Etf
Sourcepub async fn get_etf_list(&self) -> Result<Vec<EtfListItem>>
pub async fn get_etf_list(&self) -> Result<Vec<EtfListItem>>
Get a list of all available ETFs
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let etfs = client.etf().get_etf_list().await?;
for etf in etfs.iter().take(5) {
println!("{}: {}", etf.symbol, etf.name);
}
Ok(())
}Sourcepub async fn search_etf(
&self,
query: &str,
limit: Option<u32>,
exchange: Option<&str>,
) -> Result<Vec<EtfSearchResult>>
pub async fn search_etf( &self, query: &str, limit: Option<u32>, exchange: Option<&str>, ) -> Result<Vec<EtfSearchResult>>
Search for ETFs by name or symbol
§Arguments
query- Search query (name or symbol fragment)limit- Optional limit on number of resultsexchange- Optional exchange filter (e.g., “NASDAQ”, “NYSE”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let results = client.etf().search_etf("vanguard", Some(10), None).await?;
for etf in &results {
println!("{}: {} ({})", etf.symbol, etf.name,
etf.exchange_short_name.as_deref().unwrap_or("N/A"));
}
Ok(())
}Sourcepub async fn get_etf_holder(&self, symbol: &str) -> Result<Vec<EtfHolder>>
pub async fn get_etf_holder(&self, symbol: &str) -> Result<Vec<EtfHolder>>
Get institutional holders of an ETF (who holds this ETF)
§Arguments
symbol- ETF symbol (e.g., “SPY”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let holders = client.etf().get_etf_holder("SPY").await?;
println!("Top holders of SPY:");
for holder in holders.iter().take(10) {
println!(" {}: {}%", holder.name,
holder.weight_percentage.unwrap_or(0.0));
}
Ok(())
}Sourcepub async fn get_etf_holdings(&self, symbol: &str) -> Result<Vec<EtfHolding>>
pub async fn get_etf_holdings(&self, symbol: &str) -> Result<Vec<EtfHolding>>
Get holdings of an ETF (what this ETF holds)
§Arguments
symbol- ETF symbol (e.g., “SPY”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let holdings = client.etf().get_etf_holdings("SPY").await?;
println!("Top holdings in SPY:");
for holding in holdings.iter().take(10) {
println!(" {}: {:.2}% ({})",
holding.asset, holding.weight_percentage, holding.name);
}
Ok(())
}Sourcepub async fn get_etf_sector_weighting(
&self,
symbol: &str,
) -> Result<Vec<SectorWeighting>>
pub async fn get_etf_sector_weighting( &self, symbol: &str, ) -> Result<Vec<SectorWeighting>>
Get sector weighting of an ETF
§Arguments
symbol- ETF symbol (e.g., “SPY”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let sectors = client.etf().get_etf_sector_weighting("SPY").await?;
println!("Sector allocation for SPY:");
for sector in §ors {
println!(" {}: {}%", sector.sector, sector.weight_percentage);
}
Ok(())
}Sourcepub async fn get_etf_country_weighting(
&self,
symbol: &str,
) -> Result<Vec<CountryWeighting>>
pub async fn get_etf_country_weighting( &self, symbol: &str, ) -> Result<Vec<CountryWeighting>>
Get country weighting of an ETF
§Arguments
symbol- ETF symbol (e.g., “SPY”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let countries = client.etf().get_etf_country_weighting("SPY").await?;
println!("Country allocation for SPY:");
for country in &countries {
println!(" {}: {}%", country.country, country.weight_percentage);
}
Ok(())
}Sourcepub async fn get_etf_info(&self, symbol: &str) -> Result<Vec<EtfInfo>>
pub async fn get_etf_info(&self, symbol: &str) -> Result<Vec<EtfInfo>>
Get detailed information about an ETF
§Arguments
symbol- ETF symbol (e.g., “SPY”)
§Example
use fmp_rs::FmpClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FmpClient::new()?;
let info = client.etf().get_etf_info("SPY").await?;
if let Some(etf) = info.first() {
println!("ETF: {} ({})", etf.company_name, etf.symbol);
println!("AUM: ${:.2}B", etf.aum / 1_000_000_000.0);
println!("Expense Ratio: {:.2}%", etf.expense_ratio);
println!("Holdings: {}", etf.holdings_count);
println!("Inception: {}", etf.inception_date);
}
Ok(())
}Auto Trait Implementations§
impl Freeze for Etf
impl !RefUnwindSafe for Etf
impl Send for Etf
impl Sync for Etf
impl Unpin for Etf
impl !UnwindSafe for Etf
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