Struct yata::methods::CollapseTimeframe [−][src]
Converting between different timeframes.
Parameters
Has a single parameter period
: usize
period
must be > 0
Input type
Input type is reference to OHLCV
Output type
Examples
use yata::prelude::*; use yata::methods::CollapseTimeframe; let timeframe = [ // open high low close volume (10.0, 15.0, 5.0, 12.0, 1000.0), (12.1, 17.0, 6.0, 13.0, 2000.0), ]; let mut collapser = CollapseTimeframe::new(2, &timeframe[0]).unwrap(); assert_eq!(collapser.next(&timeframe[0]), None); let collapsed = collapser.next(&timeframe[1]).unwrap(); assert_eq!(collapsed.open(), 10.0); assert_eq!(collapsed.high(), 17.0); assert_eq!(collapsed.low(), 5.0); assert_eq!(collapsed.close(), 13.0); assert_eq!(collapsed.volume(), 3000.0);
Output type is Candle
Performance
O(1)
See also Sequence’s collapse_timeframe
function.
Trait Implementations
impl Clone for CollapseTimeframe
[src]
fn clone(&self) -> CollapseTimeframe
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for CollapseTimeframe
[src]
impl Debug for CollapseTimeframe
[src]
impl Default for CollapseTimeframe
[src]
fn default() -> CollapseTimeframe
[src]
impl<'de> Deserialize<'de> for CollapseTimeframe
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<'a> Method<'a> for CollapseTimeframe
[src]
type Params = usize
Method parameters
type Input = &'a dyn OHLCV
Input value type
type Output = Option<Candle>
Output value type
fn new(period: Self::Params, _candle: Self::Input) -> Result<Self, Error>
[src]
fn next(&mut self, candle: Self::Input) -> Self::Output
[src]
fn name(&self) -> &str
[src]
fn memsize(&self) -> (usize, usize) where
Self: Sized,
[src]
Self: Sized,
fn over<S>(&'a mut self, inputs: S) -> Vec<Self::Output> where
S: Sequence<Self::Input>,
Self: Sized,
[src]
S: Sequence<Self::Input>,
Self: Sized,
fn apply<'b: 'a, T, S>(&'a mut self, sequence: &'b mut S) where
S: Sequence<T> + AsMut<[T]>,
Self: Method<'a, Input = T, Output = T> + Sized,
T: Copy,
[src]
S: Sequence<T> + AsMut<[T]>,
Self: Method<'a, Input = T, Output = T> + Sized,
T: Copy,
fn new_over<S>(
parameters: Self::Params,
inputs: S
) -> Result<Vec<Self::Output>, Error> where
S: Sequence<Self::Input>,
Self::Input: Clone,
Self: Sized + 'a,
[src]
parameters: Self::Params,
inputs: S
) -> Result<Vec<Self::Output>, Error> where
S: Sequence<Self::Input>,
Self::Input: Clone,
Self: Sized + 'a,
fn new_apply<T, S>(
parameters: Self::Params,
sequence: &'a mut S
) -> Result<(), Error> where
T: Copy,
S: Sequence<T> + AsMut<[T]>,
Self: Method<'a, Input = T, Output = T> + Sized + 'a,
[src]
parameters: Self::Params,
sequence: &'a mut S
) -> Result<(), Error> where
T: Copy,
S: Sequence<T> + AsMut<[T]>,
Self: Method<'a, Input = T, Output = T> + Sized + 'a,
fn into_fn(self) -> Box<dyn FnMut(Self::Input) -> Self::Output> where
Self: Sized + 'static,
[src]
Self: Sized + 'static,
fn new_fn(
params: Self::Params,
initial_value: Self::Input
) -> Result<Box<dyn FnMut(Self::Input) -> Self::Output>, Error> where
Self: Sized + 'static,
[src]
params: Self::Params,
initial_value: Self::Input
) -> Result<Box<dyn FnMut(Self::Input) -> Self::Output>, Error> where
Self: Sized + 'static,
impl Serialize for CollapseTimeframe
[src]
Auto Trait Implementations
impl RefUnwindSafe for CollapseTimeframe
impl Send for CollapseTimeframe
impl Sync for CollapseTimeframe
impl Unpin for CollapseTimeframe
impl UnwindSafe for CollapseTimeframe
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,