Skip to main content

Series

Struct Series 

Source
pub struct Series<T> { /* private fields */ }
Expand description

Sliding historical lookback buffer for streaming time series values. Supports 0-indexed reverse access where 0 is the current bar, 1 is the previous bar, etc.

Implementations§

Source§

impl<T> Series<T>

Source

pub fn new(capacity: usize) -> Self

Creates a new Series with a maximum lookback history capacity.

Source

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

Pushes a new value onto the series, evicting the oldest value if capacity is reached.

Source

pub fn get(&self, offset: usize) -> Option<&T>

Returns a reference to the value at offset bars ago (0 = current, 1 = previous, etc.).

Source

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

Returns a reference to the latest value (offset 0).

Source

pub fn len(&self) -> usize

Returns the number of items currently in history.

Source

pub fn is_empty(&self) -> bool

Returns true if the series is empty.

Source

pub fn reset(&mut self)

Clears the series history.

Source

pub fn barssince<F>(&self, predicate: F) -> Option<usize>
where F: Fn(&T) -> bool,

Returns the number of bars since predicate evaluated to true.

Source

pub fn valuewhen<F>(&self, predicate: F, occurrence: usize) -> Option<&T>
where F: Fn(&T) -> bool,

Returns the value when predicate evaluated to true occurrence times ago (0-indexed).

Source§

impl Series<f64>

Source

pub fn highest(&self, n: usize) -> Option<f64>

Returns the maximum value in the last n bars.

Source

pub fn lowest(&self, n: usize) -> Option<f64>

Returns the minimum value in the last n bars.

Source

pub fn highestbars(&self, n: usize) -> Option<usize>

Returns the offset (0..n-1) of the highest value in the last n bars.

Source

pub fn lowestbars(&self, n: usize) -> Option<usize>

Returns the offset (0..n-1) of the lowest value in the last n bars.

Trait Implementations§

Source§

impl<T: Clone> Clone for Series<T>

Source§

fn clone(&self) -> Series<T>

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<T: Debug> Debug for Series<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for Series<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: PartialEq> PartialEq for Series<T>

Source§

fn eq(&self, other: &Series<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for Series<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Series<T>

Auto Trait Implementations§

§

impl<T> Freeze for Series<T>
where VecDeque<T>: Freeze,

§

impl<T> RefUnwindSafe for Series<T>

§

impl<T> Send for Series<T>
where VecDeque<T>: Send,

§

impl<T> Sync for Series<T>
where VecDeque<T>: Sync,

§

impl<T> Unpin for Series<T>
where VecDeque<T>: Unpin,

§

impl<T> UnsafeUnpin for Series<T>

§

impl<T> UnwindSafe for Series<T>
where VecDeque<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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.