pub fn iterated<M, I, Q, P, const LEN: usize>(
    mode: M,
    op: P
) -> TumblingOperator<M, Q, Iterated<P>, LEN>where
    M: TumblingWindow,
    Q: QueueCapAtLeast<LEN, Item = P::Output>,
    P: IteratedOperation<I, Q, LEN>,
Expand description

Create a iterated tumbling operator from the given operation.

use indicator::*;
use rust_decimal::Decimal;

fn ohlc<M, I, Q>(mode: M) -> impl Operator<I, Output = TickValue<[Decimal; 4]>>
where
    M: TumblingWindow,
    I: Tickable<Value = Decimal>,
    Q: QueueCapAtLeast<0, Item = [Decimal; 4]>,
{
    iterated(mode, |_q: &Q, y: Option<&[Decimal; 4]>, x| {
        match y {
            Some(y) => [y[0], y[1].max(x), y[2].min(x), x],
            None => [x, x, x, x]
        }
    })
}