tensortrade.feed.api.float.window.expanding module

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

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

Bases: Stream[List[float]]

A stream that generates the entire history of a stream at each time step.

Parameters:

min_periods (int, default 1) – The number of periods to wait before producing values from the aggregation function.

agg(func: Callable[[List[float]], float]) Stream[float][source]

Computes an aggregation of a stream’s history.

Parameters:

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

Returns:

Stream[float] – A stream producing aggregations of the stream history at each time step.

count() Stream[float][source]

Computes an expanding count fo the underlying stream.

Returns:

Stream[float] – An expanding 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 = 'expanding'
has_next() bool[source]

Checks if there is another value.

Returns:

bool – If there is another value or not.

max() Stream[float][source]

Computes an expanding maximum fo the underlying stream.

Returns:

Stream[float] – An expanding maximum stream.

mean() Stream[float][source]

Computes an expanding mean fo the underlying stream.

Returns:

Stream[float] – An expanding mean stream.

median() Stream[float][source]

Computes an expanding median fo the underlying stream.

Returns:

Stream[float] – An expanding median stream.

min() Stream[float][source]

Computes an expanding minimum fo the underlying stream.

Returns:

Stream[float] – An expanding minimum stream.

reset() None[source]

Resets all inputs to and listeners of the stream and sets stream value to None.

std() Stream[float][source]

Computes an expanding standard deviation fo the underlying stream.

Returns:

Stream[float] – An expanding standard deviation stream.

sum() Stream[float][source]

Computes an expanding sum fo the underlying stream.

Returns:

Stream[float] – An expanding sum stream.

var() Stream[float][source]

Computes an expanding variance fo the underlying stream.

Returns:

Stream[float] – An expanding variance stream.

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

Bases: ExpandingNode

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

forward() float[source]

Generates the next value from the underlying data streams.

Returns:

T – The next value in the stream.

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

Bases: Stream[float]

A stream operator for aggregating an entire history of a stream.

Parameters:

func (Callable[[List[float]], float]) – A function that aggregates the history of a stream.

forward() float[source]

Generates the next value from the underlying data streams.

Returns:

T – The next value in the stream.

has_next()[source]

Checks if there is another value.

Returns:

bool – If there is another value or not.

tensortrade.feed.api.float.window.expanding.expanding(s: Stream[float], min_periods: int = 1) Stream[List[float]][source]

Computes a stream that generates the entire history of a stream at each time step.

Parameters:
  • s (Stream[float]) – A float stream.

  • min_periods (int, default 1) – The number of periods to wait before producing values from the aggregation function.