tensortrade.actions.managed_risk_orders module

class tensortrade.actions.managed_risk_orders.ManagedRiskOrders(stop_loss_percentages=[0.02, 0.04, 0.06], take_profit_percentages=[0.01, 0.02, 0.03], trade_sizes=10, durations=None, trade_type=<TradeType.MARKET: 'market'>, order_listener=None)[source]

Bases: tensortrade.actions.action_scheme.ActionScheme

A discrete action scheme that determines actions based on managing risk, through setting a follow-up stop loss and take profit on every order.

__init__(stop_loss_percentages=[0.02, 0.04, 0.06], take_profit_percentages=[0.01, 0.02, 0.03], trade_sizes=10, durations=None, trade_type=<TradeType.MARKET: 'market'>, order_listener=None)[source]
Parameters:
  • pairs – A list of trading pairs to select from when submitting an order.
  • TradingPair ((e.g.) –
  • stop_loss_percentages (Union[List[float], float]) – A list of possible stop loss percentages for each order.
  • take_profit_percentages (Union[List[float], float]) – A list of possible take profit percentages for each order.
  • trade_sizes (Union[List[float], int]) – A list of trade sizes to select from when submitting an order.
  • '[1, 1/3]' = 100% or 33% of balance is tradable. '4' = 25%, 50%, 75%, or 100% of balance is tradable.) ((e.g.) –
  • order_listener (optional) – An optional listener for order events executed by this action scheme.
compile()[source]
durations

A list of durations to select from when submitting an order.

Return type:List[int]
get_order(action, portfolio)[source]

Get the order to be executed on the exchange based on the action provided.

Parameters:
  • action (int) – any The action to be converted into an order.
  • portfolio (Portfolio) – ‘Portfolio’ The portfolio the environment is operating on.
Return type:

Order

Returns:

The order to be executed on the exchange this time step.

reset()[source]

An optional reset method, which will be called each time the environment is reset.

stop_loss_percentages

A list of order percentage losses to select a stop loss from when submitting an order. (e.g. 0.01 = sell if price drops 1%, 0.15 = 15%, etc.)

Return type:List[float]
take_profit_percentages

A list of order percentage gains to select a take profit from when submitting an order. (e.g. 0.01 = sell if price rises 1%, 0.15 = 15%, etc.)

Return type:List[float]
trade_sizes

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.)

Return type:List[float]