tensortrade.env.default.observers module

class tensortrade.env.default.observers.ObservationHistory(window_size: int)[source]

Bases: object

Stores observations from a given episode of the environment.

Parameters

window_size (int) – The amount of observations to keep stored before discarding them.

window_size

The amount of observations to keep stored before discarding them.

Type

int

rows

The rows of observations that are used as the environment observation at each step of an episode.

Type

pd.DataFrame

observe() → numpy.array[source]

Gets the observation at a given step in an episode

Returns

np.array – The current observation of the environment.

push(row: dict)None[source]

Stores an observation.

Parameters

row (dict) – The new observation to store.

reset()None[source]

Resets the observation history

class tensortrade.env.default.observers.TensorTradeObserver(*args, **kwargs)[source]

Bases: tensortrade.env.generic.components.observer.Observer

The TensorTrade observer that is compatible with the other default components.

Parameters
  • portfolio (Portfolio) – The portfolio to be used to create the internal data feed mechanism.

  • feed (DataFeed) – The feed to be used to collect observations to the observation window.

  • renderer_feed (DataFeed) – The feed to be used for giving information to the renderer.

  • window_size (int) – The size of the observation window.

  • min_periods (int) – The amount of steps needed to warmup the feed.

  • **kwargs (keyword arguments) – Additional keyword arguments for observer creation.

feed

The master feed in charge of streaming the internal, external, and renderer data feeds.

Type

DataFeed

window_size

The size of the observation window.

Type

int

min_periods

The amount of steps needed to warmup the feed.

Type

int

history

The observation history.

Type

ObservationHistory

renderer_history

The history of the renderer data feed.

Type

List[dict]

has_next()bool[source]

Checks if there is another observation to be generated.

Returns

bool – Whether there is another observation to be generated.

property observation_space

The observation space of the TradingEnv. (Space, read-only)

observe(env: TradingEnv) → numpy.array[source]

Observes the environment.

As a consequence of observing the env, a new observation is generated from the feed and stored in the observation history.

Returns

np.array – The current observation of the environment.

reset()None[source]

Resets the observer

warmup()None[source]

Warms up the data feed.