Files
aiomql/docs/core/base.md
T
Ichinga Samuel e285610fe5 3.0.4
2023-10-16 15:36:31 +01:00

3.4 KiB

Table of Contents

aiomql.core.base

Base Objects

class Base()

A base class for all data model classes in the aiomql package. This class provides a set of common methods and attributes for all data model classes. For the data model classes attributes are annotated on the class body and are set as object attributes when the class is instantiated.

Arguments:

  • **kwargs - Object attributes and values as keyword arguments. Only added if they are annotated on the class body.

    Class Attributes:

  • mt5 MetaTrader - An instance of the MetaTrader class

  • config Config - An instance of the Config class

  • Meta Type[Meta] - The Meta class for configuration of the data model class

set_attributes

def set_attributes(**kwargs)

Set keyword arguments as object attributes

Arguments:

  • **kwargs - Object attributes and values as keyword arguments

Raises:

  • AttributeError - When assigning an attribute that does not belong to the class or any parent class

Notes:

Only sets attributes that have been annotated on the class body.

annotations

@property
@cache
def annotations() -> dict

Class annotations from all ancestor classes and the current class.

Returns:

  • dict - A dictionary of class annotations

get_dict

def get_dict(exclude: set = None, include: set = None) -> dict

Returns class attributes as a dict, with the ability to filter

Arguments:

  • exclude - A set of attributes to be excluded
  • include - Specific attributes to be returned

Returns:

  • dict - A dictionary of specified class attributes

Notes:

You can only set either of include or exclude. If you set both, include will take precedence

class_vars

@property
@cache
def class_vars()

Annotated class attributes

Returns:

  • dict - A dictionary of available class attributes in all ancestor classes and the current class.

dict

@property
def dict() -> dict

All instance and class attributes as a dictionary, except those excluded in the Meta class.

Returns:

  • dict - A dictionary of instance and class attributes

Meta Objects

class Meta()

A class for defining class attributes to be excluded or included in the dict property

Attributes:

  • exclude set - A set of attributes to be excluded
  • include set - Specific attributes to be returned. Include supercedes exclude.

filter

@classmethod
@property
def filter(cls) -> set

Combine the exclude and include attributes to return a set of attributes to be excluded.

Returns:

  • set - A set of attributes to be excluded