tensortrade.actions.action_strategy module

class tensortrade.actions.action_strategy.ActionStrategy(action_space, dtype=<class 'numpy.float16'>)[source]

Bases: object

An abstract strategy for determining the action to take at each timestep within a trading environment.

abstract __init__(action_space, dtype=<class 'numpy.float16'>)[source]
Parameters
  • action_space (Space) – The shape of the actions produced by the strategy.

  • dtype (Union[type, str]) – A type or str corresponding to the dtype of the action_space. Defaults to np.float16.

property action_space

The shape of the actions produced by the strategy.

Return type

Space

property dtype

A type or str corresponding to the dtype of the action_space.

Return type

Union[type, str]

property exchange

The exchange being used by the current trading environment.

This will be set by the trading environment upon initialization. Setting the exchange causes the strategy to reset.

Return type

InstrumentExchange

abstract get_trade(action)[source]

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

Parameters

action (Union[int, float, tuple]) – The action to be converted into a trade.

Return type

Trade

Returns

The trade to be executed on the exchange this timestep.

reset()[source]

Optionally implementable method for resetting stateful strategies.