MutualFunds

Struct MutualFunds 

Source
pub struct MutualFunds { /* private fields */ }
Expand description

Mutual Funds API endpoints

Implementations§

Source§

impl MutualFunds

Source

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);
}
Source

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);
}
Source

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));
}
Source

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"));
}
Source

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));
}
Source

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));
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,