Skip to main content

SessionProvider

Trait SessionProvider 

Source
pub trait SessionProvider: Send + Sync {
    // Required methods
    fn session_break_between(
        &self,
        from: &DateTime<Utc>,
        to: &DateTime<Utc>,
    ) -> Option<SessionBreak>;
    fn name(&self) -> &str;

    // Provided methods
    fn session_breaks_in_range(
        &self,
        start: &DateTime<Utc>,
        end: &DateTime<Utc>,
    ) -> Vec<SessionBreak> { ... }
    fn session_breaks(&self, bars: &[Bar]) -> Vec<(usize, SessionBreak)> { ... }
}
Expand description

Trait for defining trading session boundaries.

Implement this to create custom session-break logic (e.g., exchange- specific holidays, pre-market/after-hours splits, or futures roll dates). All built-in providers implement this trait.

Required Methods§

Source

fn session_break_between( &self, from: &DateTime<Utc>, to: &DateTime<Utc>, ) -> Option<SessionBreak>

Check if a session break occurs between two ts Returns Some(SessionBreak) if there’s a break, None otherwise

Source

fn name(&self) -> &str

Get display name for this session provider

Provided Methods§

Source

fn session_breaks_in_range( &self, start: &DateTime<Utc>, end: &DateTime<Utc>, ) -> Vec<SessionBreak>

Get all session breaks within a time range, checking at most one minute at a time. The final check stops at end; an empty or reversed range has no breaks.

Source

fn session_breaks(&self, bars: &[Bar]) -> Vec<(usize, SessionBreak)>

The breaks between consecutive bars, as find_session_breaks returns them. The default asks session_break_between for each pair; a provider can find them in one pass instead.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§