Skip to main content

RelativeVolumeAtTime

Struct RelativeVolumeAtTime 

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

Relative Volume at Time: this bar’s volume against the volume at the same time of day on previous days.

The rolling super::volume_indicators::RvolEngine answers a different question — how this bar compares to the recent ones, whatever hour they fell in. At 09:31 that comparison is dominated by the opening bar and says little. Here the comparison runs down the same column of the clock instead: 09:31 today against 09:31 on each of the previous days days.

Two ratios come out of it, and they are not interchangeable:

  • value: regular — this bar’s volume divided by the average volume in the same slot on previous days.
  • extra["cumulative"]: cumulative — the volume accumulated since the start of today divided by the average of what had accumulated by the same slot on previous days. This is the one that answers “is today busy so far”, and it is far less jumpy than the regular one.

The day starts at day_start_offset seconds after midnight UTC, so a market whose session does not align with UTC midnight can be placed correctly. A slot is the number of seconds into that day, which makes bars of any spacing line up as long as they arrive at consistent times.

Only days strictly before today count as comparison. Today’s own bars never enter their own reference, so no value depends on data that did not exist when the bar closed.

How many comparison days actually contributed is published rather than assumed:

  • extra["samples"]: number of previous days that had a bar in this slot.
  • extra["complete"]: 1.0 when that number equals days, 0.0 otherwise.

A missing slot lowers samples; it is never filled in from a neighbouring slot or an earlier day. A shortened trading day therefore shows up as an incomplete comparison instead of a quietly wrong ratio.

Unit: a ratio, where 1.0 means “as much as usual at this time”. Zero average volume in the comparison slots produces no output — a ratio against nothing has no meaning.

First output: the first bar whose slot has at least one previous day to compare against — one day of bars. How many bars that is depends on the timeframe, which this indicator cannot know from a timestamp alone, so bar_seconds states it. That parameter is declarative only: it makes Indicator::warmup_period an honest number of bars and has no influence on the calculation, which always derives slots from timestamps. A wrong value misstates the declared warmup, never a ratio.

Memory is bounded by pruning slots untouched for more than days days.

Implementations§

Source§

impl RelativeVolumeAtTime

Source

pub fn new(days: usize, day_start_offset: i64, bar_seconds: i64) -> Self

Source

pub fn with_defaults() -> Self

Trait Implementations§

Source§

impl Clone for RelativeVolumeAtTime

Source§

fn clone(&self) -> RelativeVolumeAtTime

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 Debug for RelativeVolumeAtTime

Source§

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

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

impl Indicator for RelativeVolumeAtTime

Source§

fn name(&self) -> &str

Source§

fn warmup_period(&self) -> usize

Source§

fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>

Source§

fn reset(&mut self)

Source§

fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>

Validates a bar before forwarding it to Indicator::on_bar.
Source§

fn alerts(&self) -> Vec<IndicatorAlert>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.