feed.api.float.window.rolling module

rolling.py contains functions and classes for rolling stream operations.

class feed.api.float.window.rolling.Rolling(window: int, min_periods: int = 1)[source]

Bases: feed.core.base.Stream

A stream that generates a rolling window of values from a stream.

Parameters:
  • window (int) – The size of the rolling window.
  • min_periods (int, default 1) – The number of periods to wait before producing values from the aggregation function.
agg(func: Callable[[List[float]], float]) → feed.core.base.Stream[float][float][source]

Computes an aggregation of a rolling window of values.

Parameters:func (Callable[[List[float]], float]) – A aggregation function.
Returns:A stream producing aggregations of a rolling window of values.
Return type:Stream[float]
count() → feed.core.base.Stream[float][float][source]

Computes a rolling count from the underlying stream.

Returns:A rolling count stream.
Return type:Stream[float]
forward() → List[float][source]

Generates the next value from the underlying data streams.

Returns:The next value in the stream.
Return type:T
generic_name = 'rolling'
has_next() → bool[source]

Checks if there is another value.

Returns:If there is another value or not.
Return type:bool
max() → feed.core.base.Stream[float][float][source]

Computes a rolling maximum from the underlying stream.

Returns:A rolling maximum stream.
Return type:Stream[float]
mean() → feed.core.base.Stream[float][float][source]

Computes a rolling mean from the underlying stream.

Returns:A rolling mean stream.
Return type:Stream[float]
median() → feed.core.base.Stream[float][float][source]

Computes a rolling median from the underlying stream.

Returns:A rolling median stream.
Return type:Stream[float]
min() → feed.core.base.Stream[float][float][source]

Computes a rolling minimum from the underlying stream.

Returns:A rolling minimum stream.
Return type:Stream[float]
reset() → None[source]

Resets all the listeners of the stream.

std() → feed.core.base.Stream[float][float][source]

Computes a rolling standard deviation from the underlying stream.

Returns:A rolling standard deviation stream.
Return type:Stream[float]
sum() → feed.core.base.Stream[float][float][source]

Computes a rolling sum from the underlying stream.

Returns:A rolling sum stream.
Return type:Stream[float]
var() → feed.core.base.Stream[float][float][source]

Computes a rolling variance from the underlying stream.

Returns:A rolling variance stream.
Return type:Stream[float]
class feed.api.float.window.rolling.RollingCount[source]

Bases: feed.api.float.window.rolling.RollingNode

A stream operator that counts the number of non-missing values in the rolling window.

forward()[source]

Generates the next value from the underlying data streams.

Returns:The next value in the stream.
Return type:T
class feed.api.float.window.rolling.RollingNode(func: Callable[[List[float]], float])[source]

Bases: feed.core.base.Stream

A stream operator for aggregating a rolling window of a stream.

Parameters:func (Callable[[List[float]], float]) – A function that aggregates a rolling window.
forward() → float[source]

Generates the next value from the underlying data streams.

Returns:The next value in the stream.
Return type:T
has_next() → bool[source]

Checks if there is another value.

Returns:If there is another value or not.
Return type:bool
reset() → None[source]

Resets all the listeners of the stream.

feed.api.float.window.rolling.rolling(s: feed.core.base.Stream[float][float], window: int, min_periods: int = 1) → feed.core.base.Stream[typing.List[float]][List[float]][source]

Creates a stream that generates a rolling window of values from a stream.

Parameters:
  • s (Stream[float]) – A float stream.
  • window (int) – The size of the rolling window.
  • min_periods (int, default 1) – The number of periods to wait before producing values from the aggregation function.