pub struct MarketHours { /* private fields */ }Expand description
Market Hours API endpoints
Implementations§
Source§impl MarketHours
impl MarketHours
Sourcepub async fn get_market_hours(&self) -> Result<Vec<MarketHours>>
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"));
}Sourcepub async fn get_extended_hours(&self) -> Result<Vec<ExtendedMarketHours>>
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"));
}Sourcepub async fn get_market_holidays(
&self,
year: Option<i32>,
) -> Result<Vec<MarketHoliday>>
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"));
}Sourcepub async fn get_exchange_hours(&self) -> Result<Vec<ExchangeHours>>
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§
impl Freeze for MarketHours
impl !RefUnwindSafe for MarketHours
impl Send for MarketHours
impl Sync for MarketHours
impl Unpin for MarketHours
impl !UnwindSafe for MarketHours
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