tensortrade.feed.core.base module¶
-
class
tensortrade.feed.core.base.
Constant
(value, dtype: str = None)[source]¶ Bases:
tensortrade.feed.core.base.Stream
A stream that generates a constant value.
-
forward
()[source]¶ Generates the next value from the underlying data streams.
Returns: T – The next value in the stream.
-
generic_name
= 'constant'¶
-
-
class
tensortrade.feed.core.base.
Group
[source]¶ Bases:
tensortrade.feed.core.base.Stream
A stream that groups together other streams into a dictionary.
-
class
tensortrade.feed.core.base.
IterableStream
(source: Iterable[T], dtype: str = None)[source]¶ Bases:
tensortrade.feed.core.base.Stream
A private class used the Stream class for creating data sources.
Parameters: - source (Iterable[T]) – The iterable to be used for providing the data.
- dtype (str, optional) – The data type of the source.
-
forward
() → T[source]¶ Generates the next value from the underlying data streams.
Returns: T – The next value in the stream.
-
generic_name
= 'stream'¶
-
class
tensortrade.feed.core.base.
NameSpace
(name: str)[source]¶ Bases:
tensortrade.feed.core.base.Named
A 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:
object
A 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. -
generic_name
= 'generic'¶
-
names
= {}¶
-
namespaces
= []¶
-
-
class
tensortrade.feed.core.base.
Placeholder
(dtype: str = None)[source]¶ Bases:
tensortrade.feed.core.base.Stream
A stream that acts as a placeholder for data to be provided at later date.
-
forward
() → T[source]¶ Generates the next value from the underlying data streams.
Returns: T – The next value in the stream.
-
generic_name
= 'placeholder'¶
-
-
class
tensortrade.feed.core.base.
Sensor
(obj, func, dtype=None)[source]¶ Bases:
tensortrade.feed.core.base.Stream
A stream that watches and generates from a particular object.
-
forward
() → T[source]¶ Generates the next value from the underlying data streams.
Returns: T – The next value in the stream.
-
generic_name
= 'sensor'¶
-
-
class
tensortrade.feed.core.base.
Stream
(name: str = None, dtype: str = None)[source]¶ Bases:
typing.Generic
,tensortrade.feed.core.base.Named
,tensortrade.core.base.Observable
A 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][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][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][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][T], mixin: tensortrade.feed.core.mixins.DataTypeMixin) → tensortrade.feed.core.base.Stream[~T][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
¶
-
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.
-
generic_name
= 'stream'¶
-
static
group
(streams: List[tensortrade.feed.core.base.Stream[~T][T]]) → tensortrade.feed.core.base.Stream[dict][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.
-
has_next
() → bool[source]¶ Checks if there is another value.
Returns: bool – If there is another value or not.
-
lag
(*args, **kwargs)¶
-
static
placeholder
(dtype: str = None) → tensortrade.feed.core.base.Stream[~T][T][source]¶ Creates a placholder stream for data to provided to at a later date.
Parameters: dtype (str) – The data type that will be provided. Returns: Stream[T] – A stream representing a placeholder.
-
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.
-
reset
() → None[source]¶ Resets all inputs to and listeners of the stream and sets stream value to None.
-
static
select
(streams: List[tensortrade.feed.core.base.Stream[~T][T]], func: Callable[[tensortrade.feed.core.base.Stream[~T][T]], bool]) → tensortrade.feed.core.base.Stream[~T][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 if 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][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][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)¶
-