tensortrade.env.default.actions module¶
-
class
tensortrade.env.default.actions.BSH(*args, **kwargs)[source]¶ Bases:
tensortrade.env.default.actions.TensorTradeActionSchemeA simple discrete action scheme where the only options are to buy, sell, or hold.
- Parameters
cash (Wallet) – The wallet to hold funds in the base intrument.
asset (Wallet) – The wallet to hold funds in the quote instrument.
-
property
action_space¶ The action space of the TradingEnv. (Space, read-only)
-
get_orders(action: int, portfolio: tensortrade.oms.wallets.portfolio.Portfolio) → tensortrade.oms.orders.order.Order[source]¶ Gets the list of orders to be submitted for the given action.
- Parameters
action (Any) – The action to be interpreted.
portfolio ('Portfolio') – The portfolio defined for the environment.
- Returns
List[Order] – A list of orders to be submitted to the broker.
-
registered_name= 'bsh'¶
-
class
tensortrade.env.default.actions.ManagedRiskOrders(*args, **kwargs)[source]¶ Bases:
tensortrade.env.default.actions.TensorTradeActionScheme- A discrete action scheme that determines actions based on managing risk,
through setting a follow-up stop loss and take profit on every order.
- Parameters
stop (List[float]) – A list of possible stop loss percentages for each order.
take (List[float]) – A list of possible take profit percentages for each order.
trade_sizes (List[float]) – A list of trade sizes to select from when submitting an order. (e.g. ‘[1, 1/3]’ = 100% or 33% of balance is tradable. ‘4’ = 25%, 50%, 75%, or 100% of balance is tradable.)
durations (List[int]) – A list of durations to select from when submitting an order.
trade_type (TradeType) – A type of trade to make.
order_listener (OrderListener) – A callback class to use for listening to steps of the order process.
-
property
action_space¶ The action space of the TradingEnv. (Space, read-only)
-
get_orders(action: int, portfolio: tensortrade.oms.wallets.portfolio.Portfolio) → List[tensortrade.oms.orders.order.Order][source]¶ Gets the list of orders to be submitted for the given action.
- Parameters
action (Any) – The action to be interpreted.
portfolio ('Portfolio') – The portfolio defined for the environment.
- Returns
List[Order] – A list of orders to be submitted to the broker.
-
class
tensortrade.env.default.actions.SimpleOrders(*args, **kwargs)[source]¶ Bases:
tensortrade.env.default.actions.TensorTradeActionSchemeA discrete action scheme that determines actions based on a list of trading pairs, order criteria, and trade sizes.
- Parameters
criteria (List[OrderCriteria]) – A list of order criteria to select from when submitting an order. (e.g. MarketOrder, LimitOrder w/ price, StopLoss, etc.)
trade_sizes (List[float]) – A list of trade sizes to select from when submitting an order. (e.g. ‘[1, 1/3]’ = 100% or 33% of balance is tradable. ‘4’ = 25%, 50%, 75%, or 100% of balance is tradable.)
durations (List[int]) – A list of durations to select from when submitting an order.
trade_type (TradeType) – A type of trade to make.
order_listener (OrderListener) – A callback class to use for listening to steps of the order process.
-
property
action_space¶ The action space of the TradingEnv. (Space, read-only)
-
get_orders(action: int, portfolio: tensortrade.oms.wallets.portfolio.Portfolio) → List[tensortrade.oms.orders.order.Order][source]¶ Gets the list of orders to be submitted for the given action.
- Parameters
action (Any) – The action to be interpreted.
portfolio ('Portfolio') – The portfolio defined for the environment.
- Returns
List[Order] – A list of orders to be submitted to the broker.
-
class
tensortrade.env.default.actions.TensorTradeActionScheme(*args, **kwargs)[source]¶ Bases:
tensortrade.env.generic.components.action_scheme.ActionSchemeAn abstract base class for any ActionScheme that wants to be compatible with the built in OMS.
The structure of the action scheme is built to make sure that action space can be used with the system, provided that the user defines the methods to interpret that action.
-
portfolio¶ The portfolio object to be used in defining actions.
- Type
‘Portfolio’
-
broker¶ The broker object to be used for placing orders in the OMS.
- Type
‘Broker’
-
get_orders(action, portfolio)[source]¶ Gets the list of orders to be submitted for the given action.
-
property
clock¶ The reference clock from the environment. (Clock)
When the clock is set for the we also set the clock for the portfolio as well as the exchanges defined in the portfolio.
- Returns
Clock – The environment clock.
-
abstract
get_orders(action: Any, portfolio: tensortrade.oms.wallets.portfolio.Portfolio) → List[tensortrade.oms.orders.order.Order][source]¶ Gets the list of orders to be submitted for the given action.
- Parameters
action (Any) – The action to be interpreted.
portfolio ('Portfolio') – The portfolio defined for the environment.
- Returns
List[Order] – A list of orders to be submitted to the broker.
-
perform(env: tensortrade.env.generic.environment.TradingEnv, action: Any) → None[source]¶ Performs the action on the given environment.
Under the TT action scheme, the subclassed action scheme is expected to provide a method for getting a list of orders to be submitted to the broker for execution in the OMS.
- Parameters
env ('TradingEnv') – The environment to perform the action on.
action (Any) – The specific action selected from the action space.
-
-
tensortrade.env.default.actions.get(identifier: str) → tensortrade.env.generic.components.action_scheme.ActionScheme[source]¶ Gets the ActionScheme that matches with the identifier.
- Parameters
identifier (str) – The identifier for the ActionScheme.
- Returns
‘ActionScheme’ – The action scheme associated with the identifier.
- Raises
KeyError: – Raised if the identifier is not associated with any ActionScheme.