quartic_sdk.core.entity_helpers.entity_list

Module Contents

Classes

EntityList

The given class refers to the list of specific class_type of entity

class quartic_sdk.core.entity_helpers.entity_list.EntityList(class_type, entities_list=[])

The given class refers to the list of specific class_type of entity

__repr__(self)

Return the representation of the entitylist

__str__(self)

Return the stringified representation of the entitylist

_validate_type(self, instance)

We validate that the type of the object is the same as defined for the class definition

get(self, name, value)

We return the entity with the given value for the name of the attribute

all(self)

We return the list of all entities for the given object

first(self)

Return the first element of the list

last(self)

Return the last element of the list

count(self)

Returns the length of all entities

filter(self, **kwargs)

We filter the entities based upon the given conditions There might be multiple conditions :param kwargs: Dict which maps filter_key to filter_value

The filter_key can be decomposed into two parts: (attribute, operator) For instance, if filter_key is created_at__lt then (‘created_at’, ‘lt’) It might also be a simple query where we check for equality, then filter_key is simply the attribute name

check_object_in_list(self, instance)

We check whether the instance is already in the list :param instance: Object that is to be added to the list

add(self, instance)

We add the given object instance to the entities list of the class

exclude(self, **kwargs)

We return the EntityList after removing the entities with the attributes having the given values :param kwargs: Dict which maps filter_key to filter_value

__iter__(self)

We override the iterator to allow the user to iterate on the class

__getitem__(self, key)

Override the method to get the entity list value at the given index

__eq__(self, other)

Check equality of two entity list objects

__bool__(self)

Override to get the bool value of the class if required

data(self, start_time, stop_time, sampling_ratio=1, return_type=Constants.RETURN_PANDAS, batch_size=Constants.DEFAULT_PAGE_LIMIT_ROWS, transformations=[])

Get the data of all tags in the list between the given start_time and stop_time for the given sampling_ratio :param start_time: (epoch) Start_time for getting data :param stop_time: (epoch) Stop_time for getting data :param sampling_ratio: sampling_ratio of the data :param return_type: The param decides whether the data after querying will be

json(when value is “json”) or pandas dataframe(when value is “pd”). By default, it takes the value as “json”

Parameters

transformations

Refers to the list of transformations. It supports either interpolation or aggregation, depending upon which, we pass the value of this dictionary. If transformation_type is “aggregation”, an optional key can be passed called aggregation_timestamp, which determines how the timestamp information will be retained after aggregation. Valid options are “first”, “last” or “discard”. By default, the last timestamp in each group will be retained. An example value here is: [{

”transformation_type”: “interpolation”, “column”: “3”, “method”: “linear”

}, {

“transformation_type”: “aggregation”, “aggregation_column”: “4”, “aggregation_dict”: {“3”: “max”}, “aggregation_timestamp”: “last”,

}]

Returns

(DataIterator) DataIterator object which can be iterated to get the data between the given duration