tensortrade.env.default.stoppers module

class tensortrade.env.default.stoppers.MaxLossStopper(max_allowed_loss: float)[source]

Bases: tensortrade.env.generic.components.stopper.Stopper

A stopper that stops an episode if the portfolio has lost a particular percentage of its wealth.

Parameters:max_allowed_loss (float) – The maximum percentage of initial funds that is willing to be lost before stopping the episode.
max_allowed_loss

The maximum percentage of initial funds that is willing to be lost before stopping the episode.

Type:float

Notes

This stopper also stops if it has reached the end of the observation feed.

stop(env: tensortrade.env.generic.environment.TradingEnv) → bool[source]

Computes if the environment satisfies the defined stopping criteria.

Parameters:env (TradingEnv) – The trading environment.
Returns:bool – If the environment should stop or continue.