Skip to content

indicator_collection

indicator_collection

Classes:

Name Description
IndicatorCollection

Group indicators for direct attribute access on a strategy collection.

Functions:

Name Description
indicator_field

Mark a dataclass field as a strategy indicator for IndicatorCollection.

IndicatorCollection

IndicatorCollection(*indicators: Indicator)

Group indicators for direct attribute access on a strategy collection.

Subclass as a dataclass and mark indicator fields with indicator_field(), or pass indicators explicitly to __init__.

Source code in hexital/core/indicator_collection.py
def __init__(self, *indicators: Indicator) -> None:
    self._explicit = indicators or None

indicator_field

indicator_field(
    *, default: Any = ..., default_factory: Any = ..., **kwargs: Any
) -> Field

Mark a dataclass field as a strategy indicator for IndicatorCollection.

Source code in hexital/core/indicator_collection.py
def indicator_field(
    *,
    default: Any = ...,
    default_factory: Any = ...,
    **kwargs: Any,
) -> Field:
    """Mark a dataclass field as a strategy indicator for IndicatorCollection."""
    metadata = {**kwargs.pop("metadata", {}), _INDICATOR_METADATA_KEY: True}
    field_kwargs = {"metadata": metadata, **kwargs}
    if default_factory is not ...:
        return field(default_factory=default_factory, **field_kwargs)
    if default is not ...:
        return field(default=default, **field_kwargs)
    return field(**field_kwargs)