tensortrade.base.context module¶
-
class
tensortrade.base.context.Context(base_instrument=USD, **kwargs)[source]¶ Bases:
collections.UserDictA context that is injected into every instance of a class that is a subclass of component.
Parameters: base_instrument ( Instrument) – The exchange symbol of the instrument to store/measure value in.-
base_instrument¶ Return type: Instrument
-
-
class
tensortrade.base.context.TradingContext(base_instrument=USD, **config)[source]¶ Bases:
collections.UserDictA class for objects that put themselves in a Context using the with statement.
The implementation for this class is heavily borrowed from the pymc3 library and adapted with the design goals of TensorTrade in mind.
Parameters: - shared – A context that is shared between all components that are made under the overarching TradingContext.
- exchanges – A context that is specific to components with a registered name of exchanges.
- actions – A context that is specific to components with a registered name of actions.
- rewards – A context that is specific to components with a registered name of rewards.
- features – A context that is specific to components with a registered name of features.
Warning
If there is a conflict in the contexts of different components because they were initialized under different contexts, can have undesirable effects. Therefore, a warning should be made to the user indicating that using components together that have conflicting contexts can lead to unwanted behavior.
-
__enter__()[source]¶ Adds a new context to the context stack.
This method is used for a with statement and adds a TradingContext to the context stack. The new context on the stack is then used by every class that subclasses Component the initialization of its instances.
-
contexts= <_thread._local object>¶
Return type: dict