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, trade_type=<TradeType.MARKET: 'market'>, duration=None, 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, trade_type=<TradeType.MARKET: 'market'>, duration=None, 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.
action_space

The discrete action space produced by the action scheme.

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

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

Parameters:
  • action (int) – The action to be converted into an order.
  • exchange – The exchange the action will be executed on.
  • portfolio (Portfolio) – The portfolio of wallets used to execute the action.
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]