tensortrade.feed.api.float.window.rolling module

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

class tensortrade.feed.api.float.window.rolling.Rolling(*args, **kwargs)[source]

Bases: tensortrade.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])tensortrade.feed.core.base.Stream[float][source]

Computes an aggregation of a rolling window of values.

Parameters

func (Callable[[List[float]], float]) – A aggregation function.

Returns

Stream[float] – A stream producing aggregations of a rolling window of values.

count()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling count from the underlying stream.

Returns

Stream[float] – A rolling count stream.

forward() → List[float][source]

Generates the next value from the underlying data streams.

Returns

T – The next value in the stream.

generic_name: str = 'rolling'
has_next()bool[source]

Checks if there is another value.

Returns

bool – If there is another value or not.

max()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling maximum from the underlying stream.

Returns

Stream[float] – A rolling maximum stream.

mean()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling mean from the underlying stream.

Returns

Stream[float] – A rolling mean stream.

median()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling median from the underlying stream.

Returns

Stream[float] – A rolling median stream.

min()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling minimum from the underlying stream.

Returns

Stream[float] – A rolling minimum stream.

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

Computes a rolling standard deviation from the underlying stream.

Returns

Stream[float] – A rolling standard deviation stream.

sum()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling sum from the underlying stream.

Returns

Stream[float] – A rolling sum stream.

var()tensortrade.feed.core.base.Stream[float][source]

Computes a rolling variance from the underlying stream.

Returns

Stream[float] – A rolling variance stream.

class tensortrade.feed.api.float.window.rolling.RollingCount(*args, **kwargs)[source]

Bases: tensortrade.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

T – The next value in the stream.

class tensortrade.feed.api.float.window.rolling.RollingNode(*args, **kwargs)[source]

Bases: tensortrade.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

T – The next value in the stream.

has_next()bool[source]

Checks if there is another value.

Returns

bool – If there is another value or not.

tensortrade.feed.api.float.window.rolling.rolling(s: tensortrade.feed.core.base.Stream[float], window: int, min_periods: int = 1)tensortrade.feed.core.base.Stream[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.