tensortrade.base.context module

class tensortrade.base.context.Context(**kwargs)[source]

Bases: collections.UserDict

A context that is injected into every instance of a class that is a subclass of component.

class tensortrade.base.context.TradingContext(config)[source]

Bases: collections.UserDict

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

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.

Reference:
__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>
classmethod from_json(path)[source]
classmethod from_yaml(path)[source]
classmethod get_context()[source]

Gets the deepest context on the stack.

classmethod get_contexts()[source]
shared
Return type:dict