MarketHours

Struct MarketHours 

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

Market Hours API endpoints

Implementations§

Source§

impl MarketHours

Source

pub async fn get_market_hours(&self) -> Result<Vec<MarketHours>>

Get current market status and hours

Returns the current market status (open/closed) and trading hours for major exchanges. Useful for determining if markets are currently active for trading.

§Example
let client = FmpClient::new()?;
let market_status = client.market_hours().get_market_hours().await?;
for market in market_status.iter().take(3) {
    println!("{}: {} ({})",
        market.stock_market.as_deref().unwrap_or("Unknown"),
        if market.is_market_open.unwrap_or(false) { "OPEN" } else { "CLOSED" },
        market.timezone.as_deref().unwrap_or("UTC"));
}
Source

pub async fn get_extended_hours(&self) -> Result<Vec<ExtendedMarketHours>>

Get extended market hours for all exchanges

Returns detailed trading hours including pre-market, regular session, and after-hours trading times for all major exchanges.

§Example
let client = FmpClient::new()?;
let extended_hours = client.market_hours().get_extended_hours().await?;
for exchange in extended_hours.iter().take(5) {
    println!("{}: Regular: {} - {}, Pre: {} - {}, After: {} - {}",
        exchange.name.as_deref().unwrap_or("Unknown"),
        exchange.market_open.as_deref().unwrap_or("N/A"),
        exchange.market_close.as_deref().unwrap_or("N/A"),
        exchange.pre_market_open.as_deref().unwrap_or("N/A"),
        exchange.pre_market_close.as_deref().unwrap_or("N/A"),
        exchange.after_hours_open.as_deref().unwrap_or("N/A"),
        exchange.after_hours_close.as_deref().unwrap_or("N/A"));
}
Source

pub async fn get_market_holidays( &self, year: Option<i32>, ) -> Result<Vec<MarketHoliday>>

Get market holidays for a specific year

Returns all market holidays and early closures for major exchanges. Useful for planning trading strategies around market closures.

§Arguments
  • year - Optional year (e.g., 2024). Defaults to current year if not provided.
§Example
let client = FmpClient::new()?;
let holidays = client.market_hours().get_market_holidays(Some(2024)).await?;
for holiday in holidays.iter().take(10) {
    println!("{}: {} ({})",
        holiday.date.as_deref().unwrap_or("N/A"),
        holiday.holiday.as_deref().unwrap_or("Unknown"),
        holiday.market_status.as_deref().unwrap_or("closed"));
}
Source

pub async fn get_exchange_hours(&self) -> Result<Vec<ExchangeHours>>

Get trading hours for all exchanges

Returns comprehensive trading hours information for all global exchanges, including regular hours, pre-market, and after-hours sessions.

§Example
let client = FmpClient::new()?;
let exchange_hours = client.market_hours().get_exchange_hours().await?;
for exchange in exchange_hours.iter().take(5) {
    let status = if exchange.is_open.unwrap_or(false) { "🟢 OPEN" } else { "🔴 CLOSED" };
    println!("{} ({}): {} | Regular: {} - {}",
        exchange.exchange_name.as_deref().unwrap_or("Unknown"),
        exchange.country.as_deref().unwrap_or("Unknown"),
        status,
        exchange.market_open.as_deref().unwrap_or("N/A"),
        exchange.market_close.as_deref().unwrap_or("N/A"));
}

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,