Struct Minimum

Source
pub struct Minimum<T>(/* private fields */);
Expand description

§Minimum Value Calculation for Rolling Windows

A specialized module for tracking minimum values in rolling windows of financial time-series data.

Uses an efficient data structure to maintain the minimum value at all times, providing constant-time lookups and amortized constant-time updates. This approach is particularly valuable for technical analysis indicators that require identifying price extremes, such as Donchian channels, volatility measures, and support/resistance level detection.

The implementation is optimized for financial time-series analysis where identifying minimum values within specific lookback periods is essential for decision-making processes.

Implementations§

Source§

impl<T: Default + Clone + Float> Minimum<T>

Source

pub fn new(period: usize) -> Self

Creates a new Minimum instance with the specified period

§Arguments
  • period - The size of the rolling window
§Returns

A new Minimum instance

Source

pub fn push(&mut self, value: T)

Pushes a new value into the rolling window

§Arguments
  • value - The new value to be added to the rolling window
§Returns

None if the window is not yet full, otherwise returns the minimum value

Source

pub fn get(&self) -> Option<T>

Returns the minimum value in the rolling window

§Returns

None if the window is not yet full, otherwise returns the minimum value

Source

pub fn reset(&mut self)

Resets the rolling window

Trait Implementations§

Source§

impl<T: Debug> Debug for Minimum<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Minimum<T>

§

impl<T> RefUnwindSafe for Minimum<T>
where T: RefUnwindSafe,

§

impl<T> Send for Minimum<T>
where T: Send,

§

impl<T> Sync for Minimum<T>
where T: Sync,

§

impl<T> Unpin for Minimum<T>

§

impl<T> UnwindSafe for Minimum<T>
where T: UnwindSafe,

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> 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, 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.