Skip to main content

TimeFrame

Enum TimeFrame 

Source
pub enum TimeFrame {
Show 17 variants Sec1, Min1, Min3, Min5, Min15, Min30, Hour1, Hour2, Hour4, Hour6, Hour8, Hour12, Day1, Day3, Week1, Month1, Year1,
}
Expand description

An OHLCV sampling period.

Variants§

§

Sec1

§

Min1

§

Min3

§

Min5

§

Min15

§

Min30

§

Hour1

§

Hour2

§

Hour4

§

Hour6

§

Hour8

§

Hour12

§

Day1

§

Day3

§

Week1

§

Month1

§

Year1

Implementations§

Source§

impl TimeFrame

Source

pub fn from_label(s: &str) -> Result<TimeFrame, VolasError>

Parse a label ("5m", "1h", "1d", "1M", "1w", "1y", "1s", plus upper-case aliases).

Source

pub fn label(&self) -> &'static str

The canonical label, e.g. "5m".

Source

pub fn unify(&self, ns: i64) -> i64

Unify an epoch-ns timestamp to its period key (in UTC wall-clock). Two timestamps are in the same period iff their keys are equal.

Source

pub fn unify_tz(&self, ns: i64, tz: Tz) -> i64

Unify an epoch-ns timestamp to its period key in tz’s wall-clock, so that hour+ buckets (e.g. daily bars) align to the local trading day — DST-aware for a named zone. Storage stays UTC; only the bucketing uses tz.

Source

pub fn period_start_ns(&self, ns: i64, tz: Tz) -> i64

The UTC epoch-ns instant at which ns’s period starts in tz’s wall-clock — the bar label of a cumulated period (owner decision 2026-06-12: bar labels are the grid period start, origin + n·delta, not the first raw timestamp). The grid mirrors TimeFrame::unify_tz field-for-field: intraday frames anchor at local midnight (a 15-minute bar starts at :00/:15/:30/:45), multi-hour frames at hours 0/k/2k…, Day3 at the Unix epoch, Week1 on Monday, Month1/Year1 on the calendar. A DST anomaly at the boundary resolves to the bucket’s earliest real instant (see Tz::wall_to_utc_ns_earliest).

Source

pub fn can_coarsen(self, dst: TimeFrame) -> bool

Whether this frame can be cleanly coarsened (aggregated) up to dst — i.e. every dst bucket boundary is also a boundary of self, so each dst bar is a whole number of self bars with none straddling.

Fixed-duration frames (≤ Week1) nest by duration divisibility on the epoch grid. The calendar frames need care: a sub-day / 1-day frame nests into a week / month / year (its boundaries fall on every UTC midnight, hence on Monday week-starts and on the 1st), and a month nests into a year — but a week or a 3-day bar does NOT nest into a month or year (ISO weeks and epoch-anchored 3-day bars straddle calendar boundaries).

Trait Implementations§

Source§

impl Clone for TimeFrame

Source§

fn clone(&self) -> TimeFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TimeFrame

Source§

impl Debug for TimeFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for TimeFrame

Source§

impl PartialEq for TimeFrame

Source§

fn eq(&self, other: &TimeFrame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TimeFrame

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.