pub enum DateRange {
Day1,
Day5,
Month1,
Month3,
Month6,
YTD,
Year1,
Year5,
All,
}Expand description
Preset date range for quick navigation.
Each variant describes a lookback window from the current time.
The default preset is Month1.
Use start_timestamp to convert a preset into
an absolute DateTime, or estimated_bars to
estimate how many bars to fetch for a given timeframe.
Variants§
Day1
1 Day
Day5
5 Days
Month1
1 Month
Month3
3 Months
Month6
6 Months
YTD
Year to Date (from Jan 1 of current year)
Year1
1 Year
Year5
5 Years
All
All available data
Implementations§
Source§impl DateRange
impl DateRange
Sourcepub fn default_presets() -> Vec<DateRange>
pub fn default_presets() -> Vec<DateRange>
Get all standard ranges in order
Sourcepub fn start_timestamp(&self) -> Option<DateTime<Utc>>
pub fn start_timestamp(&self) -> Option<DateTime<Utc>>
Calculate the start ts for this range Returns None for DateRange::All (meaning “from earliest available”)
Sourcepub fn to_timestamps(&self) -> (Option<DateTime<Utc>>, DateTime<Utc>)
pub fn to_timestamps(&self) -> (Option<DateTime<Utc>>, DateTime<Utc>)
Get the date range as (start, end) ts Returns (None, now) for All (meaning earliest to now)
Sourcepub fn estimated_bars(&self, bar_duration_seconds: u64) -> usize
pub fn estimated_bars(&self, bar_duration_seconds: u64) -> usize
Calculate approximate number of bars needed for this range at a given timeframe
Trait Implementations§
impl Copy for DateRange
impl Eq for DateRange
impl StructuralPartialEq for DateRange
Auto Trait Implementations§
impl Freeze for DateRange
impl RefUnwindSafe for DateRange
impl Send for DateRange
impl Sync for DateRange
impl Unpin for DateRange
impl UnsafeUnpin for DateRange
impl UnwindSafe for DateRange
Blanket Implementations§
impl<T> AsId for T
impl<T> AsIdSalt for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more