tensortrade.feed.core.base module¶
-
class
tensortrade.feed.core.base.Constant(*args, **kwargs)[source]¶ Bases:
tensortrade.feed.core.base.StreamA stream that generates a constant value.
-
class
tensortrade.feed.core.base.Group(*args, **kwargs)[source]¶ Bases:
tensortrade.feed.core.base.StreamA stream that groups together other streams into a dictionary.
-
class
tensortrade.feed.core.base.NameSpace(name: str)[source]¶ Bases:
tensortrade.feed.core.base.NamedA class providing a context in which to create names.
This becomes useful in cases where Named object would like to use the same name in a different context. In order to resolve naming conflicts in a DataFeed, this class provides a way to solve it.
- Parameters
name (str) – The name for the NameSpace.
-
class
tensortrade.feed.core.base.Named(name: str = None)[source]¶ Bases:
objectA class for controlling the naming of objects.
The purpose of this class is to control the naming of objects with respect to the NameSpace to which they belong to. This prevents conflicts that arise in the naming of similar objects under different contexts.
- Parameters
name (str, optional) – The name of the object.
-
rename(name: str, sep: str = ':/') → tensortrade.feed.core.base.Named[source]¶ Renames the instance with respect to the current NameSpace.
-
class
tensortrade.feed.core.base.Sensor(*args, **kwargs)[source]¶ Bases:
tensortrade.feed.core.base.StreamA stream that watches and generates from a particular object.
-
class
tensortrade.feed.core.base.Stream(*args, **kwargs)[source]¶ Bases:
typing.Generic,tensortrade.feed.core.base.Named,tensortrade.core.base.ObservableA class responsible for creating the inputs necessary to work in a DataFeed.
- Parameters
-
select(streams, func)[source]¶ Selects a stream satisfying particular criteria from a list of streams.
-
asdtype(dtype)¶ Converts the data type to dtype.
-
__call__(*inputs) → tensortrade.feed.core.base.Stream[T][source]¶ Connects the inputs to this stream.
- Parameters
*inputs (positional arguments) – The positional arguments, each a stream to be connected as an input to this stream.
- Returns
Stream[T] – The current stream inputs are being connected to.
-
accumulate(*args, **kwargs)¶
-
apply(*args, **kwargs)¶
-
astype(dtype: str) → tensortrade.feed.core.base.Stream[T][source]¶ Converts the data type to dtype.
- Parameters
dtype (str) – The data type to be converted to.
- Returns
Stream[T] – The same stream with the new underlying data type dtype.
-
bool¶
-
static
constant(value: T, dtype: str = None) → tensortrade.feed.core.base.Stream[T][source]¶ Creates a stream to generate a constant value.
- Parameters
value (T) – The constant value to be streamed.
dtype (str, optional) – The data type of the value.
- Returns
Stream[T] – A stream of the constant value.
-
copy(*args, **kwargs)¶
-
static
extend_instance(instance: tensortrade.feed.core.base.Stream[T], mixin: tensortrade.feed.core.mixins.DataTypeMixin) → tensortrade.feed.core.base.Stream[T][source]¶ Apply mix-ins to a class instance after creation.
- Parameters
instance (Stream[T]) – An instantiation of Stream to be injected with mixin methods.
mixin (DataTypeMixin) – The mixin holding the methods to be injected into the instance.
- Returns
Stream[T] – The instance with the injected methods provided by the mixin.
-
float¶
-
abstract
forward() → T[source]¶ Generates the next value from the underlying data streams.
- Returns
T – The next value in the stream.
-
freeze(*args, **kwargs)¶
-
gather() → List[Tuple[tensortrade.feed.core.base.Stream, tensortrade.feed.core.base.Stream]][source]¶ Gathers all the edges of the DAG connected in ancestry with this stream.
- Returns
List[Tuple[Stream, Stream]] – The list of edges connected through ancestry to this stream.
-
static
group(streams: List[tensortrade.feed.core.base.Stream[T]]) → tensortrade.feed.core.base.Stream[dict][source]¶ Creates a group of streams.
- Parameters
streams (List[Stream[T]]) – Streams to be grouped together.
- Returns
Stream[dict] – A stream of dictionaries with each stream as a key/value in the dictionary being generated.
-
abstract
has_next() → bool[source]¶ Checks if there is another value.
- Returns
bool – If there is another value or not.
-
lag(*args, **kwargs)¶
-
reduce(*args, **kwargs)¶
-
classmethod
register_accessor(name: str)[source]¶ A class decorator that registers an accessor providing useful methods for a particular data type..
Sets the data type accessor to be an attribute of this class.
- Parameters
name (str) – The name of the data type.
-
classmethod
register_generic_method(names: List[str])[source]¶ A function decorator that registers the decorated function with the names provided as a method to the Stream class.
These methods can be used for any instance of Stream.
- Parameters
names (List[str]) – The list of names to be used as aliases for the same method.
-
classmethod
register_mixin(dtype: str)[source]¶ A class decorator the registers a data type mixin providing useful methods directly to the instance of the class.
- Parameters
dtype (str) – The name of the data type the mixin is being registered for.
-
static
select(streams: List[tensortrade.feed.core.base.Stream[T]], func: Callable[tensortrade.feed.core.base.Stream[T], bool]) → tensortrade.feed.core.base.Stream[T][source]¶ Selects a stream satisfying particular criteria from a list of streams.
- Parameters
streams (List[Stream[T]]) – A list of streams to select from.
func (Callable[[Stream[T]], bool]) – The criteria to be used for finding the particular stream.
- Returns
Stream[T] – The particular stream being selected.
- Raises
Exception – Raised of no stream is found to satisfy the given criteria.
-
static
sensor(obj: Any, func: Callable[Any, T], dtype: str = None) → tensortrade.feed.core.base.Stream[T][source]¶ Creates a stream from observing a value from an object.
- Parameters
obj (Any) – An object to observe values from.
func (Callable[[Any], T]) – A function to extract the data to be observed from the object being watched.
dtype (str, optional) – The data type of the stream.
- Returns
Stream[T] – The stream of values being observed from the object.
-
static
source(iterable: Iterable[T], dtype: str = None) → tensortrade.feed.core.base.Stream[T][source]¶ Creates a stream from an iterable.
- Parameters
iterable (Iterable[T]) – The iterable to create the stream from.
dtype (str, optional) – The data type of the stream.
- Returns
Stream[T] – The stream with the data type dtype created from iterable.
-
str¶
-
static
toposort(edges: List[Tuple[tensortrade.feed.core.base.Stream, tensortrade.feed.core.base.Stream]]) → List[tensortrade.feed.core.base.Stream][source]¶ Sorts the order in which streams should be run.
- Parameters
edges (List[Tuple[Stream, Stream]]) – The connections that have been found in the DAG.
- Returns
List[Stream] – The list of streams sorted with respect to the order in which they should be run.
-
warmup(*args, **kwargs)¶