pub struct MutualFunds { /* private fields */ }Expand description
Mutual Funds API endpoints
Implementations§
Source§impl MutualFunds
impl MutualFunds
Sourcepub async fn search_funds(&self, query: Option<&str>) -> Result<Vec<MutualFund>>
pub async fn search_funds(&self, query: Option<&str>) -> Result<Vec<MutualFund>>
Search for mutual funds
Returns a list of mutual funds matching search criteria or all available funds. Useful for discovering funds by name, symbol, or category.
§Arguments
query- Optional search term to filter funds
§Example
let client = FmpClient::new()?;
let funds = client.mutual_funds().search_funds(Some("Vanguard")).await?;
for fund in funds.iter().take(5) {
println!("{}: {} - AUM: ${:.1}B",
fund.symbol.as_deref().unwrap_or("N/A"),
fund.name.as_deref().unwrap_or("Unknown"),
fund.total_assets.unwrap_or(0.0) / 1_000_000_000.0);
}Sourcepub async fn get_fund_details(&self, symbol: &str) -> Result<Vec<MutualFund>>
pub async fn get_fund_details(&self, symbol: &str) -> Result<Vec<MutualFund>>
Get mutual fund details by symbol
Returns detailed information about a specific mutual fund including NAV, expense ratio, total assets, and fund characteristics.
§Arguments
symbol- Fund symbol (e.g., “VTSAX”, “FXNAX”)
§Example
let client = FmpClient::new()?;
let fund_details = client.mutual_funds().get_fund_details("VTSAX").await?;
if let Some(fund) = fund_details.first() {
println!("{}: NAV = ${:.2}, Expense Ratio = {:.2}%",
fund.name.as_deref().unwrap_or("Unknown"),
fund.nav.unwrap_or(0.0),
fund.expense_ratio.unwrap_or(0.0) * 100.0);
}Sourcepub async fn get_fund_historical(
&self,
symbol: &str,
from_date: Option<&str>,
to_date: Option<&str>,
) -> Result<Vec<MutualFundHistorical>>
pub async fn get_fund_historical( &self, symbol: &str, from_date: Option<&str>, to_date: Option<&str>, ) -> Result<Vec<MutualFundHistorical>>
Get mutual fund historical prices
Returns historical NAV (Net Asset Value) data for a mutual fund. Useful for performance analysis and trend identification.
§Arguments
symbol- Fund symbol (e.g., “VTSAX”)from_date- Optional start date (YYYY-MM-DD format)to_date- Optional end date (YYYY-MM-DD format)
§Example
let client = FmpClient::new()?;
let history = client.mutual_funds()
.get_fund_historical("VTSAX", Some("2024-01-01"), Some("2024-03-31")).await?;
for price in history.iter().take(10) {
println!("{}: NAV = ${:.2} ({:+.2}%)",
price.date.as_deref().unwrap_or("N/A"),
price.nav.unwrap_or(0.0),
price.change_percent.unwrap_or(0.0));
}Sourcepub async fn get_fund_holdings(
&self,
symbol: &str,
) -> Result<Vec<MutualFundHolding>>
pub async fn get_fund_holdings( &self, symbol: &str, ) -> Result<Vec<MutualFundHolding>>
Get mutual fund holdings
Returns the top holdings of a mutual fund, showing what securities the fund invests in and their allocation percentages.
§Arguments
symbol- Fund symbol (e.g., “VTSAX”)
§Example
let client = FmpClient::new()?;
let holdings = client.mutual_funds().get_fund_holdings("VTSAX").await?;
for holding in holdings.iter().take(10) {
println!("{}: {:.2}% - {}",
holding.symbol.as_deref().unwrap_or("N/A"),
holding.weight_percentage.unwrap_or(0.0),
holding.name.as_deref().unwrap_or("Unknown"));
}Sourcepub async fn get_fund_performance(
&self,
symbol: &str,
) -> Result<Vec<MutualFundPerformance>>
pub async fn get_fund_performance( &self, symbol: &str, ) -> Result<Vec<MutualFundPerformance>>
Get mutual fund performance metrics
Returns performance statistics including returns over various time periods, risk metrics (alpha, beta, Sharpe ratio), and benchmark comparisons.
§Arguments
symbol- Fund symbol (e.g., “VTSAX”)
§Example
let client = FmpClient::new()?;
let performance = client.mutual_funds().get_fund_performance("VTSAX").await?;
if let Some(perf) = performance.first() {
println!("{}: 1Y = {:.1}%, 3Y = {:.1}%, Sharpe = {:.2}",
perf.name.as_deref().unwrap_or("Unknown"),
perf.one_year.unwrap_or(0.0),
perf.three_years.unwrap_or(0.0),
perf.sharpe_ratio.unwrap_or(0.0));
}Sourcepub async fn get_fund_sectors(
&self,
symbol: &str,
) -> Result<Vec<MutualFundSector>>
pub async fn get_fund_sectors( &self, symbol: &str, ) -> Result<Vec<MutualFundSector>>
Get mutual fund sector allocation
Returns the sector breakdown of a mutual fund’s holdings, showing how the fund is allocated across different industries.
§Arguments
symbol- Fund symbol (e.g., “VTSAX”)
§Example
let client = FmpClient::new()?;
let sectors = client.mutual_funds().get_fund_sectors("VTSAX").await?;
for sector in sectors.iter().take(10) {
println!("{}: {:.1}%",
sector.sector.as_deref().unwrap_or("Unknown"),
sector.weight_percentage.unwrap_or(0.0));
}